I have the following CanvasJS Chart, serveRate and serveRate2 are defined earlier:
$(".ChartContainer").CanvasJSChart({
data: [
{
type: "column",
name: "Your Desired Rating",
legendText: "Your Desired Rating",
showInLegend: true,
dataPoints: servRate
},
{
type: "column",
name: "Your Desired Rating",
legendText: "Your Desired Rating",
showInLegend: false,
dataPoints: servRate2,
visible: false
},
]
});
I am trying to programmatically access the visible option in the second data set. I am trying
$(".ChartContainer").CanvasJSChart().data[1].visible
But I don't think I am doing it correctly? is there a way to access these options for getting or setting?
You need to update options/data via chart's options object as described here.
Please try $(".ChartContainer").CanvasJSChart().options.data[1].visible
You can also keep a reference of the options object before passing it to the constructor and update the same later.