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

Message ListMessage List     Post MessagePost Message

  PolarLineLayer and setAngles
Posted by Mark Chidwick on Jan-16-2021 05:31
I would like to create a polar chart with 5 axes.  I set up the chart as

PolarChart c = new PolarChart(xs, ys, ChartPanel.chartBackground, 0x000000, 1);

and then the axis as


where labels is an array of String[5].

I then set up the plot area
c.setPlotArea(xo, yo, r, 0xffffff);

and then the angles to match the axes
double[] angles = new double[axis.size()];
for (int i = 0; i < angles.length; i++) {
angles[i] = i * 360.0 / angles.length;

Finally, I add the line layer
PolarLineLayer l = c.addLineLayer(data, color, "name of line");
l.setDataSymbol(Chart.CircleSymbol, 6);

In this case, I have angles
(0, 72, 144, 216, 288)

and data
(0, 10, 20, 30, 40)

What is plotted is
(0, 0) connected to (144, 10) connected to (288, 20) then (72, 30) then (216, 40)

It seems that it is connecting every other angle to the data.

Any thoughts???

  Re: PolarLineLayer and setAngles
Posted by Peter Kwan on Jan-16-2021 15:04
Hi Mark,

The "l.setAngles(angles);" and the "angles" variable are not necessary. Removing them should solve the problem.

The line:


means the angularAxis will have 5 labels, and their angular coordinates are their array index 0, 1, 2, 3, 4, which distributed evenly along the circle. The angularAxis does not automatically use degrees as the unit. If you want the angular coordinates to be from 0 to 360, you would need to use c.angularAxis().setLinearScale2(0, 360, labels);.

Also, for the PolarLayer, if you do not provide the angular coordinates, it will be the array index of the data (0, 1, 2, 3, 4, 5) as the coordinates. That means the labels and data will automatically match.

The above behaviour is the same for XYCharts too. If no x-coordinates are provided, the array index is the x-coordinate, so multiple arrays will automatically match each others.

Hope this can help.

Peter Kwan

  Re: PolarLineLayer and setAngles
Posted by Mark Chidwick on Jan-17-2021 02:33

Thanks for such a quick response!!  Works like a charm.  Removing the setAngles() was the trick.

Many thanks!