Hi there,
We have the following scenario: a Diagram with 323 items and 470 links takes about 8 seconds to display the first time. Is this reasonable and expected? What should we be looking at to improve this load time, please?
We do intend to show the entirety of the Diagram with all items and links at once, so we can't take advantage of Virtualization.
Profiling results indicate that the largest chunk of time is indeed spent in the Diagram constructor.
A large chuck of time is spent in RadDiagram.UpdateStylesAndTemplates, which is called three times (I suspect for the setting of each of ShapeStyle, ContainerShapeStyle, and ConnectionStyle) and seems to do plenty of work each time. I think this says that we already have the GraphSource populated before we hit the definitions of those styles (this is true based on reading order of the xaml).
What other sorts of things could we look at?
Thanks,
-David
5 Answers, 1 is accepted
The diagram has a built-in UI virtualization, but it's implementation kicks-in only after the diagram is loaded initially. The slow loading time comes from the fact that the diagram creates the containers for all the shapes initially. So, in summary it is expected for the diagram to be slow at first start.
In order to improve the initial load time you can implement some data virtualization that loads only the shapes that should be visible in the viewport. Then load the rest on demand. For example, when the diagram loads empty you can get its viewport, via the Viewport property. Then you can load only the shapes which positions are inside the viewport rectangle. You can load the rest of the shapes when the viewport changes. Or if you prefer you can start a timer and load shapes on portions.
I hope this suggestion helps.
Regards,
Martin Ivanov
Progress Telerik

Turns out we can't take advantage of virtualization -- we are indeed trying to show the whole diagram at once.
I did reorder the xaml so that we set GraphSource after setting ShapeStyle, ContainerShapeStyle and ConnectionStyle. That gets us down to about 6 seconds of load time from 8.
We'd still like to do more if you all have other suggestions, please...
Here are some additional tips which you can try.
- Simplify the ControlTemplate of the shapes as much as possible. You can extract the shape's Style and remove any visual elements that you don't need from the template. Here is you can use the Editing Control Templates and How to Create Custom Shape articles.
- Turn off the snapping of the items.
- Turn off the automation peers if they are not used.
Regards,
Martin Ivanov
Progress Telerik

Hello Martin,
we are looking for a diagram-Control for our new desktop-app. we tested your diagramcontrol and have the same problem as David. We try to visualize a diagram with up to 5000 items (worst case). Most of the items are simple lines, so we tried to optimize our testproject with the given tips. But they didn't help much. I replaced the default template of the RadDiagramShapeBase with a simple <border> to have the visual tree as slim as possible. When I now generate a diagram with 5000 random Items (MVVM), it takes up to 13 seconds until the diagram is shown. Then I realised that setting the initial WindowState of the window from Normal to Maximized reduces the time to 3 seconds!
Because of this, I think there is some kind of bug in your engine, which slows everything down.
I couldn't attach a Testproject. Is there some way to attach one for you?
We also tested Infragistics. Their control is a lot faster, even with a more complex visual tree. We still have some time for testing. If you could manage to improve the Performance, we would like to use your controls. Otherwise we will go with Infragistics.
Thanks,
Torsten
You can open a new support thread from your account where you will be able attach files and you will take advantage of guaranteed 24-hours response time from us.
Generally you can give us a saved XML from your diagram (unless you have custom types in it) and we will try to test it locally and improve the overall performance.
What you can now check fast is turning off the default virtualization telerik:DiagramSurface.IsVirtualizing="False". We are aware of some issues in the virtualization engine and we have logged a related item in our feedback portal:
Diagram: Improve virtualization performance
Regards,
Petar Mladenov
Progress Telerik