nzzdev/Q-chart

Aspect Ratio: Add displayOption to choose the aspect ratio (size)

Closed this issue · 0 comments

benib commented

We want to choose the aspect ratio (size) of the chart when embedding in an article.
Therefore we add a new displayOption size.
This option should only be available if it is a Columnchart (bar where option.isBarChart !== true) or a Linechart. the other charts aspect ratio is defined by the data.

display option size has two options for the beginning but could be extended with a third option.

  • basic resulting in aspect ratio 7:3 (the default used if displayOption is not defined)
  • prominent resulting in aspect ratio 16:9
  • middle would be 18:9 (we do not implement this for now)

The choosen aspect ratio should then be used to calculate the height based on the width. This applies to the chart only (without title, subtitle, legend, footer) and can be applied to the vega spec height directly in the respective mapping.

There needs to be a fixed minimum height of 240px. If the aspect ratio calculation results in a smaller height, we force it to 240px.