Hi,
I am using a XamDataChart to show a histogram, by binding a list of a custom class like:
class DataItem { public string Label { get; set; } public double Value { get; set;} }
My Xmal looks like this:
<ig:XamDataChart Name="xamDataChart1">
<ig:XamDataChart.Axes>
<ig:NumericYAxis x:Name="yAxis" MaximumValue="18" MinimumValue="0" />
<ig:CategoryXAxis
x:Name="xAxis"
ItemsSource="{Binding Series}"
Label="{}{Label}"
Gap="0"/>
</ig:XamDataChart.Axes>
<ig:XamDataChart.Series>
<ig:ColumnSeries
x:Name="series"
XAxis="{Binding ElementName=xAxis}"
YAxis="{Binding ElementName=yAxis}"
ValueMemberPath="Value">
</ig:ColumnSeries>
</ig:XamDataChart.Series>
</ig:XamDataChart>
What I am trying to do is show a tool tip on each column in the series to show the value of that given datapoint, is there anyway to do this with the tooltip, so far I can't seem to be able to do this.
Thanks
Hi ,
You can display the value of the datapoint on each of the respective Column by setting the ToolTip property of the ColumnSeries like ,
<ig:ColumnSeries x:Name="series" ItemsSource="{Binding Series}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ValueMemberPath="Value"> <ig:ColumnSeries.ToolTip> <StackPanel > <TextBlock Text="{Binding Item.Label}" /> <TextBlock Text="{Binding Item.Value}" /> </StackPanel> </ig:ColumnSeries.ToolTip></ig:ColumnSeries>
Hope this helps ..
-Shilpa
And how would you achieve this view code behind..? If the whole chart was created dynamically ...like
e.g:
ColumnSeries xmSeries = new ColumnSeries();
xmSeries.ValueMemberPath = "Value";
xmSeries.XAxis = xmXAxis;
xmSeries.YAxis = xmYAxis;
xmSeries.ItemsSource = dp;
xmSeries.Brush = new SolidColorBrush(colors[tupleCount % colors.Count()]);
xmSeries.Title = seriesName;
ToolTipControl control = new ToolTipControl();
control.DisplayTooltip(seriesName, tooltipValue);
xmSeries.ToolTip = control;
seriescol.Add(xmSeries);
The above codes foes not work as the series has only one datapoint....
To set the equivalent ToolTip binding in code behind , you can do the following -
StackPanel sp = new StackPanel(); TextBlock tb1 = new TextBlock(); TextBlock tb2 = new TextBlock(); sp.Children.Add(tb1); sp.Children.Add(tb2); tb1.SetBinding(TextBlock.TextProperty, new Binding("Item.Label")); tb2.SetBinding(TextBlock.TextProperty, new Binding("Item.Value")); xmSeries.ToolTip = sp;
Where "Label" and "Value" are the String and Numeric Columns respectively in the datasource , mapping to the Label and Value .