seriesDefaults.legendItem.visual Function

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.

Example - using custom visual for the legend items

<div id="chart"></div>
<script>
  $("#chart").kendoChart({
    series: [
      {
        name: "Series 1",
        data: [1, 2, 3]
      }
    ],
    seriesDefaults: {
      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>
In this article