Skip to content

Ordinal Scale Revamp, Origin Methods

Pre-release
Pre-release
Compare
Choose a tag to compare
@jtlan jtlan released this 06 Feb 23:08
· 4907 commits to master since this 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.Ordinal used to have two modes for how they map their domain onto the range: "points" and "bands". Not only did this create confusion, but some Plots would render inconsistently if the Scale was in the wrong mode. Scale.Ordinal now has only one mode.
  • The scale() method on Scale.Ordinal now scales to the center of the band, not the start:
    scalechange
  • innerPadding() and outerPadding() are now defined as proportion of the band width.
    • innerPadding is defined as the padding in between bands.
    • outerPadding is defined as the padding between the outer bands and the edge of the scale.
    • fullBandStartAndWidth() has been removed in favor of stepWidth(). 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

  • Bar plots now account for the ends of the Scale when automatically computing bar widths.
  • Axis labels are now confined to the Axis'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() and scale() methods on Scale.Ordinal now behave very differently.
  • fullBandStartAndWidth has been renamed and revamped into stepWidth()

Upgrade Instructions

  • The innerPadding() method on Scale.Ordinal used 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() / 2 will yield the position at the start of the band.
  • fullBandStartAndWidth() can be replaced by the above calculation and stepWidth().

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.