Column Series With different color on a different interval at x-axis fill in same series?

前端 未结 3 858
不知归路
不知归路 2020-12-18 14:44

I\'m trying to implement a speed/time plot UI, i\'m using WPF with the MVVM Pattern and Live-Charts by beto-rodriguez as my plot library. I am using Column Series.

i

相关标签:
3条回答
  • 2020-12-18 14:55

    You have a couple of options:

    Use a different series for every point:

    <lvc:CartesianChart>
       <lvc:CartesianChart.Series>
          <lvc:ColumnSeries Fill="Red" />
          <lvc:ColumnSeries Fill="Blue" />
    

    You can use set them using a mapper, for example: https://lvcharts.net/App/examples/v1/wpf/Point%20State

    0 讨论(0)
  • 2020-12-18 15:02

    Hi I fixed this problem with this code: In my case I need the column with the actual hour data in different color respect the other.

    Code Behind:

     public Brush DangerBrushFill { get; set; } = new SolidColorBrush(Colors.DarkOrange);
     public Brush DangerBrushStroke { get; set; } = new SolidColorBrush(Colors.Black);
     public CartesianMapper<Double> Mapper { get; set; }
     public ChartValues<double> ChartValues { get; private set; }
    
            Mapper = Mappers.Xy<Double>()
                .X((item, index) => item)
                .Y((item, index) => index)                
                .Fill((item, index) => 
                (item > 0 && index == DateTime.Now.Hour - 1) ? DangerBrushFill : null)
                .Stroke((item, index) =>
                (item > 0 && index == DateTime.Now.Hour - 1) ? DangerBrushFill : null);
    
            SeriesCollection = new SeriesCollection
            {
                new RowSeries
                {
                    Configuration=Mapper,
                    Values = ChartValues,
                    StrokeThickness = 3
                }
            };          
    

    Xaml:

     <lvc:CartesianChart    Hoverable="False"                            
                            Series="{Binding SeriesCollection}">
    

    I Hope this help you.

    0 讨论(0)
  • 2020-12-18 15:15

    1) Would it be possible that you fill the values of you ColumnSeries with 0's at the beginning? For example the values of the ColumnSeries will be like this, if you want to start your diagram from 7: {0, 0, 0, 0, 0, 0, 10, 12, 14, 16}

    2) Could you give another example of a condition? Do you really mean x=10 or probably y=10? Is this Issue related to your question?

    0 讨论(0)
提交回复
热议问题