explorable-viz / fluid

Data-linked visualisations

Home Page:http://f.luid.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`BarChart` to support stacked bars

rolyp opened this issue · comments

It should be relatively easy to adapt BarChartRecord (let’s call it Bar or StackedBar) to take a list of (categorical value, numerical value) pairs, rather than a single numerical value, in such a way that the current bar chart examples are supported as a special case.

Conceivably we could represent BarChart as a dictionary of Bar (or StackedBar, which could itself be a dictionary of numerical values), since categorical values are currently represented as strings, but for that we would probably want #954, and anyway we might want to use something other than strings to represent categorical data at some point.

  • Selectable type synonym
  • BubbleChartRecord -> Bubble
  • BarChartRecord -> StackedBar
  • Turn y field of type Number into list of (String, Number) pairs
  • Fix up bar-chart-line-chart.fld
  • Generalise BarChart.js to extract y data by extracting first element from list of (String, Number) pairs
  • Fix bar selection
  • Generalise BarChart.js to support multiple y data values (but validate on singleton stack only initially)
    • Scan-like operation on bars in stack to accumulate y offset
  • New example to exercise generalisation, based on new non-renewables dataset
    • Copy bar chart code from bar-chart-line-chart.fld to stacked-bar-chart.fld and add to ICFP2024.purs
    • Switch to non-renewables.fld
    • Plot year rather than country on x-axis (say 2014-2017); plot country on y-axis (BRA only, initially)
    • Plot multiple countries on y-axis
    • Clean up code a bit
  • Fix BarChart.js code for non-singleton stacks
    • Exception in Sel_isNone (broken x field, missing sel field)
    • y_max as sum of bar segments not just first
    • y calculation to use prev.height
  • Fix stack segment selection
    • Restore previous behaviour where data binding for each rect carries index of bar
    • Extend with index of bar segment
  • Experiment with passing d (data) to handler rather than accessing via __data__ ❌ not straightforward
  • Better heuristic for tickEvery
  • Colour scheme
  • Highlighting problem with overlaid borders
  • Maybe distinguish colour scheme from line chart (for sake of bar-chart-line-chart example)
  • Selection border stroke to emulate line chart

Couple of mini-problems to fix:

  • Caption truncated
  • Selection of bottom segment of bar is borked