File tree Expand file tree Collapse file tree
NumericInterpolator-Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ NSOrdinalScaleTest >> testOrdinalScaleRangeBands [
3333 rangeBands: #(0 960) .
3434 self
3535 assert: ordinal rangeBand equals: 160 ;
36- assert: (ordinal scale: ' a' ) equals: 0 ;
37- assert: (ordinal scale: ' d' ) equals: 480 ;
38- assert: (ordinal scale: ' f' ) equals: 800 ;
36+ assert: (ordinal scale: ' a' ) equals: 80. 0 ;
37+ assert: (ordinal scale: ' d' ) equals: 560.0 ;
38+ assert: (ordinal scale: ' f' ) equals: 880.0 ;
3939
4040 assert: ordinal rangeExtent equals: #(0 960)
4141
Original file line number Diff line number Diff line change @@ -23,9 +23,9 @@ NSOrdinalScale >> domain: arr [
2323 domain := OrderedCollection new .
2424 dictionary := Dictionary new .
2525 arr do: [ :xi |
26- ( dictionary includesKey : xi) ifFalse : [
26+ dictionary at : xi ifAbsentPut : [
2727 domain add: xi.
28- dictionary at: xi put: domain size ] ].
28+ domain size ] ].
2929 self perform: ranger withArguments: argument
3030]
3131
@@ -83,6 +83,7 @@ NSOrdinalScale >> rangeBands: x padding: padding outerPadding: outerPadding [
8383 and : step.
8484 reverse ifTrue: [ range := range reverse ].
8585 rangeBand := step * (1 - padding).
86+ range doWithIndex: [ :val :in | range at: in put: val + (rangeBand / 2.0 ) ].
8687 ranger := #rangeBands:padding:outerPadding: .
8788 argument := Array with: x with: padding with: outerPadding
8889]
@@ -181,7 +182,7 @@ NSOrdinalScale >> scale: x [
181182 domain add: x.
182183 dictionary at: x put: (index := domain size).
183184 ].
184- index ifNil: [ self error: ' invalid input ' ].
185+ index ifNil: [ ^ NSScale linear domain: domain; range: range; scale: x ].
185186 index := index % range size.
186187 index isZero
187188 ifTrue: [ index := range size ].
You can’t perform that action at this time.
0 commit comments