Chart for WinRT
Showing the X-Values in the Tooltip

Showing the X-Values in the Tooltip

To show the x-values in the tooltip, use the following XAML markup with the Visual Basic or C# code that creates the chart and uses the template:

XAML
Copy Code
<Chart:C1Chart x:Name="chart">
   <Chart: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>
    </Chart:C1Chart.Resources>
</Chart:C1Chart>

Visual Basic
Copy Code
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#
Copy Code
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"]
  });
  c1Chart1.View.AxisX.IsTime = true;
  c1Chart1.ChartType = ChartType.LineSymbols;

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback