Sets label value of a dataPoint. The value appears next to the dataPoint on axisX Line. If not provided, it takes x value for label.
Default: x valuevar chart = new CanvasJS.Chart("container", { . . data: [{ dataPoints: [ { y: 10, label: "label1" }, ], }, ] . . }); chart.render();
Also See:
8 Comments
Hi,
In the above example when i add another datapoint { y: 23, label: ‘cat 9’ } the label appears twice on the X axis. How can i make the y point 23 appear in the old category itself. Just to add i also changed the series type to ‘line’
puneet,
You have two options
1. Change/Update existing dataPoint at “cat 9” like “chart.options.data[0].dataPoints[8].y = 23”
2. Every dataPoint appears corresponding to x value – which we are assigning internally in this case. So we would suggest setting x value for all dataPoints so that you can control their position. So, two of your dataPoint would look like like: { y: 14, label: “cat 9”, x: 8} and { y: 23, label: “cat 9”, x: 8}.
Hi,
Seems the label can only set on the axisX. Is there any way to set it on axisY?
Because I want to show Time on axisX and category on axisY.
Thanks in advance.
Y-axis is numeric, so you have to use labelFormatter to assign text-labels to y-axis as shown here.
Thanks very much.
I made a demo reference your advice as shown here.
Thanks again.
Hi. I want to add labels to all of my datapoints, so that they show up as the tooltips. But, i want the x-axis to still appear as a numeric axis with numeric labels. Is there any way to do that?
Stephen,
Hope toolTipContent helps you achieve your requirement.