Search code examples
c#wpfcolorslivecharts

How to change the color of the label in the livechart? wpf


I am trying to create a bar chart with livechart following this example:

https://lvcharts.net/App/examples/v1/wpf/Labels Bar chart with black labels

My problem is I can't change the color of the label in the top of the bar. they are white and they can not be seen.

How could I change the color of the labels as the above example?


Solution

  • This is how to change the color:

    labelsExample.SeriesCollection.OfType<ColumnSeries>().ToList().FirstOrDefault().Foreground = Brushes.Green;
    

    I am not sure why you are having this issue. Default color is black: I followed the example in the link and I created a user control and I installed the nuget DLL and by default, the color is black for the labels on the bars as shown on the screenshot below:

    Screenshot

    After changing the color to green, the color becomes green as shown below:

    Screenshot showing green labels