alphagov/magna-charta

Assign 'stacked' and 'total' classes programatically

Closed this issue · 1 comments

At the moment I'm manually adding these classes to the tables but I don't see why we can't do it with JS and make it much easier to use.

So:

  1. Any table with more than one .mc-bar-cell in a row should be interpreted as a stacked bar chart and be given the 'stacked' class.

  2. If the header of the final column in a stacked table contains the word 'total' it should be interpreted as a totals column and all cells in the column (including the header) given a 'total' class.

Thoughts?

Scratch that! OK, two things:

  1. The 'stacked' option should probably remain a manual thing, so users can switch between stacked charts and multiple value charts. I'd not implemented the multi-value charts when I raised this issue.

  2. I've simplified things so that stacked charts are assumed to always end in a 'totals' column (which, after all, is good practice). That way we just use last-child rather than having to assign a 'total' class.