Profile Picture

When is it adviceable to call _NevronChart.document.Calculate() and RecalcLayout()

Posted By joern kunze 5 Years Ago

When is it adviceable to call _NevronChart.document.Calculate()...

Author
Message
joern kunze
Problem Posted 5 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 4 Months Ago
Posts: 86, Visits: 221
Hi Experts,

I have a application which uses Nevron Chart with various Chart Types (point, line, bar...) - and it is possible to display multiple charts in rows and / or columns. In general, I process the data in the following way:

// Create Charts
....
// Create Series (create Scale: Lin / log...) and attach them to the Chart
...
// Fill Series with Data (AddRange...)
...

// Recalc layout so that the Chart can be placed manually within the panel so that multiple Charts can be drawn in  rows / columns:
   _NevronChart.document.Calculate();
    _NevronChart.document.RecalcLayout(_NevronChart.View.Context);
    _NevronChart.Refresh();


// apply zoom settings for each Chart - if applicable
...

// allign Charts within the Panel
...
// add events for interactivity
...

This approach has been working quite good so far. But with the last Nevron update only Point-Chart was still working - all other Charts did not show any data.
After investigating the problem, the line:
_NevronChart.document.Calculate();
seemed to be the culprit.

After removing the line, at first glance everything was working as before with the previous Chart Version.So the questions are now:

1) What is the recommended way to force the Chart to recalc its Layout so that I can use the chart values for getting Min/Max Values , updating the used rulers depending on the loaded data values for the axis as well as updating the chart coordinates to place the Chart within a panel for Multi-Chart arrangements ?

2) Is it not adviceable to use _NevronChart.document.Calculate(); before a _NevronChart.document.RecalcLayout(_NevronChart.View.Context); call ?
With previous versions I got the impression that calling RecalcLayout() might even be dangerous since under certain circumstances it can cause a hard crash of the Chart component.

2) When exactly is it adviceable to call _NevronChart.Refresh(); ? Is it a problem when the call happens to often ?

Thanks for your help,
Best regards,
Joern



Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
Hi Joern,

In general, the Calculate method will loop through all charts and compute the min/max values if they are dirty and then populate the automatic legends with data points. The RecalcLayout will position all panels and decorate all axes based on the min/max values and computed panel/axis sizes. In recent versions, the RecalcLayout will automatically call Calculate because there may be two calculate/recalc layout passes due to the "dynamic range" axis feature. Calling RecalcLayout is sufficient to validate that all min/max values are calculated and that the chart panels are positioned properly. 

The Refresh method will loop through all chart document views (the document can be displayed by many views simultaneously) and depending on the view will invalidate it - in the case of windows it will simply post a paint message. It is not a very expensive call but you should minimize the calls if possible. 

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


Best Regards,
Nevron Support Team



joern kunze
Posted 5 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 4 Months Ago
Posts: 86, Visits: 221
Thanks a lot for the explaination, so I have now removed all the document.calculate() calls when they are followed by an RecalcLayout call.

Best regards,
Joern



Similar Topics


Reading This Topic