factor out renderDynamicDiagram() function.