Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1310
StackedColumns not painting when I refresh data
posted

Hello,

I am getting a problem when I try to paint some data, I have 2 options to choose in 2 combobox:

Installations or Enterprises

Year

My problem comes when I change from Installation to Enterprise. By default it paint data of the installations in a correct way, even if I change the year. The problem goes when changing to Enterprises. It paints only a few info of the data. From 60 registry it paints only 12.

I have tried doing in the other way, painting by default first of all the Enterprises and afterwards the installations and the result is the same.

My code behind is this one (this is on my server, I use silverlight):

 public List<ExcessVsEmissions> GetValuesOfExcessVsEmissionsEnterprise
(int year) { var TestEmissionsCollection = new List<ExcessVsEmissions>(); for (int i = 1; i <= 12; i++) { TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 4500, Date = (i.ToString() + " / " + year.ToString()[2] +
year.ToString()[3]), Emission = 4000, Id = new Guid(), Name = "Enterprise 1", ParentId = null, }); TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 3500, Date = (i.ToString() + " / " + year.ToString()[2] + year.ToString()[3]), Emission = 2000, Id = new Guid(), Name = "Enterprise 2", ParentId = null, }); TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 2000, Date = (i.ToString() + " / " + year.ToString()[2] +
 year.ToString()[3]), Emission = 1800, Id = new Guid(), Name = "Enterprise 3", ParentId = null, }); TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 10000, Date =(i.ToString() + " / " + year.ToString()[2] +
year.ToString()[3]), Emission = 10000 - 7800, Id = null, Name = "Emisiones Totales", ParentId = null, }); } return TestEmissionsCollection; } public List<ExcessVsEmissions> GetValuesOfExcessVsEmissionsInstallation
(int year) { var TestEmissionsCollection = new List<ExcessVsEmissions>(); for (int i = 1; i <= 12; i++) { TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 500, Date = (i.ToString() + " / " + year.ToString()[2] +
year.ToString()[3]), Emission = 400, Id = new Guid(), Name = "Instalacion 1", ParentId = null, }); TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 1000, Date = (i.ToString() + " / " + year.ToString()[2] +
year.ToString()[3]), Emission = 1100, Id = new Guid(), Name = "Instalacion 2", ParentId = null, }); TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 2000, Date = (i.ToString() + " / " + year.ToString()[2] +
year.ToString()[3]), Emission = 500, Id = new Guid(), Name = "Instalacion 3", ParentId = null, }); TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 3000, Date = (i.ToString() + " / " + year.ToString()[2] +
year.ToString()[3]), Emission = 2800, Id = new Guid(), Name = "Instalacion 4", ParentId = null, }); TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 4000, Date = (i.ToString() + " / " + year.ToString()[2] +
year.ToString()[3]), Emission = 3000, Id = new Guid(), Name = "Instalacion 5", ParentId = null, }); TestEmissionsCollection.Add(new ExcessVsEmissions() { Assignation = 10000, Date = (i.ToString() + " / " + year.ToString()[2] +
year.ToString()[3]), Emission = 10000 - 7800, Id = null, Name = "Emisiones Totales", ParentId = null, }); } return (TestEmissionsCollection); }

Each time I change my filter to installation or enterprise, it calls one or another method.

And in my View:

 <UserControl.Resources>

        <igChart:GroupBy
            x:Key="grouped"
            ItemsSource="{Binding ValuesOfExcessVsEmissions,Mode=TwoWay}"
            GroupMemberPath="Date"
            KeyMemberPath="Name"
            ValueMemberPath="Emission"
            />

    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">

        <ig:XamDataChart x:Name="theChart" Grid.Row="1" 
Visibility="{Binding ShowDataChart,Mode=TwoWay}" > <ig:XamDataChart.Axes> <ig:CategoryXAxis x:Name="xAxis" ItemsSource="{StaticResource grouped}" Interval="1" Label="{}{Key}"/> < <ig:NumericYAxis x:Name="yAxis" Interval="500" MinimumValue="{Binding MinAssignation,
Mode=TwoWay}"
MaximumValue="{Binding MaxAssignation,
Mode=TwoWay}"
/> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:StackedColumnSeries
x:Name="stack"
 ItemsSource="{StaticResource grouped}"
 XAxis="{Binding ElementName=xAxis}"
 YAxis="{Binding ElementName=yAxis}"
 AutoGenerateSeries="True"
 LegendItemVisibility="Visible"> </ig:StackedColumnSeries> </ig:XamDataChart.Series> </ig:XamDataChart> </Grid>

My ViewModel will Have this in the event that receives the data from the server:

  if (e.Result != null)
    { ValuesOfExcessVsEmissions = new ObservableCollection<ExcessVsEmissions>
(e.Result); ShowDataChart = Visibility.Visible; }


And my Model looks like this:


public class ExcessVsEmissions
    {
        private Guid? _parentId;

        public Guid? ParentId
        {
            get { return _parentId; }
            set
            {
                _parentId = value;
            }
        }

        private Guid? _id;

        public Guid? Id
        {
            get { return _id; }
            set { _id = value; }
        }

        private string _name;

        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
            }
        }

        private Decimal? _emission;

        public Decimal? Emission
        {
            get { return _emission; }
            set
            {
                _emission = value;
            }
        }

        private string _date;

        public string Date
        {
            get { return _date; }
            set
            {
                _date = value;
            }
        }
        private Decimal? _assignation;

        public Decimal? Assignation
        {
            get { return _assignation; }
            set { _assignation = value; }
        }       
    }

So, why is happening this? I have also tried to add Notify property changed
to my model, but with no luck.

Any idea? Thank you.

PS: By the way, how can I put a tooltip or legend to the Name
when I have Groupedby in my view?