1.0.0 Release Candidate 1
Pre-releaseOverview
Why 1.0.0?
There are a number of known issues in the Plottable API that require breaking backwards compatibility to fix. That means there are a number of backwards-incompatible changes in this release. We are working hard to remedy these problems, and get the API in a state that will allow us to maintain backwards compatibility for all releases after v1.0.0.
To provide the best experience to our users, we are rolling out incremental release candidate releases to allow for pre-integration testing. These release candidates are not meant for production, but are meant as testing resources.
Theme of the 1.0.0-rc series
Because of the breaking changes between v0.54.0 and v1.0.0, our goal is that these release candidates will help make the upgrade as smooth as possible for you all, by allowing you to test early, and often.
Please test with these release candidates and make sure you're able to migrate to the new feature set without losing functionality. If you encounter any issues, please file issues here.
A description of the major changes is below. Full instructions on migrating from v0.54.0 to v1.0.0 will be kept updated in our Upgrading to 1.0.0 Guide
Major changes
Replacing project()
project()
previously performed a lot of magic in the background. For example, calling
plot.project("fill", function(d) { return "red"; });
would set the "fill"
attribute in the DOM to "red"
, but calling
plot.project("x", ...);
set a variety of DOM attributes depending on what kind of Plot
was used.
Furthermore, if the second argument to project()
was a string
, it would automatically be used as a key into the data (unless the string began with "#"...), meaning that .project("fill", "red")
didn't do what might be expected.
We have decided to remedy this by splitting the functionality of project()
into different functions.
Using attr()
to set attributes
attr()
previously existed as an alias for project()
. Now, it directly sets DOM attributes to the results of an Accessor
and a Scale
:
attr(attr: string, attrValue: number | string | Accessor<number> | Accessor<string>): Plot;
attr<A>(attr: string, attrValue: A | Accessor<A>, scale: Scale<A, number | string>): Plot;
Example invocations:
plot.attr("stroke-width", 2);
plot.attr("fill", "pink");
plot.attr("fill", function(d) { return d.value >= 0 ? "green" : "red"; });
plot.attr("stroke", function(d) { return d.type; }, colorScale);
The Scale
must be passed as the third argument for it to autoDomain()
over the data passing through it.
attr()
can also be invoked at as a getter that returns the Accessor
-Scale
binding for a particular attribute:
interface AccessorScaleBinding {
accessor: Accessor;
scale?: Scale;
}
Property setters
There are now methods for setting Plot
properties that are not actual DOM attributes. These have a similar signature to attr()
, taking in an Accessor
function and a Scale
. An Accessor
has this signature:
interface Accessor<T> {
(datum: any, index: number, dataset: Dataset, plotMetadata: Plots.PlotMetadata): T;
}
Note that the third argument is now the Dataset
, rather than just the metadata()
from the Dataset
.
Here's an example property setter:
x(x: number | Accessor<number>): XYPlot<X, Y>;
x(x: X | Accessor<X>, xScale: Scale<X, number>): XYPlot<X, Y>;
x()
is used to set the "x" property on an XYPlot
: the previous invocation would have been something like project("x", function(d) { return d.x; }, xScale)
. Now, instead:
plot.x(function(d) { return d.x; }, xScale);
Here is the list of property setters:
- All
XYPlot
s:x()
andy()
Plots.Area
:y0
Plots.Grid
:x2()
andy2()
Plots.Pie
:innerRadius()
,outerRadius()
, andsectorValue()
Plots.Scatter
:size()
andsymbol()
Methods and Fields Renamed
A number of methods and protected fields have changed. These are documented in the upgrading guide: https://github.com/palantir/plottable/wiki/Upgrading-to-1.0.0
Bugfixes
Interaction.PanZoom
now works well when attaching aScale.ModifiedLog
to it.- Registering
Interaction.PanZoom
before the plot has rendered does not break. - If you were previously using a
Scales.Color
inside anAccessor
:
plot.project("fill", function(d) { return colorScale.scale(d.type); });
The Scale
's domain would have expanded to cover all the data, which was an error. Scale
s must be passed as the third argument to attr()
(or the second argument to the property setters) for the Scale
to autoDomain()
over all the data. Instead, do this:
plot.attr("fill", function(d) { return d.type; }, colorScale);