After reading the spec and this question I've understood, that the rendering order is actually a timing order.
The sub-elements of an <svg>
are ordered in the z-axis regarding the timing of the rendering, meaning the element, which has been rendered first lies on bottom, the lastly rendered element on top of all others in the same area.
Is this differently for group elements (<g>
)?
If you look at this code (a JsFiddle) and the outcome, the helper lines (<line>
elements) lie above the graph lines (<path>
elements). The helper lines are grouped within the axis group, each graph line would be drawn in a separate group.
But the axes are rendered first, at least the function addYAxis
is called before handleLine
runs. What am I missing here?
Note: in this answer, dealing with the rendering of red circles and blue squares in a chart, is stated, that
In this case the red circle will be visible above the blue square even though the blue square was created last. This is because the circle and the square are children of different group elements, which are in a pre-defined order.
But I don't get, why this is possible and how I can set this pre-defined order.