I want to create a polar diagram in C# (no libary) that has a fixed amout of rings and segments. Is it also possible to change the digrees on the side so the 0 is on the right? If it is not possible in C# is there a libary for it?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
This is not hard at all using the
MSChart
control.You can use its
Polar ChartType
and set the various properties of the twoAxes
to achieve what you want:Here is an example; add a
Chart chart1
to you Form and set it up like this:To let the spokes go from 0° to 360° in steps of 15° with a rotation of 90° set these axes values:
Controlling the rings is trickier, as it eventually must take your data values into account! Assuming y-values going from 0-100 we can use these settings to get 10 rings:
If your data values have a different range you should adapt these values!
So the number of spokes is
(Maximum - Minimum) / Interval
for theX-Axis
. And the number of rings is the same but for theY-Axis
. To control both is is best to set them all and not rely on the default automatic setting!If you want an empty center you should
As an alternative you could add a dummy Datapoint to the center and style it:
To find the right size for
centerwidth
you would have to either test or, if you want scaling to work, do a measurement in axxxPaint
event; this goes beyond the scope of this answer..This is fairly easy to implement with GDI in winforms. Create a new UserControl, override the OnPaint functionality to:
---------------- EDIT ------------------ Create a new UserControl: right click project -> add -> User Control