When recalculating a donut or pie chart, it keeps growing slightly
I generate a very simple donut chart and I noticed that when I call chart.unload() and the chart recalculates, the resulting chart is a bit bigger each time.
Opening up the js console after the chart has been created, and issuing the following:
chart.unload('NonexistantName');
results in the svg area increasing by 5 pixels each time. Similarly, using toPie() and toDonut() have the same effect.
I'm using Chrome 33.0.1750.154m on WIndows.
Hi @sdarnell ,
Thank you for reporting. Could you provide me some code or jsfiddle to reproduce the situation?
Here's a jsFiddle that shows the problem: http://jsfiddle.net/DWma4/2/
In my scenario I'd like to setup the the chart, but load the data later (when it has arrived), but I'd rather not have the data update doing the main chart configuration. But obviously I could do if really necessary.
Thanks, Steve
Slightly simpler jsfiddle: http://jsfiddle.net/DWma4/3/
I see this same behavior if I do not explicitly define the size in the chart. If I define the chart as follows and do not set the size when generating the chart, the chart will continue to grow every time I load new data.
<div id="chart"></div>
If I define the size either when generating the chart or in the style for the chart div, it works fine.
size: {
height: 450,
width: 900
},
<div id="chart" style="height: 450px; width: 100%"></div>
It's not exactly the same example as mentioned above, but it makes sense that it would be the same bug.
@sdarnell @sdarnell
I think this has been fixed by the commit above. I found the cause was inconsistency of the height between the div for bindto and svg when <!DOCTYPE html> specified.
When <!DOCTYPE html> specified, the height of div for bindto become a little bigger than that of svg. So, I fixed this by adding max-height to the bindto div as the height of svg.
Please try the newest code including the commit.
Thanks @masayuki0812 this did fix it for me. Apologies for the delay in verifying. BTW Thanks @nathancole for the work-around.