score:11
Accepted answer
For rectangular shaped graphs (line, bar) you can include a width
and height
tag in the html:
<canvas baseChart width="2" height="1"
[datasets]="chartData"
[labels]="chartLabels"
[options]="chartOptions"
[colors]="chartColors"
[legend]=true
chartType=line></canvas>
The width and height set the aspect ratio, not the actual size.
You can do this for square shaped graphs (donut, radar, pie, polar), but it doesn't make as much sense. It will keep a square shape, but with bigger padding on the sides or top and bottom.
Instead, you can set the exact size you want on a div
containing the chart:
<div style="display: block; width: 200px; height: 200px;">
<canvas baseChart
[data]="doughnutChartData"
[labels]="doughnutChartLabels"
[chartType]="doughnutChartType"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)"></canvas>
</div>
Source: stackoverflow.com
Related Query
- Resize the width and height of the ng2-charts
- How to get the actual chart width and height in chart.js
- Chart.js, increase space between bars and its labels when increasing the charts width
- The dataset for bar graph is not set properly using ng2 charts and ng5-slider in Angular
- How to shrink the height and increase the line width of a custom Chartjs horizontal line?
- How do I make many ChartJS charts on the same page to have the same height and also even column width?
- Setting width and height
- Changing width and height in angular-chart.js module
- Chart.js: width and height of a pie chart not respected
- How do I keep chart.js charts in one JS file, and not get errors when the ID from the JS file don't exist on one specific html page?
- Width and Height in Chart.js
- How to achieve the best possible performance with mutable data and real-time charts in React?
- React chart : prevent chart's canvas scaling with height and width
- Why would a ChartJS chart end up with width 0 and height 0?
- Keep chart.js doughnut with fixed width and height centered in container
- Setting Common labels and background color common for all the charts in ChartJs
- canvas does not display proper width and height chart.js
- I can not properly re scale <canvas> with width and height attributes
- How to style a pie chart in chart js? I want to change the border color, border width and give them shadow
- Unable to set width and height on canvas in chart js
- When I added a funnel chart to chartjs all the charts are load compressed until resize page
- How to set responsive width and height of canvas?
- Charts js - How to make gridlines dash and How to make the gridlines stop at each point
- How to add left padding for my charts done in ChartJs and my Google Map so it is not glued to the limit of the page on the left
- Customise size of data points , height and width in Chart.js?
- Flickering of charts and getcontext error with chartjs in the context of Vuejs
- Html canvas element resets width and height to zero after drag/drop
- How can I move chartJs legend left side and change the width and Hight of the chart?
- How do i have a single Chart.vue component instead of different chart components and then display charts from it by changing id of the API
- attempting to change height and width of canvas for chart
More Query from same tag
- Chart.JS - Wrong Y axis
- Setting ChartJS plugin on vue-chartjs not working
- Typescript types for chartjs-adapter-date-fns
- ng2-charts: How to set Title of chart dynamically in typescript
- Chart.js different y axis depending on graph from select options
- Chart.js reduce canvas size without changing the size of the chart
- Remove bullet points from chart.js legend
- Tool tip not showing for those label who's data overlapped on each other in chart.js
- I'm trying to get data from flask app but I get this "Uncaught ReferenceError: _data is not defined"
- Make chartjs re-render once
- Mixed chart barchart won't show
- Get Dataset Values from Chart JS onHover in Version 3
- How to show lables just outside the the doughnut chart in Chartjs?
- Charts.js line chart, how to hide y-axis start and end label if data is same
- Moving vertical line when hovering over the chart using chart.js
- Which Property do I need to edit, to change following Color?
- ChartJS 3.7.1 tooltip callback, get label value for the next index
- How to update chart.js chart with new data?
- Secondary bar with chart.js
- Is there a way to draw floating rectangle using chart.js
- Getting access to already created Chart.js chart
- Stacked line chart not displaying correctly when Xaxis is time
- Create charts with a loop in Django with charts.js
- How can I change color of only one column in Barchart using Chart.js
- Chart.JS - Couldn't add the margin/spacing between Y-axis labels
- Stacked horizontal bar chart along total count with chart.js
- How to put arguments in a jchart.Chart class
- How to chart detected activities on the hour using Chart.js
- How to fix chart not starting at zero
- Change position of Chart.js tick labels