Profile Picture

Setting custom style for each point in the NPointSeries

Posted By Alex Efimov 14 Years Ago
Author
Message
Alex Efimov
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 5, Visits: 1
Hi, guys.
Is there a way to set a custom point size for each point in series?

Thanks in advance.

Nevron Support
Posted 14 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 Alex,

Currently the component does not support points with different size/shape inside a point series (partially because it is more computationally expensive to compute inflates in this case). You can easily overcome this by creating some helper methods that create points series with different settings - the following code snippet shows how to achieve this in the case of categorical and xy scatter point series:

  private void Form1_Load(object sender, EventArgs e)
  {
   NChart chart = nChartControl1.Charts[0];

   // sample data
   double[] pointYValues = new double[] { 10, 20, 30 };
   double[] pointXValues = new double[] { 10, 20, 30 };
   float[] pointSizes = new float[] { 10, 20, 30 };
   PointShape[] pointShapes = new PointShape[] { PointShape.Bar, PointShape.Cross, PointShape .Ellipse };

   // add categorical points
   AddCategoricalPoints(chart, pointYValues, pointSizes, pointShapes);

   // add xy scatter points
   AddXYScatterPoints(chart, pointXValues, pointYValues, pointSizes, pointShapes);
  }

  private void AddCategoricalPoints(NChart chart, double[] pointValues, float[] pointSizes, PointShape[] pointShapes)
  {
   int count = Math.Min(Math.Min(pointValues.Length, pointSizes.Length), pointShapes.Length);
   double[] pointXValues = new double[count];

   // simulate categorical points
   for (int i = 0; i < count; i++)
   {
    pointXValues[i] = i;
   }

   // fallback to scatter
   AddXYScatterPoints(chart, pointXValues, pointValues, pointSizes, pointShapes);
  }

  private void AddXYScatterPoints(NChart chart, double[] pointXValues, double[] pointYValues, float[] pointSizes, PointShape[] pointShapes)
  {
   int count = Math.Min(Math.Min(pointXValues.Length, pointYValues.Length), Math.Min(pointSizes.Length, pointShapes.Length));

   for (int i = 0; i < count; i++)
   {
    NPointSeries point = new NPointSeries();
    point.UseXValues = true;

    point.Values.Add(pointYValues[i]);
    point.XValues.Add(pointXValues[i]);

    point.Size = new NLength(pointSizes[i], NGraphicsUnit.Pixel);
    point.PointShape = pointShapes[i];

    chart.Series.Add(point);
   } 
  }

We will probably add this feature in the next major release of the component.

Hope this helps - let us know if you have any questions or comments...



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic