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.
You are correct that the second line in your code-snippet would trigger the drawing of the XamDataChart, as once the data source of the OlapXAxis is set, it will try to resolve the series type and NunericYAxis and draw the chart based on that. One thing I am unsure of in this case, though, is why calling the LoadCustomizations method first is not working for you on this matter, and is only showing a blank chart. One thing I have noticed, is that the chart does not appear to honor the call to LoadCustomizations if the data source has not been set or used anywhere, though, but this may be a timing or redrawing issue with the chart. I will be continuing to investigate this, as it is possible that this could be a bug.
I am rather curious as to the structure of your ResultChanged event handler, to be honest, as I am unable to reproduce a flicker in the XamDataChart with an OlapXAxis unless I force the call to RefreshGrid on button click when the chart is fully expanded. I am attaching the sample project I have used to test this. Would it be possible for you to please look it over, and if it does not represent what is happening on your end, could you please modify it and send it back?
It would also be very helpful if you could please provide an isolated version of your sample project where this issue is reproduced so that I may be able to reproduce it on my end as well.
Please let me know if you have any other questions or concerns on this matter.
Nice example - and it looks pretty much like my code.
Except from the GenerateInitialItems() part. My data is very dynamic and I expect the Measures, Rows and Column to be set by the LoadCustomizations().
To reproduce my issues in your example do the following:
1. Run the code as it is, show some data, and click save
2. Verify when you start the program it shows the graph by default
3. Now comment these lines:
//fds.Rows = XmlaDataSource.GenerateInitialItems("[Date].[Date]"); //fds.Measures = XmlaDataSource.GenerateInitialItems("AmountOfSale, NumberOfUnits");
4a. Run the example and the graph shows nothing
4b. Move the setting of datasource to before result change and you will se a lot of flicker, but the graph shows data.
Any suggestions?
Thank you for following up. I wasn't able to reproduce the behavior following your steps. First I had to uncomment line 63 where SetMeasureAggregator was being called because the application will fail if the FlatDataSource has no measures assigned. Repositioning when the datasource is set to line 38 doesn't cause the graph to show data nor any flickering when loading the chart.
I've attached a video of my steps demonstrating this. I'm using the version 16.2 build 2045. Please clarify your steps to reproduce this behavior.
Let me know if you have any questions.
I am using 16.1.
But after I changed the code so I set the Measures, Rows and Columns manually and not depending on LoadCustomazations(), everything is working much better.
I am able to set the DataSource after the Load statement which (almost) removes all the flicker.
Thanks for your help on this matter.