Profile Picture

SamplingMode and Line label

Posted By John Palmer 12 Years Ago
Author
Message
Nevron Support
Posted 12 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 John,

The easiest way to achieve is to have a second point scatter series for the data labels - for example:

   NChart chart = nChartControl1.Charts[0];

   NLineSeries line = new NLineSeries();
   line.SamplingMode = SeriesSamplingMode.Enabled;
   line.UseXValues = true;

   NPointSeries point = new NPointSeries();
   point.UseXValues = true;
   point.Size = new NLength(0);

   Random rand = new Random();

   for (int i = 0; i < 10000; i++)
   {
    double x = i;
    double y = Math.Sin(i / 1000.0);

    line.XValues.Add(x);
    line.Values.Add(y);

    if (i % 1000 == 0)
    {
     point.XValues.Add(x);
     point.Values.Add(y);
    }
   }

   chart.Series.Add(line);
   chart.Series.Add(point);

Creates a chart with two series - line series and a point series with zero size used only to show data labels. Hope this helps - let us know if you meet any problems or have any questions.



Best Regards,
Nevron Support Team



John Palmer
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 2, Visits: 2
I use the following code to create and display a line with some text at the line's midpoint. With SamplingMode enabled, the label does not appear. With SamplingMode disabled, it does. I would like to get some of the performance gains out of using SamplingMode, but is there a way to do it such that the label will show up?

private void DisplaySpectrum(SpectrumViewModel s)
{
var line = (NLineSeries)nccSpectra.Charts[0].Series.Add(SeriesType.Line);

line.Tag = s;
line.Name = s.Name;
line.UseXValues = true;
//line.SamplingMode = SeriesSamplingMode.Enabled;

line.DataLabelStyle.Visible = true;
line.DataLabelStyle.Format = "



Similar Topics


Reading This Topic