beto-rodriguez / LiveCharts2

Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
https://livecharts.dev
MIT License
4.35k stars 569 forks source link

Legend disappears on hover WinUI #1674

Open jpageacsys opened 2 weeks ago

jpageacsys commented 2 weeks ago

Describe the bug When I hover over my pie chart, the legend disappears

To Reproduce I have a pie chart set up like this:

<lvc:PieChart
    MinWidth="600"
    Style="{StaticResource ChartStyle}"
    LegendPosition="Bottom"
    LegendTextPaint="{x:Bind KeyPaint}"
    TooltipBackgroundPaint="{x:Bind KeyBackground}"
    TooltipTextPaint="{x:Bind KeyPaint}"
    Series="{Binding PartStatus}"/>

The key binding is set to this in the page

public Paint KeyPaint
{
    get
    {
        if (ColorUtil.IsDark())
            return new SolidColorPaint(SKColors.White);
        else
            return new SolidColorPaint(SKColors.Black);
    }
}

public Paint KeyBackground
{
    get
    {
        if (ColorUtil.IsDark())
            return new SolidColorPaint(SKColors.Black);
        else
            return new SolidColorPaint(SKColors.White);
    }
}

Expected behavior The legend should remain visible but instead disappears when I hover over the control.

Screenshots Here's a video of it happening: https://github.com/user-attachments/assets/b6eaf2b0-5e08-4699-80f4-a1b8c185e8d8

If I remove the binding to the text color it works but this looks bad in the dark theme: image

I am using LiveCharts 2.0.0-rc4.5 for WinUI Thanks!

beto-rodriguez commented 2 weeks ago

Strange I'll take a look; the good news is that now that is handled by the library, themes now work better.

You need to do something like https://github.com/beto-rodriguez/LiveCharts2/issues/1458#issuecomment-2246990467 then the library will set the colors based on the theme.

jpageacsys commented 2 weeks ago

Thanks! I'll just switch over to using that.