Theme: how to access the current theme colors that a chart is using? #1345
Unanswered
VincentH-Net
asked this question in
Q&A
Replies: 1 comment
-
This is not complicated. All you have to do is recover the current theme and modify the specific element drawing rules. Here is an example for financial series. LiveCharts.Configure(config =>
config
// you can override the theme
.AddDarkTheme()
.GetTheme<SkiaSharpDrawingContext>()
.HasRuleForFinancialSeries(delegate (IFinancialSeries<SkiaSharpDrawingContext> financialSeries)
{
financialSeries.UpFill = new SolidColorPaint(new SKColor(255, 195, 0, byte.MaxValue));
financialSeries.UpStroke = new SolidColorPaint(new SKColor(255, 195, 0, byte.MaxValue), 3f);
financialSeries.DownFill = new SolidColorPaint(new SKColor(0, 83, 255, byte.MaxValue));
financialSeries.DownStroke = new SolidColorPaint(new SKColor(0, 83, 255, byte.MaxValue), 3f);
})
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When building a chart's visuals in a bound property, e.g. in an
Axis
, how can I access a color for the current theme that a chart is using, irrespective of whether it is dark or light theme?When I respond like this to a Light / dark theme switch, the default Chart colors adapt automatically:
However, I'd like to choose a theme color for a specific element, but still adapt to dark / light theme automatically.
E.g. what should I code in a bound
Axis
property instead ofLabelsPaint = new SolidColorPaint(new SKColor(0,0,0,0))
?I would expect to be able to use some sort of color array index, but could find only examples that access a hardcoded theme - I would like to access the theme that the chart is currently using, without including logic in the bound property to detect whether the current theme is light or dark.
Beta Was this translation helpful? Give feedback.
All reactions