Hello
I have a XamDataChart with a OlapXAxis set to a FlatDataSource.
I've made som logic in the FlatDataSource.ResultChanged (aggregators and auto expand). This is done after following suggestions on this Forum. However it is nessesarry to call RefreshGrid in the event, which causes the graph to draw multiple times. This looks wierd and the graphs flickers. This is because I attach the datasource which causes the graph to draw, then I call RefreshGrid in the result changed, which causes the graph to redraw.
I have different thoughts on how to fix this, but I struggle with finding a suitable event. I need a way to suspend the layout and then resume it after drawing is done.
Any ideas?
Hello logimatic,
I have been investigating into this issue, and you are correct that the RefreshGrid method will cause the XamDataChart and its OlapXAxis to redraw. The flicker seems to be most easily reproduced on my end when the dimensions of the Olap hierarchy are expanded, especially if they are fully expanded.
I am curious if the flicker is happening mostly on your end due to the expansion and aggregator assignment happening within the ResultChanged event of the FlatDataSource. The reason why I am curious about this, is because both the assignment of aggregators and the calling of the RefreshGrid method will cause this event to fire again, and so it is possible that the ResultChanged event may be firing multiple times on your end, and firing the RefreshGrid method multiple times with it. Would it be possible for you to please provide some more detail on exactly what is happening during this ResultChanged event, and if you are taking any measures to prevent the re-fire of this event?
So far, I have not personally found a way to "suspend" the layout and resume it after drawing is done, unless this happens at the start of the application, in which case you can do the expansion and aggregator assignment before assigning the data source to the XamDataChart.OlapXAxis. This would allow the chart to show up with the expansion and aggregator assignment. I am currently investigating further into this, though, as it is possible that we are destroying and redrawing more than we actually need to internally to the OlapXAxis, which could also cause this flicker you are seeing.
I hope to have more information for you on this matter soon. In the meantime, would it be possible for you to please provide your thoughts on the above? Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Thanks for your answer.
An example:
See picture.
It should be used in a dashboard and I only want to draw it when init (at least this will be ok, I am not wirried about the flickering while designing)
I have saved the layout and my code to init the graph looks like this:
_dataSource.ResultChanged += _dataSource_ResultChanged;
olapXAxis.DataSource = _dataSource;
_dataSource.LoadCustomizations(_graphSettings.PivotSettings);
As far as I can tell the second line triggers the first drawing of the graf. If I set the datasource after the LoadCustomizations method, the graph just shows up empty for some reason. I cannot not set any aggreator in this method because _dataSource.Measures is empty and not yet initialized, and therefor I figured to do it in the ResultChanged event. The ResultChangedEvent fires ~8 times in my case (I assume it has something to do with the expand set in the PivotSettings).
Of course I can make some code in the ResultChange event to check if the aggregators already has been set, but since I have to call RefreshGrid after it will still flicker slightly because I have to do at leat one call to RefreshGrid (both the settings of the datasource and RefreshGrid will trigger a redraw).
This is a simplification of my project, I also do other things in the ResultChanged, like expand all not expanded levels and set default sorting. But I don’t think that is relevant for the example.