Sets the visibility of dataSeries. Data Series is visible by default and you can hide the same by setting visible property to false.
Default: truevar chart = new CanvasJS.Chart("container", { . . data: [{ visible: false, . . }], . . }); chart.render();
In the below example first data series is hidden by setting visible property to false. You can try un hiding the same by changing it to false.
Also See:
6 Comments
How could you set it up so that when you click on one of the legend items, two of the dataSeries are made visible or invisible?
I have a line graph with multiple lanes that have a shared tool tips. When I hide one line, or many, they still display in tool tips. Is there a way to make it not display in tool tips if its visibility is set to false?
Sorry for the quick question/answer but I figured it out and I thought I would share this. This is my toolTip:
(wont let me post my code)
https://jsfiddle.net/1trzg0z4/
Is there a way to hide/unhide series other than through the legend click event. For example if I wanted to turn off a series by a button click. Is this possible?
Thanks
Matthew,
It is quite possible to hide/unhide dataSeries through any event. Just in the implementation of the eventHandler you have to set the visible property of the dataSeries to false/true that you want to hide/unhide
Here is an example
Thanks for the help. For anyone having problems I had to modify the code. In my code I had to click the button twice in order to get the series to hide/ unhide properly and then it worked normally. This may be because I am adding my data dynamically. To fix the issue I had to set the visibility parameter to true when I added the series as its undefined at first. Now the code works as expected.