question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add padding to chart

See original GitHub issue

Hi guys

I’m trying to add a padding in the chart. I changed the global config like mentioned in #44 in my component file but still not working.

import { Pie, defaults } from 'react-chartjs-2';
import { merge } from 'lodash';

merge(defaults, {
  global: {
    layout: {
      padding: 25,
    },
  },
});

...
<Pie data={ chartData } options={ chartOptions } height={ 300 } />

I printed the object defaults and the property is changed there, but my charts still look the same thing.

Can anyone help me with this, please? I didn’t figure out what is going wrong Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
jerairrestcommented, Dec 20, 2016

Wait… wait… I lied. Apparently I need more coffee 😃

1reaction
jerairrestcommented, Jan 18, 2017

Just getting back into things here: I was able add padding by simply passing the following in without actually merging the default values.

const options = {
  layout: {
    padding: {
      left: 150,
      right: 150,
      top: 150,
      bottom: 150,
    },
  }
}

Does that work for you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Padding
Let's say you wanted to add 50px of padding to the left side of the chart canvas, you would do: let chart =...
Read more >
chartjs - top and bottom padding of a chart area
There are a few ways to control padding between scales/legends in chart.js (some official ways documented in the docs and some "hacky" ways ......
Read more >
padding - Sets Padding For Chart Title
This property allows you to set the padding for Chart Title. ... Padding can also be an object containing top, right, bottom and...
Read more >
Chart Styling - Margin and Padding
padding property can be used to apply a top, right, bottom, left padding to the chart. This defines the spacing around the viewport...
Read more >
Chart Paddings and Margins
For a line/area chart, canvas padding is the space between the canvas border and the position where the line/area chart begins. Specify the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found