ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Radar chart with tick marks
Posted by Maurice van der Zwaan on Mar-22-2012 21:04
Attachments:
I would like to know if it's possible to have a radar chart with ticks marks on the axis instead of the circle/polygon gridlines.

See the attached sample which I need to render using ChartDirector. For now I got everything working except the tick marks
sample.png

  Re: Radar chart with tick marks
Posted by Peter Kwan on Mar-23-2012 02:16
Hi Maurice van der Zwaan,

For your particular case, you may consider to simply draw them using straight lines with DrawArea.line or BaseChart.addLine. The drawing itself should take less than 10 lines of code. For example (in C#/Java):


//Assume this is the parameter of your chart
cx = 225;
cy = 185;
radius = 150;
axisWidth = 3;
tickLength = 3;
color = 0x3333ff;
tickCount = 5;


int offset = (int)(radius * 0.707);   // = radius * cos(45)

//two main axis
d.line(cx - offset, cy - offset, cx + offset, cy + offset, color, axisWidth);
d.line(cx + offset, cy - offset, cx - offset, cy + offset, color, axisWidth);

//the ticks
for (int i = -tickCount; i <= tickCount; ++i) {
   int tickOffset = offset * i / tickCount;
   d.line(cx - tickOffset + tickLength, cy - tickOffset - tickLength, cx - tickOffset - tickLength, cy - tickOffset + tickLength, color, 1);
   d.line(cx + tickOffset - tickLength, cy - tickOffset - tickLength, cx + tickOffset + tickLength, cy - tickOffset + tickLength, color, 1);
}


Hope this can help.

Regards
Peter Kwan

  Re: Radar chart with tick marks
Posted by Maurice van der Zwaan on Mar-23-2012 04:55
It still needs some tweaking (datapoints are not aligned with the ticks right now) but you put me in the right direction !

  Re: Radar chart with tick marks
Posted by Maurice van der Zwaan on Mar-23-2012 05:14
It seems the calculation for the offset is not correct, or the radius of the radar chart is changed from what I entered on creation (auto-scaling issue?)

  Re: Radar chart with tick marks
Posted by Maurice van der Zwaan on Mar-23-2012 05:28
My mistake, I used Math.Cos but it needs Radians not degrees..

Thanks for your solution, it works perfectly