New to Kendo UI for jQuery? Start a free 30-day trial

Legend.item

configuration

The configuration of the Chart legend item.

To override the marker configuration of individual series, use the series.legendItem settings of the series.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "line",
    markers: {
      visible: true
    },
    data: [1, 2, 3]
  }, {
    type: "line",
    markers: {
      type: 'roundedRect',
      visible: true
    },
    data: [4, 5, 6]
  }],
  legend: {
    item: {
      highlight: {
        visible: false
      }
    }
  }
});
</script>
<div id="chart"></div>
<script>
$("#chart").kendoChart({
  series: [{
    type: "line",
    markers: {
      visible: true
    },
    data: [1, 2, 3]
  }, {
    type: "line",
    markers: {
      type: 'roundedRect',
      visible: true
    },
    data: [4, 5, 6]
  }],
  seriesDefaults: {
      /* Use these settings to emulate the legacy legend item rendering */
      legendItem: {
          type: 'line',
          line: {
              dashType: 'solid',
          },
          markers: {
              visible: false
          },
          highlight: {
              visible: false
          }
      },
  }
});
</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]
  }],
  legend: {
    item: {
      area: {
        opacity: 0.1,
      }
    }
  }
});
</script>

The cursor style of the legend item.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  legend: {
    item: {
      cursor: "pointer"
    }
  },
  series: [
    { name: "Series 1", data: [1, 2, 3] },
    { name: "Series 2", data: [4, 5, 6] }
  ]
});
</script>

The highlight configuration of the legend item.

<div id="chart"></div>
<script>
$("#chart").kendoChart({
  legend: {
    item: {
      highlight: {
        markers: {
          background: "yellow",
          border: {
            color: "red",
            width: 2
          }
        },
        visible: true
      }
    }
  },
  series: [
    { name: "Series 1", data: [1, 2, 3] },
    { name: "Series 2", data: [4, 5, 6] }
  ]
});
</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]
  }],
  legend: {
    item: {
      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]
  }],
  legend: {
    item: {
      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({
  legend: {
    item: {
      type: "line"
    }
  },
  series: [
    { name: "Area Series", data: [1, 2, 3], type: "area" },
    { name: "Column Series", data: [4, 5, 6], type: "column" }
  ]
});
</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({
    legend: {
      item: {
        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;
        }
      }
    },
    series: [
      { name: "Series 1", data: [1, 2, 3] },
      { name: "Series 2", data: [3, 4, 5] }
    ]
  });
</script>