Profile Picture

Plotting Circle

Posted By Teddy Lambropoulos 14 Years Ago
Author
Message
Teddy Lambropoulos
Posted 14 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

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



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: Yesterday @ 8:46 AM
Posts: 3,054, Visits: 4,012

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



Syrhey Karol'
Posted 12 Years Ago
View Quick Profile
Forum Member

Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 21, Visits: 74
Hi Guys!

Is it possible to draw simple shape like circle or rectangle with kind of 'NPathSeries' for now?
By the way NPath class was created for that goal?

Or I shall use the approach like in the previous post?

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: Yesterday @ 8:46 AM
Posts: 3,054, Visits: 4,012
It is possible to draw custom graphics (with GDI+) in the chart canvas. Please refer to the following examples in our Windows forms demo application:

All Examples > Custom Painting > ...
All Examples > Coordinate Transformations > ...

Best Regards,
Nevron Support Team



Syrhey Karol'
Posted 12 Years Ago
View Quick Profile
Forum Member

Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 21, Visits: 74
Thank you! It works great!

Best regards,
Zonder




Similar Topics


Reading This Topic