About partially refreshing chart


Author
Message
Hongen GUAN
Hongen GUAN
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 4, Visits: 1

Hello,

We are working on adding/removing elements in chart dynamically.

Say there's a group of checkboxes. Each one represents a layer of the chart. Each layer holds various of graphic elements. User can decide which layers being displayed. Here is the problem: We have to call "Refresh()" of NChartControl after every single change of the chart. There will be performance issue.

Do we have another way to do this? Like some kind of refreshing the chart partially?

 

Thanks,

Hoken


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Hoken,

The easiest way to workaround such cases is to have a timer that refreshes the chart periodically - that is instead of directly calling refresh you may simply have a flag, which if raised triggers a refresh in response to a timer event - the following code shows how to implement this:

  bool refreshChart = false;

  private void Form1_Load(object sender, EventArgs e)
  {
   // setup the chart initially
   NChart chart = nChartControl1.Charts[0];
   NBarSeries bar = new NBarSeries();
   chart.Series.Add(bar);

   bar.Values.Add(10);

   refreshChart = true;
   timer1.Start();
  }

  private void button1_Click(object sender, EventArgs e)
  {
   // do some modifiations
   Random rand = new Random();
   NBarSeries bar = nChartControl1.Charts[0].Series[0] as NBarSeries;
   bar.Values.Add(rand.Next(10));

   // raise the refresh flag
   refreshChart = true;
  }

  private void timer1_Tick(object sender, EventArgs e)
  {
   if (refreshChart)
   {
    refreshChart = false;
    nChartControl1.Refresh();
   }
  }

Hope this helps - let us know if you meet any problems...

 



Best Regards,
Nevron Support Team


Hongen GUAN
Hongen GUAN
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 4, Visits: 1

Thanks for your reply.

I'm worried that dose not meet the requirement. Say layer1 has 1 million data points. layer2 is just one bubble. If I want to add this one bubble to the chart, I still have to refresh the whole chart, even within another thread to do this will still introduce the performence problem. The user wants to see the change immediately.

 


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Hongen,

An alternative solutions is too keep prerendered rasters of each layer and import them on the fly to the chart control for rendering trouhg NImageFillStyle for example...



Best Regards,
Nevron Support Team


Hongen GUAN
Hongen GUAN
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 4, Visits: 1
OK. Since I have limited knowledge about this. I'm guessing that's like some kind of cache. Could you please tell me some more details?
Hongen GUAN
Hongen GUAN
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 4, Visits: 1
In addition, we want some interactions in the chart. So if the 2nd layer which is an image covers the chart, it will also prevent raising mouse event in the 1st layer...
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search