Setting Custom Colors in DataSeries.Loaded Event
You can set different colors for the data point in the same series using the Loaded event like the following:
DataSeries ds = new DataSeries()
{
ValuesSource = new double[] {-2, -1, 1, 2, 2, 1, -1, -3 }
};
SolidColorBrush red = new SolidColorBrush(Colors.Red);
SolidColorBrush blue = new SolidColorBrush(Colors.Blue);
ds.Loaded += (s, e) =>
{
PlotElement pe = s as PlotElement;
if (pe != null &&
pe.DataPoint.PointIndex >= 0) // only points
{
// set color depending on point value
if (pe.DataPoint.Value >= 0)
pe.Fill = red;
else
pe.Fill = blue;
}
};
chart.Data.Children.Add(ds);
chart.ChartType = ChartType.LineSymbols;