ManifestWebDesign / angular-gridster

An implementation of gridster-like widgets for Angular JS
http://manifestwebdesign.github.io/angular-gridster/
MIT License
964 stars 394 forks source link

Gridster with NVD3 isn't sizing appropriately #476

Closed dekkofilms closed 6 years ago

dekkofilms commented 7 years ago

I'm using gridster, and everything is working pretty smoothly, but one of my charts is not positioned or sized correctly. Any ideas or help would be appreciated!

So on initial page load it is positioned wrong, and super tiny:

screen shot 2017-03-31 at 3 49 35 pm

But if I drag the entire browser a little bit, it immediately fixes itself in place:

screen shot 2017-03-31 at 3 49 44 pm

How can i have it in it's correct position and behavior without having to drag the browser in for it to fix itself?

$scope.options = {
  chart: {
      type: 'pieChart',
      margin : {
        top: 30,
        right: 0,
        bottom: 0,
        left: 0
      },
      height: 300,
      x: function(d){return d.key;},
      y: function(d){return d.y;},
      showLabels: false,
      legendPosition: false,
      duration: 500,
  }
};
$scope.data = [
  {
      key: "iOS",
      y: 1,
      color: '#ff7f0e'
  },
  {
      key: "Android",
      y: 1,
      color: '#79d8c5'
  }
];

And here is the gridster options and grid:

$scope.gridsterOpts = {
  columns: 6,
  colWidth: 'auto',
  rowHeight: 100,
  resizable: {
     enabled: false,
  },
  draggable: {
    enabled: true,
    handle: '.dragger'
  }
};

$scope.standardItems = [
    { sizeX: 2, sizeY: 3, row: 0, col: 0 }, //net profit
    { sizeX: 2, sizeY: 3, row: 0, col: 2 }, //orders as of tday
    { sizeX: 2, sizeY: 5, row: 0, col: 4 }, //average users

    { sizeX: 4, sizeY: 4, row: 3, col: 0 }, //recent order graph
    { sizeX: 2, sizeY: 2, row: 5, col: 4 }, //as of yesterday
    { sizeX: 3, sizeY: 3, row: 7, col: 0 }, //trending products
    { sizeX: 3, sizeY: 3, row: 7, col: 3 }, //top searches
    { sizeX: 6, sizeY: 3, row: 10, col: 0 }  //order history
];

I have another chart in the same dashboard, and that one doesn't have this issue at all, so I am a little stumped at this point.

tareqx2 commented 7 years ago

I actually had a similar issue, what I found was that it's a bug with nvd3. To get around it I had to re-render the chart on gridster-resized event

    this.$scope.$on('gridster-resized', (item) =>{
        this.$timeout(()=>{
            this.nvChart.update();
        });
    });`