Making D3 responsive: viewBox vs resize()?

后端 未结 1 1586
遥遥无期
遥遥无期 2021-02-05 12:59

I have to build d3 visualisations that work well both on tablets, Desktop displays, and in some cases very very large 4k+ high resolution cinema size displays.

So I\'m tr

相关标签:
1条回答
  • 2021-02-05 13:05

    I'd recommend using the following logic:

    • If your visualization is usable in the smallest screens you want to support with the viewBox technique, stick to that, no need to look further (lucky you :))
    • Otherwise: you may have the following problems when scaling down the visualizations:
      • there are too many details, that cannot be distinguished in smaller screens
      • the texts are too small and not readable in the smaller screens

    Then you need to use javascript to adapt your visualization based on the screen size. This blog article which is serious about visualizations' responsiveness.

    Oh, and don't forget to debounce your resize event listener.

    0 讨论(0)
提交回复
热议问题