showInLegend: Boolean

Setting this property to true makes the dataSeries to appear in legend. In case of pie/ doughnut chart, dataPoints of the single series chart appear in legend.

Default: false
Options: false, true

  • You can individually choose the dataSeries elements to be shown in legend.
  • Text appearing in Legend can be customized by setting legendText attribute.

var  chart =  new  CanvasJS.Chart("container",
 data: [{
  showInLegend: true,

Try it Yourself by Editing the Code below.

  Also See:    

If you have any questions, please feel free to ask in our forums.Ask Question

Comments 9

  1. Hi!
    The is a bug in Legend showing. Try to append the next code:
    legend: {
    itemclick : function(e) {
    if (typeof(e.dataSeries.visible) === “undefined” || e.dataSeries.visible) {
    e.dataSeries.visible = false;
    } else {
    e.dataSeries.visible = true;

    into the options of chart and try to click on “DataSeries 3” after that!

  2. Hi!
    I am using canvasJS chart to render a scatter chart. In that I am using 4 different dataseries , I need to show all four legends on chart but with my own alignment . Two of them should be displayed on top right side vertical each one separate line and one of them at top of y-axis and remaining at start of x-axis . Can I able to align legend position dynamically .Please I need it as urgent as possible..
    I have create a fiddler example . You can use that to help me out.

If you have any questions, please feel free to ask in our forums. Ask Question