Skip to content

Improvements to getClosestPlotData()

Pre-release
Pre-release
Compare
Choose a tag to compare
@jtlan jtlan released this 17 Apr 22:53
· 4293 commits to master since this release

Good afternoon,

This release features more nuanced default behavior for getClosestPlotData().

Features

Improvements to getClosestPlotData()

We've simplified the API. It now accepts a query point only:

getClosestPlotData(queryPoint: Point): PlotData;

and the notion of "closest" differs by plot type:

  • Scatter, Pie, and Grid Plots retain the Euclidean norm
  • Line and Area Plots implement an x-then-y strategy; points are first compared by x-value and, if multiple points have the same x-value, their y-value is used as a tiebreaker
  • Bar Plots implement a similar x-then-y strategy, with the addition that bars containing the query point are always returned. For horizontal Bar Plots, the strategy is y-then-x.

This makes it easy to show plot data tooltips in a user-friendly way.
Try it out here: http://jsfiddle.net/38ehL9p6/1/

Bugfixes

  • Plottable stops reading colors from CSS when a maximum of 256 colors is reached (#1834)

Typescript-only API-Breaking Changes

  • getClosestPlotData() no longer accepts the two (optional) parameters withinValue and datasetKeys.