I have created a CartesianChart using LiveCharts in WPF which shows values from a list called NIOquoteTrend. The list is populated with values from a database and each value has a specific corresponding timestamp in the database.
I have displayed the values with intervals of 1 hour and I have a DateTimePicker to specify the timestamps between which the values will be shown. There is also a button which then calls the funcion UpdateQuoteTrend(). The values are displayed correctly in the chart but what I do not know how to do is how to display the DateTime in the x-Axis corresponding to the specific value.
Since the series-values are displayed correctly and in the right order I think a solution would be to just display the dates and times between the selected values as labels in the X-Axes with an interval of 1 hour. If anyone has any idea how I could do that I would very much appreciate the help. Below is my cs code:
void UpdateQuoteTrend()
{
if (trendChart.Series.Count > 0)
trendChart.Series.Clear();
trendChart.Series.Add(new LineSeries
{
Title = "Fehlerquote",
Values = NIOquoteTrend.AsChartValues(),
Stroke = Brushes.Red,
PointGeometry = DefaultGeometries.Circle,
PointGeometrySize = 15
});
}
This is my XAML code:
<Wpf:CartesianChart x:Name="trendChart" Margin="0,40,0,0" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="3" LegendLocation="Right" FontSize="20" Zoom="Xy" ScrollMode="XY" >
<Wpf:CartesianChart.AxisX>
<Wpf:Axis x:Name="xAxisTrendChart" Title="Datum" FontSize="20" />
</Wpf:CartesianChart.AxisX>
</Wpf:CartesianChart>
and this is what the graph looks like: graph
Never mind I solved it. I just created a new SQL Query/ Stored Procedure similar to the one I used to get the values from the database, just instead of values I get the timestamps as string. I then save the timestamps in a list which I use as labels in my x-Axis.