19970

Is there a way to draw a Point on a Polar Chart [closed]

Question:

I want to add a colored point (red or green) on every "crossing" between the rings and segment lines. Is there a simpler way than making 240 Series which just have two datapoints?

<a href="https://i.stack.imgur.com/exCS5.png" rel="nofollow"><img alt="The chart i want the points added to" class="b-lazy" data-src="https://i.stack.imgur.com/exCS5.png" data-original="https://i.stack.imgur.com/exCS5.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Answer1:

1 - There is no need to create different Series. Just add the DataPoints you want at the spots you want! This is the easiest way, since you already know the values.

2 - As an alternative you can use a xxxPaint event and draw filled circles (or whatever you fancy..). For this you need to convert the values to pixels. This can <strong>usually</strong> be achieved with the AxisX/AxisY.ValueToPixelPosition methods. <strong>However</strong> for Polar Charts this will not work. Instead you need to calculate the pixel coordinates yourself..

The 2nd way is a bit harder, but of course will give you more control over the style of the points you draw..

Here is the result of adding DataPoints:

<a href="https://i.stack.imgur.com/JMwRs.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/JMwRs.png" data-original="https://i.stack.imgur.com/JMwRs.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Example code for the 1st version; first we set up a polar chart with its axis properties:

Chart chart = chart2; chart.Series.Clear(); ChartArea ca = chart.ChartAreas[0]; Axis ax = ca.AxisX; Axis ay = ca.AxisY; ax.Minimum = 0; ax.Maximum = 360; ax.Interval = 15; // 15° interval ax.Crossing = 0; // start the segments at the top! ay.Minimum = 0; ay.Maximum = 10; ay.Interval = 1; Series s0 = chart.Series.Add("points"); s0.MarkerStyle = MarkerStyle.Circle; s0.SetCustomProperty("PolarDrawingStyle", "Marker"); s0.MarkerSize = 6; s0.MarkerColor = Color.Teal; s0.ChartType = SeriesChartType.Polar;

And then we add the points at the crossings and finally style one of them to show that they all can be different..:

for (double vx = ax.Minimum; vx < ax.Maximum; vx += ax.Interval) for (double vy = ay.Minimum; vy <= ay.Maximum; vy += ay.Interval) s0.Points.AddXY(vx, vy); s0.Points[333].MarkerColor = Color.Red; s0.Points[333].MarkerSize = 12; <hr />

For the code to calculate the pixel coordinates <a href="https://stackoverflow.com/questions/38453848/hittest-in-polar-chart-with-multiple-series/38458511?s=1|2.0256#38458511" rel="nofollow">see this post!</a>

Using the function in the link and this PrePaint event:

private void chart2_PrePaint(object sender, ChartPaintEventArgs e) { Chart chart = chart2; ChartArea ca = chart.ChartAreas[0]; Series s0 = chart.Series["points"]; foreach (DataPoint dp in s0.Points) { PointF pt = PolarValueToPixelPosition(dp, chart, ca); e.ChartGraphics.Graphics.DrawEllipse(Pens.OrangeRed, pt.X - 5, pt.Y - 5, 9, 9); } }

we can adorn each point with a circle:

<a href="https://i.stack.imgur.com/rz3oZ.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/rz3oZ.png" data-original="https://i.stack.imgur.com/rz3oZ.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Or course, if you don't want to add the DataPoints in the first place, you can replace them by calculating the values like I did in the loops that added them..

Recommend

  • Is it possible to create a bubble polar chart with Highcharts?
  • Mapping shapes from a flat equirectangular panorama to planes within A-Frame
  • how to do power of complex number in CUBLAS?
  • Java graph library [duplicate]
  • Pie-in-pie (Donut) charts
  • Cannot read property 'addEvent' of undefined
  • jquery pie chart with drilldown/clickable pie parts
  • How to edit css for jquery datepicker prev/next buttons?
  • Grid creating extra spacing that I don't want
  • C# 4 and CLR Compatibility
  • How to create a Unix-domain socket with specific access permissions
  • Android Studio Can't Find tools.jar
  • How to detect interior vertices in groups of 2d polygons? (E.g. ZIP Codes to determine a territory)
  • How do I include a SWC in an AS2 Flash project?
  • How to add a focus style to an editable ComboBox in WPF
  • How do I superscript characters in a UIButton?
  • How do I alternate colors in Flat List (React Native)
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Allowing both email and username for authentication
  • Get one-time binding to work for ng-if
  • Linq Objects Group By & Sum
  • Nant, Vault & Windows Integrated Authentication
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Optimizing database types to compact database (SQLite)
  • How reduce the height of an mschart by breaking up the y-axis
  • Bug in WPF DataGrid
  • Large data - storage and query
  • How do you troubleshoot character encoding problems?
  • jquery mobile loadPage not working
  • jQuery tmpl and DataLink beta
  • How can I estimate amount of memory left with calling System.gc()?
  • php design question - will a Helper help here?
  • Unanticipated behavior
  • Traverse Array and Display in markup
  • Buffer size for converting unsigned long to string
  • AngularJs get employee from factory
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Authorize attributes not working in MVC 4
  • Django query for large number of relationships
  • reshape alternating columns in less time and using less memory