Showing the X-Values in the Tooltip
To show the x-values in the tooltip, use the following xaml and then the Visual Basic or C# code that creates the chart and uses the template:
•XAML
<c1chart:C1Chart x:Name="chart">
<c1chart:C1Chart.Resources>
<DataTemplate x:Key="tt">
<StackPanel Orientation="Vertical">
<!-- XAsString returns xvalue that is formatted similar to x-axis -->
<TextBlock Text="{Binding XAsString}" />
<TextBlock Text="{Binding Y}" />
</StackPanel>
</DataTemplate>
</c1chart:C1Chart.Resources>
</c1chart:C1Chart>
Dim cnt As Integer = 20
Dim x As DateTime() = New DateTime(cnt - 1) {}
Dim y As Double() = New Double(cnt - 1) {}
Dim rnd As New Random()
For i As Integer = 0 To cnt - 1
x(i) = DateTime.Today.AddDays(-i)
y(i) = rnd.NextDouble() * 100
Next
chart.Data.Children.Add(New XYDataSeries())
chart.View.AxisX.IsTime = True
chart.ChartType = ChartType.LineSymbols
•C#
int cnt = 20;
DateTime[] x = new DateTime[cnt];
double[] y = new double[cnt];
Random rnd = new Random();
for (int i = 0; i < cnt; i++)
{
x[i] = DateTime.Today.AddDays(-i);
y[i] = rnd.NextDouble() * 100;
}
chart.Data.Children.Add(new XYDataSeries()
{
XValuesSource = x, ValuesSource = y,
PointTooltipTemplate = (DataTemplate)chart.Resources["tt"]
});
chart.View.AxisX.IsTime = true;
chart.ChartType = ChartType.LineSymbols;