-
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
Rotate the kiviat polygon and fix the bottom label position #79
Conversation
Oh, more than a month passed already. I checked at the diff online in the web and it's strangely large. It shows me like if all classes were removed and added. Maybe a newline separator changed? we should check in Iceberg and try it. @Nyan11 Do you have some script snippet to test what changes? |
I use a Windows computer. Maybe a problem with CRLF ?
The bugs are explained in #78 . Here is an example: kiviat := RSKiviat new.
kiviat addRow: #(3 5 1 2).
kiviat axisNames: #('axis1' 'axis2' 'axis3' 'axis4').
kiviat usePolygon.
kiviat open
|
Well, I don't see the button for Approving the PR. |
Actually, the label do not allign with the current PR for kiviat of size 6, 12, 18 and 24 (but does for 30). 4 to: 20 by: 2 do: [ :kiviatSize | | kiviat axis values |
axis := OrderedCollection new.
values := OrderedCollection new.
1 to: kiviatSize do: [ :number |
axis add: 'axis', number printString.
values add: (Random new nextBetween: 1 and: 5)
].
kiviat := RSKiviat new.
kiviat addRow: values.
kiviat axisNames: axis.
kiviat usePolygon.
kiviat open.
]. |
Seem to be fix. 3 to: 36 by: 1 do: [ :kiviatSize | | kiviat axis values |
axis := OrderedCollection new.
values := OrderedCollection new.
1 to: kiviatSize do: [ :number |
axis add: 'axis', number printString.
values add: (Random new nextBetween: 1 and: 5)
].
kiviat := RSKiviat new.
kiviat addRow: values.
kiviat axisNames: axis.
kiviat usePolygon.
kiviat open.
]. |
the modification is here ( fixLabelPosition: label angle: angle
| positions gap roundedUpTo |
roundedUpTo := 0.0001.
label position: angle cos @ angle sin * radius.
gap := self labelGapSize.
positions := Dictionary newFromPairs: {
(0 roundUpTo: roundedUpTo).
(0.5 @ 0).
(Float halfPi roundUpTo: roundedUpTo).
(0 @ 0.5).
(Float halfPi negated roundUpTo: roundedUpTo).
(0 @ -0.5).
(Float pi roundUpTo: roundedUpTo).
(-0.5 @ 0).
(Float pi + Float halfPi roundUpTo: roundedUpTo).
(0 @ 0.5) }.
positions
at: (angle roundUpTo: roundedUpTo)
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 ] EDIT: The "angle" is given by the method ``RSKiviat >> #renderAxisIn:`, and it is calculated with a floating point division followed by an addition. In the case of a kiviat with 6 branches:
|
Great. I didn't noticed first which misalignment you were talking about. But then I did and I appreciate your fix. BTW, in the second commit there isn't the same normality in the web diff. Did you change Pharo version or computer? |
I did both on the same computer. First commit:Pharo 12.0.0 Second commit:Pharo 12.0.0 |
So, I consider this is ready to be merged. |
Fix: #78