hi,
I'm trying to dynamically creatDynamically StackedFragmentSeries of a StackedColumnSeries. For some reason, at the run time, the execution stuck after setting ItemSources for a GroupBy object.
---XAMl---
<Page x:Class="DynamicStackColumnCharts.Page1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:igChart="http://schemas.infragistics.com/xaml" xmlns:local="clr-namespace:DynamicStackColumnCharts" mc:Ignorable="d" Loaded="Page_Loaded" d:DesignHeight="300" d:DesignWidth="300" Title="Page1"> <Page.Resources> </Page.Resources> <Grid> <igChart:XamDataChart x:Name="theChart"> </igChart:XamDataChart>
</Grid></Page>
-----code-----------------
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using System.Collections.ObjectModel;using Infragistics.Controls.Charts;using Infragistics;
namespace DynamicStackColumnCharts{ /// <summary> /// Interaction logic for Page1.xaml /// </summary> public partial class Page1 : Page { GroupBy gb ; public Page1() { InitializeComponent(); }
private void stack_SeriesCreated(object sender, Infragistics.Controls.Charts.StackedSeriesCreatedEventArgs e) { StackedFragmentSeries series = (StackedFragmentSeries)sender;
if (series != null) { series.Title = series.ValueMemberPath.Replace("_Count", string.Empty); } }
private void Page_Loaded(object sender, RoutedEventArgs e) {
gb= new GroupBy(); gb.GroupMemberPath = "Date"; gb.KeyMemberPath = "Installation"; gb.ValueMemberPath = "Emission"; ObservableCollection<InstalationEmissionDateInformation> temp = TestEmissionsCollection.GetItemSource(); gb.ItemsSource = temp;
NumericYAxis yAxis = new NumericYAxis(); CategoryXAxis xAxis = new CategoryXAxis(); xAxis.ItemsSource = gb; //xAxis.Label = "{Country}"; this.theChart.Axes.Add(xAxis); this.theChart.Axes.Add(yAxis);
StackedColumnSeries series = new StackedColumnSeries(); series.XAxis = xAxis; series.YAxis = yAxis; series.ItemsSource = gb; series.AutoGenerateSeries = true; theChart.Series.Add(series);
}
public class TestEmissionsCollection {
public static ObservableCollection<InstalationEmissionDateInformation> GetItemSource() { ObservableCollection<InstalationEmissionDateInformation> retVal = new ObservableCollection<InstalationEmissionDateInformation>(); retVal.Add(new InstalationEmissionDateInformation("A", 5, "1/1/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("B", 2, "1/1/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("C", 7, "1/1/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("A", 6, "1/2/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("B", 3, "1/2/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("C", 8, "1/2/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("A", 6, "1/3/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("B", 3, "1/3/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("C", 6, "1/3/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("A", 4, "1/4/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("B", 3, "1/4/2012", 1)); retVal.Add(new InstalationEmissionDateInformation("C", 7, "1/4/2012", 1)); return retVal; }
public TestEmissionsCollection() { } }
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; } }
this is XBAP application, after i set the security to full trust. GroupBy object itemsource is able to set.
How to display Label for CategoryXAxis?
Hello Lily,
I am just checking if you require any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
thanks, it worked!
Thank you for your reply. I am very glad my suggestion helped solving your issue. If you need any further assistance please do not hesitate to ask.