Search code examples
c#.netlivecharts

LiveCharts highlight point at specific position on X axis


Please, I have a functional piece of code. It hightlights point at 4th index with red brush (on X axis).

        var mapper = new CartesianMapper<double>()
           .X((value, index) => index)
           .Y(value => value)               
           .Fill((value, index) => index == 4 ? Brushes.Red : Brushes.Green);

What should I do when I have multiple points to highlight inside int[] array?

int[] pointsToHighlight = new int[] {4, 5, 6};

Solution

  • var mapper = new CartesianMapper<double>()
       .X((value, index) => index)
       .Y(value => value)               
       .Fill((value, index) => pointsToHighlight.Contains(index) ? Brushes.Red : Brushes.Green);