-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSKiviat usePolygon does not work with even axis #78
Comments
A simple fix could be done in the method createPolygonFor: each
"create the background polygon shape if the variable #shouldUseEllipse equals False.
The polygon must be created with a rotation if the number of axis is even."
| rotation |
rotation := 0.
axisNames size even ifTrue: [ rotation := Float pi / axisNames size ].
^ RSPolygon new
noPaint;
points:
(RSPolygon
generateUnitNgonPoints: axisNames size
rotation: rotation) * each;
border: self border;
yourself with 4 axiswith 8 axis |
In the above fix, the label on the bottom is not aligned properly. ('axis3' for the kiviat with 4 axis) ('amet,' for the kiviat with 8 axis) |
In order to fix the label issue. fixLabelPosition: label angle: angle
| positions gap |
label position: angle cos @ angle sin * radius.
gap := self labelGapSize.
positions := Dictionary newFromPairs: {
0.
(0.5 @ 0).
Float halfPi.
(0 @ 0.5).
Float halfPi negated.
(0 @ -0.5).
Float pi.
(-0.5 @ 0).
(Float pi + Float halfPi).
(0 @ 0.5) }.
positions
at: angle
ifPresent: [ :fix |
label translateBy: label extent * fix + (gap * fix sign) ]
ifAbsent: [
gap := angle cos @ angle sin * gap.
(angle between: Float halfPi negated and: 0) ifTrue: [
^ label translateBy: label baseRectangle bottomLeft negated + gap ].
(angle between: 0 and: Float halfPi) ifTrue: [
^ label translateBy: label baseRectangle topLeft negated + gap ].
(angle between: Float halfPi and: Float pi) ifTrue: [
^ label translateBy: label baseRectangle topRight negated + gap ].
label translateBy: label baseRectangle bottomRight negated + gap ] |
I added a default value is the position dictionary for PI/2 (label is in the bottom). Float halfPi -> (0 @ 0.5). When the angle of the axis is half pi, the gap should be 0 horizontal and +0.5 vertical |
Hello,
I want a kiviat with a polygon background with 4 axis.
But the polygon is not correctly align.
reproduction
with the bug
without the bug
expected behavior
The square background on figure1 should be turned 45° on the right so the axis match the polygon corners.
The text was updated successfully, but these errors were encountered: