Hello,
I am trying to show a StackedColumnSeries which will have in each column the same X number of data to be stacked.
What I want to do is to create dynamically each StackedFragmentSeries depending on the number of the data to be shown. I can't know the quantity because there will be different filters which will allow to pick different information from the database.
In the example below is my attempt to show it by binding the stackedFragmentSeries to an ObservableCollection, but it doesn't show anything. Emissions is the Observable collection with the values catched from the Database and they are Decimals. Any help about this?
<ig:XamDataChart x:Name="xamStackedColumnChart" Legend="{Binding ElementName=xmLegend}" Padding="10" Visibility="Visible" HorizontalZoomable="True" HorizontalZoombarVisibility="Collapsed" VerticalZoomable="True" VerticalZoombarVisibility="Collapsed" > <ig:XamDataChart.Axes> <ig:NumericYAxis x:Name="StackedColumnYAxis" MinimumValue="0" Interval="10000" Label="{}{} T CO2" MaximumValue="250000" LabelSettings="{StaticResource AxisLabelSettings2}"/> <ig:CategoryXAxis x:Name="StackedColumnXAxis" ItemsSource="{Binding ValuesOfExcessVSEmissions}" Label="{}{Date}" /> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:StackedColumnSeries x:Name="StackedColumns" XAxis="{Binding ElementName=StackedColumnXAxis}" YAxis="{Binding ElementName=StackedColumnYAxis}" ItemsSource="{Binding ValuesOfExcessVSEmissions}"> <ig:StackedColumnSeries.Series> <ig:StackedFragmentSeries ValueMemberPath="Emissions" Title="{Binding ValuesOfExcessVSEmissions}"> </ig:StackedFragmentSeries> </ig:StackedColumnSeries.Series> </ig:StackedColumnSeries> </ig:XamDataChart.Series> </ig:XamDataChart>
Hi, could you show an example of you data? Depending on the format of the data, you should be able to use our GroupBy data source and AutoGenerateSeries on the StackedColumnSeries.
-Graham
What do you need exactly?
I will try to listen the events, but that goes against my MVVM pattern.
And how do I bind the name of my elements of the GROUPBY ?
Thank you
Its not against the pattern, have something in your viewmodel listen to the event and change a visibility property on the viewmodel accordingly. Then have the chart or a splash bind to the visibility property on your viewmodel.
You will have to explain what you mean by the second question in more detail.
Hope this helps!
My second question, I have this legend and I don't know how to bind the context to my GroupByItems. i want to show the KeyMemberPath name in my legend.
Legend:
<ig:Legend x:Name="xmLegend"
HorizontalAlignment="Stretch"
Background="Transparent" Padding="2"
BorderBrush="Transparent"
Style="{x:Null}"
VerticalAlignment="Top"
Margin="2"
Content="{Binding Source={StaticResource grouped},Path= KeyMemberPath}"> </ig:Legend>
Groupby:
<igChart:GroupBy x:Key="grouped" ItemsSource="{Binding ValuesOfExcessVsEmissions,Mode=TwoWay}" GroupMemberPath="Date" KeyMemberPath="Name" ValueMemberPath="Total"/>
Looks like there is a bit of a functionality hole there for the auto generated case. I couldn't find a straightforward way to make the series title equal the key for that series. So you may want to make a feature request. But you can do the below to work around the missing functionality.
<UserControl.Resources> <local:TestEmissionsCollection x:Key="data" /> <igChart:GroupBy x:Key="grouped" ItemsSource="{StaticResource data}" GroupMemberPath="Date" KeyMemberPath="Installation" ValueMemberPath="Emission" /> <local:KeyConverter x:Key="keyConverter" /> <DataTemplate x:Key="keyLegendItemTemplate"> <StackPanel Orientation="Horizontal" Margin="1" Visibility="{Binding Series.Visibility}"> <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Series.LegendItemBadgeTemplate}" /> <ContentPresenter Content="{Binding Series.ValueMemberPath, Converter={StaticResource keyConverter}, ConverterParameter='_Emission'}"/> </StackPanel> </DataTemplate> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <igChart:XamDataChart x:Name="theChart" Legend="{Binding ElementName=legend1}"> <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" LegendItemTemplate="{StaticResource keyLegendItemTemplate}" > </igChart:StackedColumnSeries> </igChart:XamDataChart.Series> </igChart:XamDataChart> <igChart:Legend x:Name="legend1" Grid.Column="1" /> </Grid> </UserControl>
And code behind:
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } } 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)); } } 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; } } public class KeyConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is string && parameter is string) { var key = (string)value; var param = (string)parameter; key = key.Replace(param, ""); return key; } return ""; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }
Hope this helps!-Graham
There is no luck, it shows "Series Title".
By the way, I am getting a problem that I have posted in this forum, that when I ask my server to change the data to show, it does not paint any bar, and I have realized that the legend neither changes. I know this because it must show 4 elements when I change my detail option and it continues showing 6 of my default choice.
Hello Michael,
I believe Rob has already answered this question here:
https://ko.infragistics.com/community/forums/f/ultimate-ui-for-wpf/97084/xamdatachart-stackedcolumnseries-group-by-how-do-we-properly-set-the-tooltip-and-legend
Using the Sample above how do we properly format the Tooltip value?
Currently it is only displaying the value not the name.
Current Tooltip reads: Series Title: 7
Ideally we want: Emission: 7.
Thanks,
Michael
Using the sample above, how to we get the tooltip to provide meaningful text?
<igChart:StackedColumnSeries x:Name="stack"ItemsSource="{StaticResource grouped}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" AutoGenerateSeries="True" ShowDefaultTooltip="True"></igChart:StackedColumnSeries>
See attached screenshot.
Got it now that I am awake. :-)
<Window x:Class="WpfAppStackedColumnSerie.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfAppStackedColumnSerie" xmlns:igChart="clr-namespace:Infragistics.Controls.Charts;assembly=InfragisticsWPF4.Controls.Charts.XamDataChart.v14.2" xmlns:ig="http://schemas.infragistics.com/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <local:TestEmissionsCollection x:Key="data" /> <ig:GroupBy x:Key="grouped" ItemsSource="{StaticResource data}" GroupMemberPath="Date" KeyMemberPath="Installation" ValueMemberPath="Emission" /> </Window.Resources> <Grid>
Is GroupBy still available for WPF in version 15.1?
What is the namespace for "igChart"?
Snippet: