How do you resolve the issue of arc angles that do not calculate to an integer.
The arc angle of a graphic does not accept anything but integers as can be seen from the image.
You can overcome it by using round but that seems to affect the last segment, particularly when it is only a small value.
Any ideas please.
Constructing a PieChart
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Constructing a PieChart
Hi.
It does seem from the docs that only integer values of arcAngle are valid. Normally, this is accurate enough, since human beings cannot discern a half degree difference. It looks like you have several radii that have gaps between their neighbors.
In your case, you would want to do one of two things.
1- Manage the arcAngles so that adjacent slices have common radii, that is, all slices use integral arcAngles, but these always overlie their neighbors. This will mean that the widths of some of the slices will need to be adjusted slightly; they will not be perfectly accurate if derived from a count of 360, but should be fine visually, and this is likely the most important thing.
2- Roll your own radii, by drawing line graphics from a common center towards point on a large virtual circle. This will allow finer control of the angle of the line, but you will still have to manage them as before, so they overlie each other. I do not think this should be necessary, though, unless you have lots and lots of very small slices, which will probably not be visually distinguishable in the first place, since one degree is pretty thin.
Craig Newman
It does seem from the docs that only integer values of arcAngle are valid. Normally, this is accurate enough, since human beings cannot discern a half degree difference. It looks like you have several radii that have gaps between their neighbors.
In your case, you would want to do one of two things.
1- Manage the arcAngles so that adjacent slices have common radii, that is, all slices use integral arcAngles, but these always overlie their neighbors. This will mean that the widths of some of the slices will need to be adjusted slightly; they will not be perfectly accurate if derived from a count of 360, but should be fine visually, and this is likely the most important thing.
2- Roll your own radii, by drawing line graphics from a common center towards point on a large virtual circle. This will allow finer control of the angle of the line, but you will still have to manage them as before, so they overlie each other. I do not think this should be necessary, though, unless you have lots and lots of very small slices, which will probably not be visually distinguishable in the first place, since one degree is pretty thin.
Craig Newman
Re: Constructing a PieChart
I have for the moment settled on
Then for the next segment
When I get to the last segment I do:
So far it seems OK but I will keep testing.
Thanks for your comments.
Code: Select all
put round(tValue/tTotalValue * 360) into tArcAngle
Code: Select all
add tArcAngle to tStartAngle
Code: Select all
if n = tNumOfSegs then
if tStartAngle + tArcAngle < 360 then
put 360 - tStartAngle into tArcAngle
end if
end if
Thanks for your comments.
Re: Constructing a PieChart
Hi.
I think I see what you are up to, and it seems like you have the "overlying" of the radii in hand. And closing the last gap back to the start radius as well.
Isn't liveCode great?
Craig
I think I see what you are up to, and it seems like you have the "overlying" of the radii in hand. And closing the last gap back to the start radius as well.
Isn't liveCode great?
Craig