Search code examples
wpfxamllivechartsmaterial-design-in-xaml

How to set label color of livechart?


I have an application based on materialdesigninxaml framework where I can set the light and the dark color, when the light color is setted I can see correctly the label text which is black, but when I set the dark theme the label of the charts still remain black, so I don't see anything. This is my chart:

 <lvc:CartesianChart Series="{Binding}" LegendLocation="Bottom">
       <lvc:CartesianChart.AxisY>
           <lvc:Axis Labels="{Binding AnalysisController.Labels}"/>
       </lvc:CartesianChart.AxisY>
 </lvc:CartesianChart>

I tried to add this to my App.xaml as suggested by the documentation:

<ResourceDictionary Source="pack://application:,,,/LiveCharts.Wpf;component/Themes/Colors/white.xaml" />

but the color of the text is still black


Solution

  • You can set the Foreground of your axis to another color like this:

    <lvc:CartesianChart Series="{Binding}" LegendLocation="Bottom">
        <lvc:CartesianChart.AxisY>
            <lvc:Axis Labels="{Binding AnalysisController.Labels}"
                      Foreground="White"/>
        </lvc:CartesianChart.AxisY>
    </lvc:CartesianChart>