label: String

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 value
Example: “label1”, “label2”..

Notes
  • To make an axis appear as a category Axis, one must set label property for all dataPoints.


var  chart =  new  CanvasJS.Chart("container",
{
 .
 .
 data: [{
  dataPoints: [
   { y: 10,  label: "label1" },

   ],

  },
 ]
 .
 .
});
chart.render();


Try it Yourself by Editing the Code below.

  Also See:    



In order to provide better support,we have closed the comments and switched completely to our Forums.
If you have any questions, please feel free to ask in our forums.

Comments 8

  1. 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}.

  2. 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.

  3. 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?

In order to provide better support,we have closed the comments and switched completely to our Forums.
If you have any questions, please feel free to ask in our forums.