Profile Picture

How to set different colors for the points in one series

Posted By Xiaolong Zhu 13 Years Ago

How to set different colors for the points in one series

Author
Message
Xiaolong Zhu
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 18, Visits: 1
 

Hi experts,

I want to create a chart with several point series. To show each series in the legend, i specified different fill styles for the series. Additionally, in each point series, i want to draw the points with different colors. So i also set various colors to the different points. But the result is the points take the series color not the point color. i copied my code here, is there anyone could give any hints? thanks in advance.

//create NPointSeries

public NPointSeries AddPointSeries(IEnumerable<Point> pts, Color seriesColor, string name)

{

NPointSeries series = (NPointSeries)_chart.Series.Add(SeriesType.Point);

series.UseXValues = true;

series.DataLabelStyle.Visible = false;

series.PointShape = PointShape.Ellipse;

series.Name = name;

series.FillStyle = new NColorFillStyle(seriesColor);

foreach(Point pt in pts)

{

NDataPoint dataPoint = new NDataPoint(pt.X, pt.Y);

series.AddDataPoint(dataPoint);

}

UpdatePointSeriesAppearence(series);

return series;

}

// set different colors to each point

private void UpdatePointSeriesAppearence(NPointSeries series)

{

for (int iPt = 0; iPt < series.GetDataPointCount(); iPt++)

{

NDataPoint dataPoint = series.ComposeDataPoint(iPt);

Color color = GetPtColor(iPt);

if (settings.SymbolType == SymbolStyle.None)

{

dataPoint[DataPointValue.StrokeStyle] = new NStrokeStyle(1, color);

dataPoint[DataPointValue.FillStyle] = new NColorFillStyle(Color.Transparent);

}

else

{

dataPoint[DataPointValue.StrokeStyle] = new NStrokeStyle(1, color);

dataPoint[DataPointValue.FillStyle] = new NColorFillStyle(color);

}

}

}

 





Similar Topics


Reading This Topic