explorable-viz / fluid

Data-linked visualisations
http://f.luid.org
MIT License
32 stars 1 forks source link

`Aggregate` values in `BarChart` and `LineChart` #999

Open rolyp opened 1 month ago

rolyp commented 1 month ago

This is an idea for a “hardcoded” generalisation of bar charts and line charts to support aggregate values (initially just sums, but potentially averages as well). Perhaps just for the y axis initially, allow a data value (currently a number) to instead be a list of numbers paired with an operation (e.g. sum). Then when visualising BarChart, we can choose to render the aggregate value (total) as the “primary” height of the bar, with the total of the selected values shown as a “secondary” bar on top. For LineChart we could do something similar. While there are potentially ways of understanding this in terms of program transformation or data provenance, these are outside of the scope of the current project and this goal here is more to motivate the feature, rather than provide a general-purpose solution.

Aggregate would have a constructor for the “singleton” aggregate that just contains a single value; aggregates would perhaps also nest (so that you can have an aggregate of aggregates). For explorable-viz/fluid-examples#20, we also want to “deaggregate”: split out a BarChart or LineChart which contains (non-singleton) aggregates into an aggregate of bar or line charts with one less dimension of aggregation (something like a distributive law). Think of this as a kind of automatic faceting feature.