Enable Tooltips on XY Dataseries

WPF

Windows Presentation Foundation controls

Enable Tooltips on XY Dataseries

  • rated by 0 users
  • This post has 5 Replies |
  • 1 Follower
  • Is there a tutorial on how to enable tooltips on an xy dataseries so they display the values of a given point?  Like in the key features of the wpf chart documentation?

     

  • Hi,

    We can show tooltip on C1WpfChart in the following manner:

    The current DataPoint instance that provides information about the point.
    When using data binding it makes it easier to display this information in
    the label.

    Here is the sample of a label template that displays the value of the point.





    To assign the template to the data series set the PointTooltipTemplate
    property to the following:


    Since it is a standard data template, the complex label can be built, for
    example, the next sample template defines the data label for the XY chart
    which shows both coordinates of the data point.

    It uses the standard grid with two columns and two rows as a container. The
    x-value of the point is obtained with indexer of the DataPoint class. The
    indexer allows getting the values for the data series classes which support
    several data sets, such as XYDataSeries class.

    BEGIN CODE
















    />



    Path=Value}" />




    To assign the template to the data series set the PointTooltipTemplate
    property to the following:



    END CODE

    Hope this helps.

    Regards,
    Patrick

    wrote in message news:217862@10.0.1.98...
    Is there a tutorial on how to enable tooltips on an xy dataseries so they
    display the values of a given point? Like in the key features of the wpf
    chart documentation?




    http://helpcentral.componentone.com/cs/forums/p/79226/217862.aspx#217862
  • Your code is not showing up in your response on my computer.

    thanks for your help

     

  • Hi,
     
    Sorry for the incovenience, here is the code.
     
    <DataTemplate x:Key="lbl">
       <TextBlock Text="{Binding Path=Value}" />
    </DataTemplate>
     
    To assign the template to the data series set the PointTooltipTemplate property to the following:
     
    <c1c:DataSeries PointTooltipTemplate ="{StaticResource lbl}" />
     
    Since it is a standard data template, the complex label can be built, for example, the next sample template defines the data label for the XY chart which shows both coordinates of the data point.
     
    It uses the standard grid with two columns and two rows as a container. The x-value of the point is obtained with indexer of the DataPoint class. The indexer allows getting the values for the data series classes which support several data sets, such as XYDataSeries class.
     
    BEGIN CODE
     
    <DataTemplate x:Key="lbl">
       <!-- Grid 2x2 with black border  -->
       <Border BorderBrush="Black">
     
              <Grid>
     
                     <Grid.ColumnDefinitions>
                           <ColumnDefinition />
                           <ColumnDefinition />
                     </Grid.ColumnDefinitions>
     
                     <Grid.RowDefinitions>
                           <RowDefinition />
                           <RowDefinition />
                     </Grid.RowDefinitions>
     
                     <!-- x-coordinate -->
                     <TextBlock Text="X=" />
                     <TextBlock Grid.Column="1" Text="{Binding Path=[XValues]}" />
     
                     <!-- y-coordinate -->
                    <TextBlock Grid.Row="1" Text="Y=" />
                     <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=Value}" />
     
              </Grid>
       </Border>
    </DataTemplate>
     
    Now  assign the template to the data series set the PointTooltipTemplate property to the following:
     
    <c1c:DataSeries PointTooltipTemplate ="{StaticResource lbl}" />
     
    END CODE
     
    Hope this helps.
     
    Have a nice day.
     
    Regards,
    Patrick
    <pltaylor3> wrote in message news:217913@10.0.1.98...

    Your code is not showing up in your response on my computer.

    thanks for your help

     



    http://helpcentral.componentone.com/cs/forums/p/79226/217913.aspx#217913

  • I am trying to implement your code and I am running into a couple problems.  First a little background.  I have multiple charts with multiple series on them that are all different xy datasets.  My XAML code for one of the charts is simply.

    <my:C1Chart Name="c1Chart1" Margin="53,156.5,27,0" Height="300" VerticalAlignment="Top">

               <my:C1ChartLegend DockPanel.Dock="Right" />

    </my:C1Chart>

    i fill my charts in code behind using

    bunch of code....

    chart.Data.Children.Add(CreateDataSeries(sim1pts, ds.DataSetName,brushes[k]));

    finish up code....

    DataSeries CreateDataSeries(IEnumerable<System.Windows.Point> pts, string name, Brush brush)
            {
                return new XYDataSeries()
                {
                    XValuesSource = (from pt in pts select pt.X).ToArray<double>(),
                    ValuesSource = (from pt in pts select pt.Y).ToArray<double>(),
                    Label = name,
                    PointTooltipTemplate ="{StaticResource lbl}",
                    ToolTip = true,
                    ConnectionStroke = brush,
                };
            }

    the "PointTooltipTemplate ="{StaticResource lbl}", " is not currently working.  How would I fill that?

  • C1Chart_Tooltip_Sample.zip
    Hi,
     
    Please take a look at the attached sample which demonstrate how can we show ToolTip on a XY chart.
     
    Hope this helps.
     
    Regards,
    Patrick
    <pltaylor3> wrote in message news:217921@10.0.1.98...

    I am trying to implement your code and I am running into a couple problems.  First a little background.  I have multiple charts with multiple series on them that are all different xy datasets.  My XAML code for one of the charts is simply.

    <my:C1Chart Name="c1Chart1" Margin="53,156.5,27,0" Height="300" VerticalAlignment="Top">

               <my:C1ChartLegend DockPanel.Dock="Right" />

    </my:C1Chart>

    i fill my charts in code behind using

    bunch of code....

    chart.Data.Children.Add(CreateDataSeries(sim1pts, ds.DataSetName,brushes[k]));

    finish up code....

    DataSeries CreateDataSeries(IEnumerable<System.Windows.Point> pts, string name, Brush brush)
            {
                return new XYDataSeries()
                {
                    XValuesSource = (from pt in pts select pt.X).ToArray<double>(),
                    ValuesSource = (from pt in pts select pt.Y).ToArray<double>(),
                    Label = name,
                    PointTooltipTemplate ="{StaticResource lbl}",
                    ToolTip = true,
                    ConnectionStroke = brush,
                };
            }

    the "PointTooltipTemplate ="{StaticResource lbl}", " is not currently working.  How would I fill that?



    http://helpcentral.componentone.com/cs/forums/p/79226/217921.aspx#217921

Page 1 of 1 (6 items)