Ordinal Scale Revamp, Origin Methods
Pre-release
Pre-release
Good afternoon,
This release features some major changes to Scale.Ordinal, as well as methods for querying the origin of Components.
Features
Scale.Ordinal revamp
Scale.Ordinalused to have two modes for how they map their domain onto the range: "points" and "bands". Not only did this create confusion, but somePlots would render inconsistently if theScalewas in the wrong mode.Scale.Ordinalnow has only one mode.- The
scale()method onScale.Ordinalnow scales to the center of the band, not the start:

innerPadding()andouterPadding()are now defined as proportion of the band width.innerPaddingis defined as the padding in between bands.outerPaddingis defined as the padding between the outer bands and the edge of the scale.fullBandStartAndWidth()has been removed in favor ofstepWidth().stepWidth()method returns the distance between successive values on the scale, in pixels.
Component Origin Methods
Two methods have been added to Components:
origin()gets the location of the Component's upper-left-corner relative to its parent.originToSVG()gets the location of the Component's upper-left corner relative to the root<svg>node.
Bugfixes
Barplots now account for the ends of theScalewhen automatically computing bar widths.Axislabels are now confined to theAxis's bounding-box within the<svg>(#1501)- End ticks are consistently visible on both ends of an
Axis.Time(#1509) - Tick labels now show up at regular intervals (#1196)
API Breaks
innerPadding()andscale()methods onScale.Ordinalnow behave very differently.fullBandStartAndWidthhas been renamed and revamped intostepWidth()
Upgrade Instructions
- The
innerPadding()method onScale.Ordinalused to return the padding in pixels; now it returns the padding as a proportion of the band width.ordinalScale.bandWidth() * ordinalScale.innerPadding()will calculate the padding in pixels. - Since
scale()now returns the position corresponding to the middle of the band,ordinalScale.scale(value) - ordinalScale.rangeBand() / 2will yield the position at the start of the band. fullBandStartAndWidth()can be replaced by the above calculation andstepWidth().
Future Changes
- As we have upgraded our library to use Typescript 1.4, we are moving in the near future to actually use some of its features like union typing. Our library as of the current moment should still be compatible with Typescript 1.3, but we will not be compatible with it in the near future.