Plotting Circle


Author
Message
Teddy Lambropoulos
Teddy Lambropoulos
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
Posts: 20, Visits: 1

Is there an easy way to plot a circle? I have tried using an NSmoothLineSeries for this, but the size of the data point markers makes the plot look "choppy." Is there an easier way to do this? Perhaps predefined shapes?

 

Best regards,

 

Teddy


Reply
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Teddy,

You can use the GraphicsPath flatten method in a combination with a scatter line series to get a "circle"- for example:

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

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

  using (GraphicsPath path = new GraphicsPath())
  {
    path.AddEllipse(new Rectangle(-10, -10, 20, 20));
    FillFromPath(line, path);
  }

  chart.Series.Add(line);
  chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();

  nChartControl1.Refresh();
}

private void FillFromPath(NLineSeries line, GraphicsPath path)
{
  path.Flatten(null, 0.01f);
  PointF[] points = path.PathPoints;

  line.UseXValues = true;
  int count = points.Length;

  for (int i = 0; i < count; i++)
  {
    PointF point = points[i];
    line.Values.Add(point.X);
    line.XValues.Add(point.Y);
  }
}

We'll have a new series called path series in Vol2 (early autumn) that will allow you to draw graphics path directly in the control. Note that you may not actually get a circle if the plot proportions are not exactly 1:1.

Questions or comments - please feel free...



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search