New to Kendo UI for jQueryStart a free 30-day trial

Series.legendItem

configuration

The configuration of the Chart legend item for this series.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "line",
    name: "Series A",
    markers: {
      visible: true
    },
    legendItem: {
      type: "area"
    },
    data: [1, 2, 3]
  }, {
    type: "line",
    name: "Series A",
    markers: {
      type: 'roundedRect',
      visible: true
    },
    legendItem: {
      type: "area"
    },
    data: [4, 5, 6]
  }]
});
</script>

Sets the configuration of the legend items of type area. By default, all series except line and scatter use this legend type.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "area",
    name: "Series A",
    data: [1, 2, 3]
  }, {
    type: "area",
    name: "Series B",
    data: [4, 5, 6],
    legendItem: {
      area: {
        opacity: 0.1,
      }
    }
  }]
});
</script>

The cursor style of the legend item.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "line",
    name: "Series A",
    data: [1, 2, 3],
    legendItem: {
      cursor: "pointer"
    }
  }]
});
</script>

The highlight configuration of the legend item.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "line",
    name: "Series A",
    data: [1, 2, 3],
    legendItem: {
      highlight: {
        visible: true,
        markers: {
          background: "red"
        }
      }
    }
  }]
});
</script>

Sets the configuration of the legend items of type line. This is the default legend item type for all line and scatter series.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "line",
    name: "Series A",
    data: [1, 2, 3]
  }, {
    type: "line",
    name: "Series B",
    data: [4, 5, 6],
    legendItem: {
      line: {
        color: "#777",
      }
    }
  }]
});
</script>

The configuration of the Chart legend item markers.

By default, the marker configuration will be the same as the series.markers settings of the displayed series.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "line",
    markers: {
      visible: true,
      background: "green"
    },
    data: [1, 2, 3],
    legendItem: {
      markers: {
        visible: false
      }
    }
  }]
});
</script>

Sets the type of the legend items. The default value is based on the series type.

The supported values are:

  • "line"—the legend items are rendered as a line. This is the default value for line charts.
  • "area"—the legend items are rendered as a filled rectangle. This is the default value for area charts.
<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "line",
    name: "Series A",
    data: [1, 2, 3],
    legendItem: {
      type: "area"
    }
  }]
});
</script>

A function that can be used to create a custom visual for the legend items. The available argument fields are:

  • options—The item options.
  • createVisual—A function for getting the default visual.
  • series—The item series.
  • pointIndex—The index of the point in the series. Available for the Pie, Donut, and Funnel series.
<div id="chart"></div>
<script>
  $("#chart").kendoChart({
    series: [
      {
        name: "Series 1",
        data: [1, 2, 3],
        legendItem: {
          visual: function (e) {
            var color = e.options.markers.background;
            var labelColor = e.options.labels.color;
            var rect = new kendo.geometry.Rect([0, 0], [100, 50]);
            var layout = new kendo.drawing.Layout(rect, {
              spacing: 5,
              alignItems: "center"
            });

            var marker = new kendo.drawing.Path({
              fill: {
                color: color
              }
            }).moveTo(10, 0).lineTo(15, 10).lineTo(5, 10).close();

            var label = new kendo.drawing.Text(e.series.name, [0, 0], {
              fill: {
                color: labelColor
              }
            });

            layout.append(marker, label);
            layout.reflow()

            return layout;
          }
        }
      }
    ]
  });
</script>