set labels on datapoints using mschart

12,504

Datapoint has a label property that can be set programatically:

DataPoint dp = new DataPoint();
dp.Label = c.Start.ToShortTimeString() + " - " + c.End.ToShortTimeString() + "\n" + c.Class;

You can iterate through the datapoints in a series after databinding:

foreach (DataPoint d in Chart1.Series[0].Points)
        {
          d.Label = "somevalue";
        } 

Or you can set the values when you databind:

Chart1.Series[0].Points.DataBind(datasource, "xField", "yField", "Label={somevalue}");
Share:
12,504
FiveTools
Author by

FiveTools

Updated on June 04, 2022

Comments

  • FiveTools
    FiveTools almost 2 years

    alt text

    I would like to customize the labels on the datapoints below so they would render as (using first datapoint on the chart as an example) :

    4:10 - 4:40 yellow class