Chartjs-Chart.js: How to set minimum height of chart but still maintain aspect ratio?

0👍

Solved it by adding an intermediate div between container and chart:

<div
  style={{
    minHeight: 300,
    paddingTop: "33.33333%",
    position: "relative",
  }}
>
  <div
    style={{
      position: "absolute",
      inset: 0,
    }}
  >
    <Bar
      style={{ width: "100%", height: "100%" }}
      //data={...}
      options={{
        maintainAspectRatio: false,
      }}
    />
  </div>
</div>

Leave a comment