Wpf Modern UI Metro Chart Update Chart

Asked

Viewed 104 times

1

I have the chart below where the first load works normally, but when I do a search and change the list it continues with the previous series.

Ex: in the first load I have 8 items in the list and it shows ok. According to a population search again with 21 items but the chart continues showing the 8 previous items.

<chart:ClusteredColumnChart
    x:Name="chtEvolucaoDiaria"                 
    Style="{StaticResource MinimalChartStyle}"
    ChartTitle="Evolução Diária"    
    Grid.Row="1"
    Grid.Column="3"
    Width="auto"
    Height="400"
    Background="#444444"
    Foreground="White"
    Palette="{StaticResource Cores}" 
    ChartSubTitle="" 
    >
</chart:ClusteredColumnChart>

In the codebehind populo it this way:

chtEvolucaoDiaria.Series.Clear();

ChartSeries series = new ChartSeries();
series.Name = "dc" + dia;
series.DisplayMember = "Categoria";
series.ValueMember = "Valor";
series.SeriesTitle = dia.ToString();
series.Foreground = Brushes.White;

series.ItemsSource = ListaDcEvolucaoDiaria;

chtEvolucaoDiaria.Series.Add(series);

Editing

Apparently change the order of the following lines works:

Of:

series.ItemsSource = ListaDcEvolucaoDiaria;

chtEvolucaoDiaria.Series.Add(series);

To:

chtEvolucaoDiaria.Series.Add(series);

series.ItemsSource = ListaDcEvolucaoDiaria;

1 answer

1


Apparently change the order of the following lines works:

Of:

series.ItemsSource = ListaDcEvolucaoDiaria;

chtEvolucaoDiaria.Series.Add(series);

To:

chtEvolucaoDiaria.Series.Add(series);

series.ItemsSource = ListaDcEvolucaoDiaria;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.