I have got my Live Charts Cartesian->Line Chart plotting 5 different types of data from a file/serial port but they are all on the same series.
I have 2 Y axis showing but cannot add data to each on the fly. The live charts documentation is terrible.
I have created 2 series but the data does not seem to plot.
<lvc:CartesianChart x:Name="lc_MainChart" Hoverable="False" Grid.Row="0" Grid.Column="1" DisableAnimations="True" LegendLocation="Right" Loaded="CartesianChart_Loaded" Margin="2,2,2,2" BorderBrush="Black" BorderThickness="2,2,2,2" >
<lvc:CartesianChart.AxisX >
<lvc:Axis Title="DATA POINTS" FontSize="18" MinValue="0" MaxValue="512" Labels="{Binding Labels}"></lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis Title="MOTOR VOLTAGE (mV)" FontSize="18" MinValue="0" MaxValue="8000" ></lvc:Axis>
<lvc:Axis Title="MOTOR CURRENT (mA)" FontSize="18" MinValue="0" MaxValue="800" Position="RightTop" ></lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.Series>
<lvc:LineSeries Name="Chart1" Values="{Binding ChartValues}"/>
<lvc:LineSeries Name="Chart2" Values="{Binding ChartValues2}"/>
</lvc:CartesianChart.Series>
</lvc:CartesianChart>
// Setup chart
ChartSeries = new SeriesCollection
{
new LineSeries
{
Title = "Motor Current",
Values = new ChartValues<Int16> {0},
PointForeground = Brushes.Red,
PointGeometry = null
},
new LineSeries
{
Title = "Voltage",
Values = new ChartValues<Int16> {0},
PointForeground = Brushes.Blue,
PointGeometry = null
}
};
// Setup chart series
ChartSeries2 = new SeriesCollection
{
new LineSeries
{
Title = "Motor Speed",
Values = new ChartValues<Int16> {0},
PointForeground = Brushes.Green,
PointGeometry = null
},
new LineSeries
{
Title = "Force",
Values = new ChartValues<Int16> {0},
PointForeground = Brushes.Blue,
PointGeometry = null
}
};
YFormatter = value => value.ToString("F");
lc_MainChart.LegendLocation = LegendLocation.Right;
ChartSeries[0].Values.Add(MotorCurrent[i]);
ChartSeries[1].Values.Add(VBat[i]);
ChartSeries2[0].Values.Add(MotorSpeed[i]);
ChartSeries2[1].Values.Add(Force[i]);
DataContext = this;
Here is a solution:
just add ScalesYAt="[index of axis]" property to LineSerie, hope save your time.