This is a migrated thread and some comments may be shown as answers.

How to redraw chart?

5 Answers 105 Views
Chart
This is a migrated thread and some comments may be shown as answers.
hyojung kwon
Top achievements
Rank 1
hyojung kwon asked on 23 Jun 2010, 02:55 AM
Hello,

In my application I draw LineSeries chart using WCF service.
Chart is drawn, once page is loaded for the first time and when user click refresh button, it gets new data using WCF service then is supposed to be redrawn.
However, when chart is redrawn by refresh button, LineSeries chart draws over old chart without clearing old chart.

I used following code to refresh chart.

       void server_GetGraphDataCompleted(object sender, GetGraphDataCompletedEventArgs e)
        {
            RadChart1.ItemsSource = null;
            List<GraphEntity> result = e.Result;
            RadChart1.ItemsSource = result;
        }

Whenever user click refresh button, chart is created over old one.

Can you tell me what I did wrong?

Thanks in advance
Kwon

5 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 25 Jun 2010, 01:02 PM
Hello hyojung kwon,

You are binding the chart correctly. Most probably the data returned in the second call to the service contains the old data as well and the chart correctly plots both series.

Best wishes,
Vladimir Milev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
hyojung kwon
Top achievements
Rank 1
answered on 28 Jun 2010, 02:19 AM
I checked my code but data returned from service has same counts and same data.
Following is my code in silverlight behind code.

private ServiceReference.ServiceClient server;

public GraphDemo()
        {
            InitializeComponent();
         
            server = new ServiceReference.ServiceClient();
            server.GetGraphDataCompleted += new EventHandler<GetGraphDataCompletedEventArgs>(server_GetGraphDataCompleted);

            FillChartData();
        }

 private void FillChartData()
        {
                SeriesMapping sm2 = new SeriesMapping();
                sm2.SeriesDefinition = new LineSeriesDefinition();
                sm2.LegendLabel = "SpO2";

                ItemMapping im3 = new ItemMapping("SpO2Value", DataPointMember.YValue);
                ItemMapping im4 = new ItemMapping("ColumnTimeForXCategory", DataPointMember.XCategory);
                sm2.ItemMappings.Add(im3);
                sm2.ItemMappings.Add(im4);

                RadChart1.SeriesMappings.Add(sm2);
                
                server.GetGraphDataAsync();
}

void server_GetGraphDataCompleted(object sender, GetGraphDataCompletedEventArgs e)
        {
            RadChart1.ItemsSource = null;
            List<GraphEntity> result = e.Result; // returns same number of data from service
            RadChart1.ItemsSource = result;
        }


Is there any doubtable code up there?

Thanks in advance.
Kwon

0
Accepted
Nikolay
Telerik team
answered on 30 Jun 2010, 11:29 AM
Hello hyojung kwon,

It appears that the issue is related to what happens when clicking the Refresh button. In order to clear the older chart you need to clear the SeriesMappings and call FillChartData() again, as shown below :

private void RefreshButton_Click(object sender, RoutedEventArgs e)
       {
           RadChart1.SeriesMappings.Clear();
           this.FillChartData();
       }

Please, let us know if this works on your side as well.

Kind regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
hyojung kwon
Top achievements
Rank 1
answered on 01 Jul 2010, 01:30 AM
Hello Nikolay

It is working well for me.
Thank you so much.

Regards
Kwon
0
Niclas Junsved
Top achievements
Rank 1
answered on 04 Aug 2010, 02:31 PM
Hi!

How do I achieve "clear" as below in Q2 2010 version?

 

radChart.SeriesMappings.Clear();

 


Regards

Niclas

Tags
Chart
Asked by
hyojung kwon
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
hyojung kwon
Top achievements
Rank 1
Nikolay
Telerik team
Niclas Junsved
Top achievements
Rank 1
Share this question
or