how to set this chart width and height ?
See original GitHub issuemy english is very poor ,sorry~
how to set this chart width and height ?
this is my code
// homechart.js
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ["data"],
mounted () {
this.renderChart(this.data, {
})
}
})
my vue app
<template>
<homechart :data='chart'></homechart>
</template>
<script>
import homechart from './homechart'
export default {
components: { homechart },
data() {
return {
chart:{
labels : [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
data : [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1]
}
]
}
}
},
}
</script>
the chart is work , but ,it’s so big, i want set chart width and height.
show me the code , please , think you!
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Setting width and height [closed] - Stack Overflow
Show activity on this post. This works. The key here is to use an outer div and set the width and height on...
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 >Move or resize a chart - Microsoft Support
To use specific height and width measurements, on the Format tab, in the Size group, enter the size in the Height and Width...
Read more >Set Chart Size with ChartJS - Mastering JS
To set the chart size in ChartJS, we recommend using the responsive option, which makes the Chart fill its container.
Read more >Limit the height and width of chart.js - CodePen
<p>Example of chart that will respect it's containers width and height via the property <code>maintainAspectRatio: false</code></p>.
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 FreeTop 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
Top GitHub Comments
Hey,
seems to be related to #8
There are two possibilities. If you want your chart to be responsive, you can wrap your chart into a div that has a max-width (in css) If you want a fixed width and height, you can simply pass it the props.
<my-chart :width="300" :height="300"> </my-chart>
However you will need to set the
repsonsive
property to false. And maybe themaintainAspectRatio
. Both are chartJs options you can pass in the data object.http://www.chartjs.org/docs/#chart-configuration-global-configuration
think you , you are so fast! it’s work now! the code is
and