CartoDB / airship

A design library for building Location Intelligence applications.
https://carto.com/developers/airship/
BSD 3-Clause "New" or "Revised" License
75 stars 14 forks source link

Histogram background data support #565

Closed rjimenezda closed 5 years ago

rjimenezda commented 5 years ago

This PR adds support to the histogram for 'background data'

~This lets the user provide an array of HistogramData that will be used as a fallback when a bucket value is 0.~

This is data that is rendered behind the actual data, filled with 'unselectedColor'.

This is particularly useful when filtering a visualization with the histogram and setting the resulting data back to it. If you keep a "global" version of the histogram, you will get some context in the background.

~Right now, this is always applied, but we should consider if it only makes sense when a selection is present. Thoughts? cc @ivanmalagon~

I've included an example that deals with a simulated scenario. When you change the selection, the histogram data is set to those buckets only. By default it has no background data, and there's buttons to change the background data and the data to new ranges

There's some special logic behind this. The background data is validated, and if it's not compatible* with the current data, is kept but ignored. On the next data update, the compatibility is checked again, and only if it compatible will the data be rendered.

*Compatible === equal in length, contains the same ranges or categories in the same bucket.

WIP because: