Skip to main content
Version: 1.15.0

Global styling

If you’re displaying multiple charts, you may want to have a single source of truth for their style.

Jetpack Compose

In Jetpack Compose, most default values are sourced from the ChartStyle provided by LocalChartStyle. You can use ProvideChartStyle to provide a custom ChartStyle. Use currentChartStyle to access the provided value.

ProvideChartStyle(remember(...) { ChartStyle(...) }) {
...
}

You can use m2ChartStyle or m3ChartStyle to create a baseline ChartStyle with the colors from your app’s Material Theme. These functions come from the compose-m2 and compose-m3 modules.

View system

In the view system, you can easily reuse and extend XML styles. Also, you can set the values of attributes at the theme level. For example, if you added <item name="showTopAxis">true</item> to your theme, all charts would have a top axis by default.