Chartjs-How to remove left and right padding from the canvas/chart?

1👍

One solution would be to use a second container.

The canvas seems to resize based on its parent width.

<body>
  <div class="container">
    <div class="canvas-container">
      <canvas id="chartJSContainer" width="500" height="200"></canvas>
    </div>
  </div>
</body>
* {
  padding: 0;
  margin: 0;
}

body {
  background-color: #1c2128;
}

.container {
  width: 490px;
  overflow: hidden;
  margin: 20px auto;
}

.canvas-container {
  width: 500px;
  background-color: #ffffff;
  height: 200px;
  margin-left: -5px;
}

Leave a comment