Profile Picture

Coloring specific parts of NSmoothLine

Posted By Teddy Lambropoulos 13 Years Ago
Author
Message
Teddy Lambropoulos
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)Junior Member (20 reputation)

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

Hi all,

I have a question regarding coloring specific parts of a NSmoothLine series. Let say I have entered 100 values in this series. I want to from index 0 to index 25 to be black, from index 26 to 75 to be red, and index 76 to index 100 to be black again. I have used code like this to color the middle portion red:

for i as integer=26 to 75

     DirectSeries.BorderStyles(i) = New NStrokeStyle(Color.Red)

     DirectSeries.XValues.Add(xvals(i))

     DirectSeries.Values.Add(zvals(i) * 1000)

end

NChartControl1.refresh()

My issue with this code is it does not turn the specified section red. It appears as if there is still the black line and under it I can see the red. But I want the line to be only black, then only red, then only black.

I can explain my issue more if need be. Does anybody have any ideas?



Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi Teddy,

We tested the code and it appears to be working as expected. We also changed it a little bit so that it really adds 100 data points and still everything looks OK. Here is the full example (in C#):

private void Form1_Load(object sender, EventArgs e)
{
   Random rand = new Random();

   NLineSeries series = new NLineSeries();
   series.DataLabelStyle.Visible = false;

   NChart chart = nChartControl1.Charts[0];
   chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();
   chart.Series.Add(series);

   for (int i = 0; i < 100; i++)
   {
      series.XValues.Add(i);
      series.Values.Add(Math.Sin(i * 0.08) * 3000 + rand.NextDouble() * 1000);
   }

   for (int i = 26; i < 75; i++)
   {
      series.BorderStyles[i] = new NStrokeStyle(Color.Red);
   }
}

The attached image shows the output. Maybe there is some difference in the series settings? Is shadow drawing enabled for the series?


Best Regards,
Nevron Support Team



Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Here is the image:

Best Regards,
Nevron Support Team



Attachments
RedAndBlackLine.png (51 views, 16.00 KB)


Similar Topics


Reading This Topic