How to remove padding or margins from Google Charts with JavaScript?

Spread the love

Sometimes, we want to remove padding or margins from Google Charts with JavaScript.

In this article, we’ll look at how to remove padding or margins from Google Charts with JavaScript.

How to remove padding or margins from Google Charts with JavaScript?

To remove padding or margins from Google Charts with JavaScript,, we set the chart width and height.

For instance, we write

const options = {
  title: "How Much Pizza I Ate Last Night",
  width: 350,
  height: 400,
  chartArea: { width: "100%", height: "80%" },
  legend: { position: "bottom" },
};

const data = new google.visualization.DataTable();

//...
const chart = new google.visualization.PieChart(
  document.getElementById("chart_div")
);
chart.draw(data, options);

to set the width to '100% ' to make the chart fill the full width.

Conclusion

To remove padding or margins from Google Charts with JavaScript,, we set the chart width and height.

Leave a Reply

Your email address will not be published.