Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
Remove padding from chartjs bar chart canvas

I want to create a single stacked bar chart with Chart.js that shows how close someone is to a certain amount of money. To define this amount I put a dotted line on top of the chart.

The problem is however that the canvas of this chart has some unwanted padding. So the line spills over outside of the chart. How can I remove this padding on the left and right side?

I tried with negative padding as suggested in another post, but this doesn't remove the padding.

const options = {
    layout: {
      padding: -40,
    },
  };

Code sandbox: https://codesandbox.io/s/romantic-paper-kfu6o7?file=/src/App.js

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try setting barPercentage & categoryPercentage values to 1 inside options like below. Here is updated Code sandbox https://codesandbox.io/s/winter-wind-xdcuxu?file=/src/App.js

const options = {
    barPercentage: 1,
    categoryPercentage: 1
   
    // Your existing properties
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!