As described in the chart interface page each chart implementation must define a
mapData function that prepares the dataset for the rendering.
Each chart might need a different shape of data, but it's possible to identify some common patterns for transforming data.
For this purpose, we're introducing a "declarative mapping" approach, in which the rawgraphs chart interface can implement the
as a plain object describing the "role" of each dimension in the data transformation.
This API is still under definition and might change in the future versions.
#Simple column picking
This form of declarative mapping implements the operation of "translating" column names from the user dataset to the dimensions described in the charts.
Let's suppose we have a dataset like:
and a chart exposing two dimensions:
If we just want to "reduce" the dataset to a list of
y based on column mappings,
mapData function could be written like
Using the declarative mapping, we can just write:
Which tells RAWGraphs to just pick the two columns mapped on x and y dimensions. Note that this implementation would also work for multi-valued dimensions, while the function shown above would not work in this case.
You can see an example of this kind of mapping in the core bubble chart used in the RAWGraphs app.