I\'m trying to simply invert the Y Axis so this graph it goes up instead of down.
Starting at 6 going up to 1.
This is the user doc on inverted graphs
ht
To keep it simple, I would use negative negative values, and then format the labels:
<lvc:CartesianChart>
<lvc:CartesianChart.Series>
<lvc:LineSeries Values="{Binding Values}"></lvc:LineSeries>
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<lvc:Axis MinValue="-10" MaxValue="-1" LabelFormatter="{Binding Formatter}">
<lvc:Axis.Separator>
<!--to force the display of all the labels all the time
lets force the step-->
<lvc:Separator Step="1"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
Code Behind:
Values = new ChartValues<double>
{
-1,
-2,
-3,
-4,
-5,
-6,
-7,
-8,
-9
};
Formatter = x => x*-1 + " place";
The previous option is an specific solution for this question, to invert an axis you need to:
var invertedYMapper = LiveCharts.Configurations.Mappers.Xy<ObservablePoint>()
.X(point => point.X)
.Y(point => -point.Y);
var lineSeries = new LineSeries
{
Values = new ChartValues<ObservablePoint>
{
new ObservablePoint(0,2),
new ObservablePoint(1,5),
new ObservablePoint(2,7)
}
};
// set the inverted mapping...
lineSeries.Configuration = invertedYMapper;
var seriesCollection = new SeriesCollection
{
lineSeries
};
// correct the labels
var YAxis = new Axis
{
LabelFormatter = x => (x * -1).ToString()
};
cartesianChart1.AxisY.Add(YAxis);
cartesianChart1.Series = seriesCollection;