How to set chart fixed height?
See original GitHub issueI want to make a fixed height bar chart .
This is the code :
<template>
<h2>Bar Chart</h2>
<div style="height: 700px">
<vue3-chart-js v-bind="{ ...barChart }" />
</div>
</template>
<script>
import Vue3ChartJs from "@j-t-mcc/vue3-chartjs";
export default {
name: "App",
components: {
Vue3ChartJs,
},
setup() {
const barChart = {
type: "bar",
options: {
min: 0,
max: 100,
responsive: true,
plugins: {
legend: {
position: "top",
},
},
scales: {
y: {
min: -100,
max: 100,
ticks: {
callback: function (value) {
return `${value}%`;
},
},
},
},
},
data: {
labels: ["VueJs", "EmberJs", "ReactJs", "AngularJs"],
datasets: [
{
label: "My First Dataset",
backgroundColor: ["#1abc9c", "#f1c40f", "#2980b9", "#34495e"],
data: [40, 20, 50, 10],
},
{
label: "My Second Dataset",
backgroundColor: ["#2ecc71", "#e67e22", "#9b59b6", "#bdc3c7"],
data: [-40, -20, -10, -10],
},
],
},
};
return {
barChart,
};
},
};
</script>
I already try to set the height to 700px
<div style="height: 700px">
<vue3-chart-js v-bind="{ ...barChart }" />
</div>
But it’s not working, chart height doesn’t change at all.
How to set bar chart fixed height?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Set height of chart in Chart.js - javascript - Stack Overflow
I created a container and set it the desired height of the view port (depending on the number of charts or chart specific...
Read more >Is it possible to make charts a fixed height? #3384 - GitHub
To get a fixed height and variable width chart… remove width or height attributes from the canvas element. set the desired css height...
Read more >Chart.js chart with fixed height and variable width - CodePen
Chart.js chart with fixed height and variable width. Adjust the width of the window to test.
Read more >How to Set Dynamic Height for Bar Chart in Chart js - YouTube
How to Set Dynamic Height for Bar Chart in Chart jsIn this video we will cover how to set dynamic height for bar...
Read more >Responsive Charts - Chart.js
When it comes to changing the chart size based on the window size, a major limitation is that the canvas render size (...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, pretty busy these days.
I have added fixed
width
andheight
properties. They must be used withoptions.responsive: false
If you are using responsive charts and you want your chart to conform to the parent container dimensions you can try using
options.maintainAspectRatio: false,
@J-T-McC thank you very much for your help, it’s working now.