P
Philippe Julien
Hi,
The attached labels.htm script shows how to draw custom labels outside
slices on a piechart.
As usual, the chartspace classid at the end of the script should correspond
to the OWC version
a.. OWC10 : CLSID:0002E556-0000-0000-C000-000000000046
b.. OWC11 : CLSID:0002E55D-0000-0000-C000-000000000046
It is quite challenging to draw outside labels, because :
a.. chDataLabels.Position = c.chLabelPositionOutsideBase is not supported in OWC
b.. Piecharts plot on the chart's plotarea directly, so getting to the pie radius or center is not easy.
Points coordinates (.Top, .Bottom, .Left and .Right) give the slice outer rectangle, so the center of the rectangle is not the center of the inscribed slice.
c.. Points coordinates are only available at rendering time.
Plotarea origin is top left corner, so X goes from left to right, Y goes from top to bottom.
d.. Slice explosion is not linear (unlike in Excel charts). Many thanks to Martin Farrelle who backsolved the explosion formula from the various
mesures I took on my display with a plastic rule (!)
To get to the pie radius and center, let's assume first that there is no explosion.
The outer square of a pie chart is the superimposition of all slices outer rectangles.
From the pie square coordinates, one can then get the center and radius.
However, when a slice is exploded, the outer rectangle is shifted along the slice median spike by a percentage of the radius which according to OWC's
documentation is Explosion / 100. Actually the percentage of the radius is Explosion / (100 + Explosion).
To retrieve the shift dx and dy projections, one needs the slice median spike angle (easy to get at SetData time) and the radius.
Assuming there is no FirstSliceAngle, pie radius can be retrieved from the first slice:
a.. .Bottom - .Top if the slice is smaller than a quarter
b.. .Right - .Left if it larger than a quarter but smaller than a half
c.. (.Bottom - .Top) / 2 otherwise
Actual implementation is then a piece of cake
About OWC Explosion, it sounds more like a bug than a feature, as at rendering time OWC assumes that explosion is linear. For instance, if you specify a 1000 explosion, the slice is shifted by 91% of the radius, but the pie itself is shown as a very small circle (approx 1/20 of the screen height), as if OWC was to show the exploded slice away by 10 times the radius (as it would in Excel).
kind regards,
- Philippe
The attached labels.htm script shows how to draw custom labels outside
slices on a piechart.
As usual, the chartspace classid at the end of the script should correspond
to the OWC version
a.. OWC10 : CLSID:0002E556-0000-0000-C000-000000000046
b.. OWC11 : CLSID:0002E55D-0000-0000-C000-000000000046
It is quite challenging to draw outside labels, because :
a.. chDataLabels.Position = c.chLabelPositionOutsideBase is not supported in OWC
b.. Piecharts plot on the chart's plotarea directly, so getting to the pie radius or center is not easy.
Points coordinates (.Top, .Bottom, .Left and .Right) give the slice outer rectangle, so the center of the rectangle is not the center of the inscribed slice.
c.. Points coordinates are only available at rendering time.
Plotarea origin is top left corner, so X goes from left to right, Y goes from top to bottom.
d.. Slice explosion is not linear (unlike in Excel charts). Many thanks to Martin Farrelle who backsolved the explosion formula from the various
mesures I took on my display with a plastic rule (!)
To get to the pie radius and center, let's assume first that there is no explosion.
The outer square of a pie chart is the superimposition of all slices outer rectangles.
From the pie square coordinates, one can then get the center and radius.
However, when a slice is exploded, the outer rectangle is shifted along the slice median spike by a percentage of the radius which according to OWC's
documentation is Explosion / 100. Actually the percentage of the radius is Explosion / (100 + Explosion).
To retrieve the shift dx and dy projections, one needs the slice median spike angle (easy to get at SetData time) and the radius.
Assuming there is no FirstSliceAngle, pie radius can be retrieved from the first slice:
a.. .Bottom - .Top if the slice is smaller than a quarter
b.. .Right - .Left if it larger than a quarter but smaller than a half
c.. (.Bottom - .Top) / 2 otherwise
Actual implementation is then a piece of cake
About OWC Explosion, it sounds more like a bug than a feature, as at rendering time OWC assumes that explosion is linear. For instance, if you specify a 1000 explosion, the slice is shifted by 91% of the radius, but the pie itself is shown as a very small circle (approx 1/20 of the screen height), as if OWC was to show the exploded slice away by 10 times the radius (as it would in Excel).
kind regards,
- Philippe