C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Enable Tooltips on XY Dataseries

rated by 0 users
This post has 5 Replies | 1 Follower

Top 500 Contributor
Posts 13
pltaylor3 Posted: Wed, May 13 2009 9:48 AM

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?

 

Top 10 Contributor
Posts 1,237
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
Top 500 Contributor
Posts 13
pltaylor3 replied on Thu, May 14 2009 10:08 AM

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

thanks for your help

 

Top 10 Contributor
Posts 1,237
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

Top 500 Contributor
Posts 13
pltaylor3 replied on Thu, May 14 2009 10:48 AM

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?

Top 10 Contributor
Posts 1,237
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) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.