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

Message ListMessage List     Post MessagePost Message

  PolarChart troubles
Posted by Steve Valliere on Jul-22-2011 22:33
First, I have abandoned my fervent wish to be able to use the same "angles" for anything instead of ChartDirector's "pseudo-angles" (i.e. "angle" is often an arbitrary value based on the number of labels present, which can be EXTREMELY confusing both initially and when the code must be maintained).  I'm assuming that problem is here to stay.

My only current problem is that it seems impossible to have fewer spoke lines in the polar grid than I have labels.  If I call the lines below with 24 labels and a spoke angle of 15.0 in this order

      c->angularAxis()->setLabels( StringArray(szLabels,cLabels) );
      c->angularAxis()->setLinearScale(0, 360, rdSpokeAngle);

I get spokes where I want, but the labels have been replaced with their degree offsets.  If, on the other hand, I use the same parameters but reverse the calling sequence:

      c->angularAxis()->setLinearScale(0, 360, rdSpokeAngle);
      c->angularAxis()->setLabels( StringArray(szLabels,cLabels) );

then I get the correct labels, but I also get a spoke every 15.0 degrees.  Is there any way to get this to work that isn't a large, complex work-around?  If not, then I guess I'll just make the grid less visible because too much grid tends to obscure data.

  Re: PolarChart troubles
Posted by Peter Kwan on Jul-23-2011 02:24
Hi Steve,

Sorry for the lack of documentation regarding this matter. If the first character of a label is "-", then it will not have any grid line. (This is mentioned in the documentation for Axis.setLabels, but we forget to mention it in AngularAxis.setLabels.)

For example, if you labels are "a", "-b", "c", "-d", "e", "-f", then only the labels "a", "c", "e" will have grid lines. The labels "b", "d" and "f" will have no grid lines.

Hope this can help.

Regards
Peter Kwan

  Re: PolarChart troubles
Posted by Steve Valliere on Jul-23-2011 03:14
I think that will solve the visual issue, but the strange (to me) way that I must compute the "angles" for the data forces me to ask if I will need to use the total number of LABELS or SPOKES for calculating the "angles."

Also, while experimenting with c->angularAxis()->setLinearScale() and c->angularAxis()->setLabels(), I discovered that I cannot get this line to work:

   c->angularAxis()->setLinearScale(0, 360, StringArray(szLabels,cLabels));

I thought I'd use it instead of the other two, since it seems to combine everything that is happening into a single call.  However, I always end up with 12 spokes (30 degrees apart), labelled 0, 30, 60, 90, etc.  If I instead do this:

   c->angularAxis()->setLinearScale(0, 360, rdSpokeAngle );
   c->angularAxis()->setLabels( StringArray(szLabels,cLabels) );

I get the labels I assigned (though as I said earlier, the rdSpokeAngle value I tried to set is still ignored.)

  Re: PolarChart troubles
Posted by Peter Kwan on Jul-24-2011 13:49
Hi Steve,

You may consider:

c->angularAxis()->setLabels( StringArray(szLabels,cLabels) );

to be equivalent to:

c->angularAxis()->setLinearScale(0, cLabels, StringArray(szLabels,cLabels));

That's why you cannot use both AngularAxis.setLabels and AngularAxis.setLinearScale. These two APIs both set the angular axis scale and labels. But an angular axis can only have 1 scale. If you call both APIs, the last one will be used.

The advantage of setLabels is that you do not need to provide the angles at all when adding the data series. They will be implied to be the array index (0, 1, 2, 3, ...). If you look at the sample code that uses setLabels (eg. the "Multi Radar Chart", "Polar Area Chart"), no angular coordinates are used. The code is usually simplier. However, it requires that the points must be evenly spaced on the angular scale and always flows in the same angular direction (that is, either clockwise or anti-clockwise).

Angular coordinates are most useful if your data points are at arbitrary angles (not necessarily evenly spaced) and can flow at arbitrary directions. If you want to use angular coordinates and specify the labels, you may use:

   c->angularAxis()->setLinearScale(0, 360, StringArray(szLabels,cLabels));

There is an example "Polar Scatter Chart" that demonstrates the above API. You may try it to see if it works as expected.

If you think the above API is not working, is it possible to provide a short sample code (using some hard coded data) to illustrate the issue, so I may try to reproduce the problem?

Regards
Peter Kwan

  Re: PolarChart troubles
Posted by Steve Valliere on Jul-25-2011 22:36
Peter Kwan wrote:
That's why you cannot use both AngularAxis.setLabels and AngularAxis.setLinearScale. These two APIs both set the angular axis scale and labels. But an angular axis can only have 1 scale. If you call both APIs, the last one will be used.

Thanks, that explains what I was seeing quite clearly.

Angular coordinates are most useful if your data points are at arbitrary angles (not necessarily evenly spaced) and can flow at arbitrary directions. If you want to use angular coordinates and specify the labels, you may use:

   c->angularAxis()->setLinearScale(0, 360, StringArray(szLabels,cLabels));

Thanks again.  That's what I thought would happen, but I honestly didn't get any sense of that from the documentation page that I found (PolarChart Related -- angularAxis -- setLinearScale2)

If you think the above API is not working, is it possible to provide a short sample code (using some hard coded data) to illustrate the issue, so I may try to reproduce the problem?

I have ensured that all other calls to the angularAxis() object have been commented out, except for the line you provided above and it is now working.  Apparently, I was still calling either c->angularAxis()->setLinearScale() or c->angularAxis()->setLabels() and that made c->angularAxis()->setLinearScale(0, 360, StringArray(szLabels,cLabels)); misbehave.  Sorry for my mistake.

And thanks again!  Your help is the best!