Working with SVG¶
Expanding the SVG Region¶
If the default svg area is not the right size for your needs, you can change its dimensions.
The <svg> element that scripts render to is contained within an element called svg-container, whose only child is the render area. Thus, the render area can be obtained with:
style.width and style.height attributes of the rendering area.
Changing the rendering area size
This code changes the available space in the <svg> element, giving us 5 times the original vertical space to work with:
Resizing in the script
If you're using the helper library, you may need to resize after calling stage.render.
Alternative Method¶
You also have access to set the viewBox attribute of the <svg> region. However, we don't suggest making this specific kind of low-level change if you're working only with D3FX.
Importing modules¶
Sterling uses the d3-require and jsdelivr systems to import external libraries. These should be given in the first lines of the script (before any comments!) and be enclosed in a single require form per library. E.g., to import the d3-array and d3-format libraries: