1

I created a line chart in BB.js (same api as C3.js) like this:

In document.ready

function createChart2(chartX,chartY){
    var chart2 = bb.generate({
        bindto: "#chart2",
        data: {
            columns:[chartX,chartY]
        },
        title: {
            text: "Results house 1"
        }
    });
}

chartX and chartY are arrays of data and my linechart is generated fine. Now I want to create a button which allows the user to toggle one of the lines. So I did this:

<div id="option">
<input name="updateButton" 
       type="button" 
       value="Update" 
       onclick="updateData()" />
</div>
<script>
  function updateData(){
chart2.toggle('chartX');
  }
</script>

When I press the button I do not get an error but the line is not toggled. What can be wrong in this example?

hacking_mike
  • 1,005
  • 1
  • 8
  • 22

1 Answers1

1

The issue was that I needed to hide the "label" from my data. And not the complete array. So not:

chart2.toggle('chartX');

but:

chart2.toggle('Weight'); // which is the first entry in my "chartX" array
hacking_mike
  • 1,005
  • 1
  • 8
  • 22