Nevron Forum

NMarkerstyles question

https://www.nevron.com/Forum/Topic2444.aspx

By Henning Olsson - Wednesday, June 24, 2009

I'm trying to change the color of the lines and points (markers) in a 2D line chart depending on a third variable.

X value = variable 1
Y value = variable 2
Color value = variable 3

I managed to do it for the lines using:
line(g).BorderStyles(i - 1) = New NStrokeStyle(2, Color.FromArgb(RGB(0), RGB(1), RGB(2)))

But I can't get the equivalent to work for MarkerStyles.

I tried this, but it doesn't work:
line(g).MarkerStyles(i - 1) = New NColorFillStyle(Color.FromArgb(RGB(0), RGB(1), RGB(2)))

All help will be greatly appreciated!

By Blagovest Milanov 1 - Thursday, June 25, 2009

Hi Henning,

You have to assign instances of the NMarkerStyle object - the following code shows how to do it individually per data point using the default series marker:

NChart chart = nChartControl1.Charts[0];

chart.BoundsMode = BoundsMode.Stretch;

 

// add some sample data

NLineSeries line = new NLineSeries();

Random rand = new Random();

line.DataLabelStyle.Visible = false;

 

for (int i = 0; i < 10; i++)

{

    line.Values.Add(rand.Next(100));

    NMarkerStyle markerStyle = (NMarkerStyle)line.MarkerStyle.Clone();

    markerStyle.FillStyle = new NColorFillStyle(Color.Red);

    markerStyle.Visible = true;

    line.MarkerStyles[i] = markerStyle;

}

 

chart.Series.Add(line);

nChartControl1.Refresh();

Hope this helps - let me know if you meet any problems.

Best regards,
Bob