Interaction.Key update, automatic bar widths, scale domain controls
Pre-releaseGood evening,
Tonight's release features some updates to Interactions, additional controls for Scale domains, automatic bar width calculation on bar Plots, and a few other additions.
Features
Interaction.Key update
Interaction.Key now can listen for multiple keys. Use Interaction.Key.on(keycode, callback) to assign a new callback to be called when the key corresponding to keycode is pressed. An example:
var kI = new Plottable.Interaction.Key();
// keyCode for "a" is 65
kI.on(65, function() { plot.showAllData(); })
plot.registerInteraction(kI);Pixel information included in HoverData
HoverData now includes a list of pixel positions corresponding to hovered-over elements:
export interface HoverData {
data: any[];
pixelPositions: Point[];
selection: D3.Selection;
}Retrieving Baseline Value
The .baseline() method, invoked with no arguments, now returns the baseline value on a Bar Plot.
Disabling Console Warnings
Plottable occasionally uses console warnings to alert developers to issues, such as deprecated classes and layout errors. To suppress these errors, set the global value Plottable.Config.SHOW_WARNINGS to false.
IntegerTickGenerator
Plottable.TickGenerators.integerTickGenerator() will produce a formatter that only returns integers.
Automated domain controls
- By calling
automaticallyAdjustYScaleOverVisiblePoints(true)on a Plot, the Y scale's domain will automatically be adjusted to show only points visible on the X scale's domain. The adjustment is performed immediately after a call. It disablesscale.autoDomain. automaticallyAdjustXScaleOverVisiblePoints(true)instead adjusts the X scale in response to changes in the Y scale.showAllData()adjusts both domains' extents to show all datasets. This call does not override auto domain adjustment behavior over visible points.
Default Bar Widths
Previously, bars on a Bar Plot backed by a non-Ordinal scale (or a Scale.Ordinal in "points" mode) would have their width default to 10px. Now, the width will automatically default to the closest spacing between two data points.
Bugfixes
- Data values outside of
Scale.Ordinal's domain are not rendered.
API Breaks
Interaction.Key's constructor no longer takes in a key code.Interaction.Key.callback()has been removed in favor ofInteraction.Key.on(), which allows registration of callbacks to different keys.- The 'onlyShowUnchanged' parameter in various formatters has been removed in favor of using an IntegerTickGenerator on Quantitative Scales.
Typescript API Breaks
StackedBarPlotnow extendsAbstractBarPlotinstead ofStackedPlot.
Upgrade Instructions
- Update all uses of
Interaction.Keyas follows:
var kI = new Plottable.Interaction.Key(65).callback(<function>); // OLD VERSION
var kI = new Plottable.Interaction.Key().on(65, <callback>); // NEW VERSION- Formatters relying on the
onlyShowUnchangedparameter should be adjusted to use customTickGenerators on the associated scales. For example:
// we only have integer y-values
yAxis.formatter(Plottable.Formatters.fixed(0, true)); // OLD
yScale.tickGenerator(Plottable.TickGenerators.integerTickGenerator());StackedBarPlotis no longer aStackedPlot; Typescript references should be updated accordingly.