Issue with bindto when adding multiple donuts charts
Hi,
I am trying to add multiple donut charts to my project and the bindto property is not working. When running this code I am unable to see any of the donut charts. (I have tried all the bindto alternatives)
Here is my code:
HTML:
<div id="chart1" style="height:300px;"></div>
<div id="chart2" style="height:300px;"></div>
JS:
var donut1 = c3.generate({
data: {
bindto: '#chart1',
columns: [
['data1', 30],
['data2', 120],
['data3', 50],
],
type : 'donut',
onclick: function (d, i) { console.log("onclick", d, i); },
onmouseover: function (d, i) { console.log("onmouseover", d, i); },
onmouseout: function (d, i) { console.log("onmouseout", d, i); }
},
donut: {
title: "chart1"
}
});
var donut2 = c3.generate({
data: {
bindto: '#chart2',
columns: [
['data1', 50],
['data2', 40],
['data3', 50],
],
type : 'donut',
onclick: function (d, i) { console.log("onclick", d, i); },
onmouseover: function (d, i) { console.log("onmouseover", d, i); },
onmouseout: function (d, i) { console.log("onmouseout", d, i); }
},
donut: {
title: "chart2"
}
});
This are the css and js files:
<link href="css/c3.css" rel="stylesheet"/>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="js/c3.js" type="text/javascript"></script>
Hi @jmoller!
Please query the Google Group before posting issues, it's likely somebody there can solve it. We try to keep the issue queue free for feature requests and bug reports. :smile:
In your case, the problem is because bindto is inside chart.data; it needs to be top-level, i.e., chart.bindto.
http://plnkr.co/edit/w7pPSIQz0B8SbU8i5nOR?p=preview
Thank you very much!!
Thanks you very much, it really saved my ass!!