Based on this forum post: http://es.infragistics.com/community/forums/p/64311/478787.aspx#478787
Both the Tooltip and Legend text values are currently displaying "Series Title".
We are looking to get the Legend to display what each color represents or mapped to.
And when we hover over a Stack Fragment, in this sample, we want to display "Emission: <num value>".
How can we accomplish this?
Thanks,
Micjael
<Window.Resources> <local:TestEmissionsCollection x:Key="data" /> <ig:GroupBy x:Key="grouped" ItemsSource="{StaticResource data}" GroupMemberPath="Date" KeyMemberPath="Installation" ValueMemberPath="Emission" /> </Window.Resources> <Grid x:Name="LayoutRoot" Background="White"> <!-- Loaded="TheChart_OnLoaded" --> <igChart:XamDataChart x:Name="theChart" Legend="{Binding ElementName=xmLegend}" Title="{Binding ElementName=xmLegend, Path=ToolTip}"> <igChart:XamDataChart.Axes> <igChart:CategoryXAxis x:Name="xAxis" ItemsSource="{StaticResource grouped}" Label="{}{Key}" /> <igChart:NumericYAxis x:Name="yAxis" /> </igChart:XamDataChart.Axes>
<igChart:XamDataChart.Series> <igChart:StackedColumnSeries x:Name="stack" ItemsSource="{StaticResource grouped}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" AutoGenerateSeries="True" ShowDefaultTooltip="True">
</igChart:StackedColumnSeries> </igChart:XamDataChart.Series> </igChart:XamDataChart> <ig:Legend x:Name="xmLegend" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="20,20,5,20"> </ig:Legend>
namespace WpfAppStackedColumnSerie{ using System; using System.Collections.ObjectModel; using System.Windows;
using Infragistics; using Infragistics.Controls.Charts;
/// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); }
}
/// <summary> /// The test emissions collection. /// </summary> public class TestEmissionsCollection : ObservableCollection<InstalationEmissionDateInformation> { public TestEmissionsCollection() { Add(new InstalationEmissionDateInformation("A", 5, "1/1/2012", 1)); Add(new InstalationEmissionDateInformation("B", 2, "1/1/2012", 1)); Add(new InstalationEmissionDateInformation("C", 7, "1/1/2012", 1)); Add(new InstalationEmissionDateInformation("A", 6, "1/2/2012", 1)); Add(new InstalationEmissionDateInformation("B", 3, "1/2/2012", 1)); Add(new InstalationEmissionDateInformation("C", 8, "1/2/2012", 1)); Add(new InstalationEmissionDateInformation("A", 6, "1/3/2012", 1)); Add(new InstalationEmissionDateInformation("B", 3, "1/3/2012", 1)); Add(new InstalationEmissionDateInformation("C", 6, "1/3/2012", 1)); Add(new InstalationEmissionDateInformation("A", 4, "1/4/2012", 1)); Add(new InstalationEmissionDateInformation("B", 3, "1/4/2012", 1)); Add(new InstalationEmissionDateInformation("C", 7, "1/4/2012", 1)); } }
/// <summary> /// The instalation emission date information. /// </summary> public class InstalationEmissionDateInformation { public string Installation { get; set; } public Decimal Emission { get; set; } public string Date { get; set; } public Decimal Assignation { get; set; }
public InstalationEmissionDateInformation( string installation, Decimal emission, string date, Decimal assignation) { Installation = installation; Emission = emission; Date = date; Assignation = assignation; } } }
namespace WpfAppStackedColumnSerie { using System; using System.Collections.ObjectModel; using System.Windows; using Infragistics; using Infragistics.Controls.Charts; ///
/// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } } /// /// The test emissions collection. /// public class TestEmissionsCollection : ObservableCollection { public TestEmissionsCollection() { Add(new InstalationEmissionDateInformation("A", 5, "1/1/2012", 1)); Add(new InstalationEmissionDateInformation("B", 2, "1/1/2012", 1)); Add(new InstalationEmissionDateInformation("C", 7, "1/1/2012", 1)); Add(new InstalationEmissionDateInformation("A", 6, "1/2/2012", 1)); Add(new InstalationEmissionDateInformation("B", 3, "1/2/2012", 1)); Add(new InstalationEmissionDateInformation("C", 8, "1/2/2012", 1)); Add(new InstalationEmissionDateInformation("A", 6, "1/3/2012", 1)); Add(new InstalationEmissionDateInformation("B", 3, "1/3/2012", 1)); Add(new InstalationEmissionDateInformation("C", 6, "1/3/2012", 1)); Add(new InstalationEmissionDateInformation("A", 4, "1/4/2012", 1)); Add(new InstalationEmissionDateInformation("B", 3, "1/4/2012", 1)); Add(new InstalationEmissionDateInformation("C", 7, "1/4/2012", 1)); } } /// /// The instalation emission date information. /// public class InstalationEmissionDateInformation { public string Installation { get; set; } public Decimal Emission { get; set; } public string Date { get; set; } public Decimal Assignation { get; set; } public InstalationEmissionDateInformation( string installation, Decimal emission, string date, Decimal assignation) { Installation = installation; Emission = emission; Date = date; Assignation = assignation; } } }
http://es.infragistics.com/community/forums/t/64311.aspx
Covers how to properly format the legend.
We just require a sample of how to format the ToolTip.
Michael
This work, and based on other forum post.
<igChart:StackedColumnSeries.ToolTip> <TextBlock Text="{Binding Series.ValueMemberPath, Converter={StaticResource KeyConverter}, ConverterParameter='_Emission'}" /> </igChart:StackedColumnSeries.ToolTip>
Hi Michael,
I'm glad you were able to find a solution for this. Let me know if you require any further assistance.
Hi Rob,
My snippet above only provides the name not the value. (Emission names A B, C)
Please reply with an example that renders a ToolTip containing both the Name and Value (i.e. "A:5").
Your tooltip xaml only has one TextBlock in it. You need to add another TextBlock to it for the value. In order to get the value, though, you will need to pass the DataContext.Item to a converter so you can grab the value out of it. A MultiBinding is required for this so you can pass both the Item and the ValueMemberPath to the converter. Reflection can then be used to get the value from the Item. I attached a sample.
Hi , I am stuck on this urgent problem. Thank you for the sample. I have my chart in my XAML all set up with the code u gave. However my data is not present at the beginning . I get the data after clicking a button and fetch and assign it to my stackedColumnChart .
var data = ( TestEmissionsCollection)FindResource("data"); data.Clear(); data.AddRange(model.GetData());
This block gets fired at every button click . Rest of the code i am using is the same as the original post.
When I added the multibinding option to be able to get the Tool tip , that line crashes when I load the UI because the data is not available till the button click.
<MultiBinding Converter="{StaticResource ValueFromMemberPath}">
this line crashes with XamlParseException :
Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '56' and line position '38'.
How can I disable the tooltip till I fetch the data ?
Regards,
Prasaanth
For completeness, this latest issue was being discussed here: http://es.infragistics.com/community/forums/t/103083.aspx
also wanted to know how to display the labels of X and Y axis