Skip to content

Css enhancements#1461

Open
andrewgoz wants to merge 8 commits intochartist-js:mainfrom
andrewgoz:css-enhancements
Open

Css enhancements#1461
andrewgoz wants to merge 8 commits intochartist-js:mainfrom
andrewgoz:css-enhancements

Conversation

@andrewgoz
Copy link
Copy Markdown

This is a refactoring - the new CSS is functionally identical to the old. The primary reason for the changes is to reduce the size of the minimised CSS by nearly 20%, from 9038 bytes to 7370 bytes.

The other reason is to greatly simplify customizing series colors. Currently, the CSS styles to alter one series is:

.myclass .ct-series-a .ct-point, .myclass .ct-series-a .ct-line, .myclass .ct-series-a .ct-bar, .myclass .ct-series-a .ct-slice-donut {
  stroke: #123456;
}
.myclass .ct-series-a .ct-slice-pie, .myclass .ct-series-a .ct-area {
  fill: #123456;
}

Each additional custom series color duplicates the above over and over, adjusting for the series name.

With the new CSS variables, the required styles are:

.myclass .ct-series {
  --ct-series-a-color: #123456;
}

Each additional custom series color just duplicates the one color line, adjusting for the series name.

I have also added the "ct-chart" class name to all charts, to make it easier to write CSS rules that target all charts, in the same way there is a general "ct-series" class name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant