I'm binding my xamchart of type Area to a list containing 3 values which are months,balance and interest.
I have set the Datamapping as Value=Balance and Label = Month.
I want the tooltip on the datapoint to show balance aswell as interest. I know i can set the ToolTip = Interest in Datamapping, but i also want to show the Balance. Is there anyway by which i can access the datasource from the tooltip's datatemplate and then display all the values.I tried some options like the one below but didnt work.
Please help.
Thanks.
<!-- Chart Series -->
<igCA:XamChart.Series>
<igCA:Series ChartType="Area"
DataMapping="Value=Balance;Label=Month;ToolTip=Interest">
</igCA:Series>
</igCA:XamChart.Series>
<!-- ToolTip Style-->
<Style TargetType="ToolTip">
<Setter Property="FontSize" Value="15" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
BorderThickness="1"
Background="LightGray">
<Grid DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igCA:Series}}}">
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Style="{StaticResource TextBlockStyle}"
Grid.Row="0"
Grid.Column="0"
Text="Account Balance:"/>
<Label Style="{StaticResource DollarLabelStyle}"
Grid.Column="1"
Content="{Binding Balance}"/>
Grid.Row="1"
Text="Interest Amount:"/>
Content="{Binding Interest}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
that is an interesting approach, but I'm afraid it won't work because the DataContext is never set on the tooltip objects that get created by the chart.
you can make a feature request here: http://devcenter.infragistics.com/protected/requestfeature.aspx
the only workaround I can think of is to add a string property on your data objects that return the full tooltip string, and add that new property to your DataMapping.
You can also load the data in code and then you can format the tooltip any way you want...
foreach (TPoint tp in tv.TPointList) { DataPoint dp = new DataPoint(); dp.ChartParameters.Add(ChartParameterType.ValueX, tp.X); dp.ChartParameters.Add(ChartParameterType.ValueY, tp.Y); dp.ToolTip = chartVector.VariableReference + "\r\nDate:" + tp.X.ToShortDateString() + "\r\nY:" + tp.Y.ToString(); series.DataPoints.Add(dp); }