c# How to revert Y Axis with Live Charts

858 views Asked by At

[liveCharts wpf C#] I am not good at English . Can you help me with this question? I'm trying to simply revert the Y Axis so this graph it goes down instead of up .

   public partial class Window5 : Window
{
    public SeriesCollection SeriesCollection { get; set; }
    public string[] Labels { get; set; }
    public Func<double, string> YFormatter { get; set; }
    public Window5()
    {
        InitializeComponent();
        SeriesCollection = new SeriesCollection { };
        SeriesCollection.Add(
             new VerticalLineSeries
             {
                 Title = "HK1",
                 Values = new ChartValues<double> { 5, 6, 9, 4, 5, 2 },
                 PointGeometry = null,
                 Fill = Brushes.Transparent
             }
         );

        SeriesCollection.Add(
             new VerticalLineSeries
             {
                 Title = "HK2",
                 Values = new ChartValues<double> { 3, 5 },
                 PointGeometry = null,
                 Fill = Brushes.Transparent
             }
         );
        Labels = new[] { "0", "-1.5", "-2.7", "-3.0", "-4.9", "-5.0" };
        DataContext = this;
    }
}

XAML

    <Grid>
    <lvc:CartesianChart  x:Name="diagram"
                         Series="{Binding SeriesCollection}">
        <lvc:CartesianChart.AxisY>
            <lvc:Axis Labels="{Binding Labels}"
                      Position="LeftBottom" 
                      RenderTransformOrigin="0.5,0.5">
            </lvc:Axis>
        </lvc:CartesianChart.AxisY>
        <lvc:CartesianChart.AxisX>
            <lvc:Axis MinValue="0"
                      Position="RightTop" />
        </lvc:CartesianChart.AxisX>
        <lvc:CartesianChart.DataTooltip>
            <lvc:DefaultTooltip SelectionMode="SharedYValues" />
        </lvc:CartesianChart.DataTooltip>
    </lvc:CartesianChart>
</Grid>

Image Reverse Axis Live chart

Code: https://drive.google.com/file/d/1-NOzBjLq2qELfKzqvLDN4LBzEFpVPpwD/view?usp=sharing

Thanks everyone!!!

0

There are 0 answers