Skip to main content
A newer version of this page is available. .

How to: Custom Draw Series

  • 6 minutes to read

This example demonstrates one of several possible ways of using the ChartControl.CustomDrawSeries event. In the sample, the event is used to draw custom legend markers for a series.

A custom legend marker is set to the CustomDrawSeriesEventArgsBase.LegendMarkerImage property. Note that in this case, the CustomDrawSeriesEventArgsBase.DisposeLegendMarkerImage property should be set to true to avoid memory leaks.

To customize options used to draw the series point, cast CustomDrawSeriesEventArgsBase.SeriesDrawOptions to the DrawOptions class descendant that stores draw options of the required series view type.

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace CustomDrawingSample.Model {
    public partial class Order {
        [Key]
        public int OrderID { get; set; }

        [Column("EmployeeID")]
        [ForeignKey("Employee")]
        public int? EmployeeId { get; set; }

        [Column("Freight", TypeName = "smallmoney")]
        public decimal Freight { get; set; }

        [Column("OrderDate", TypeName = "datetime")]
        public DateTime OrderDate { get; set; }

        public virtual Employee Employee { get; set; }
    }
}
See Also