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 shows old chart data when hover
- how to create multiple chart on one component vue
- Using CHARTJS with a JavaScript Array
- break y axis in line chart chart.js
- Can I make Y axis begin at specific value in ChartJS?
- Angular 5, Chart.js displaying multiple charts, one on each tab
- chart js (version 2) bar chart superimpose one data set onto another
- How to make labels on both side from horizontal bar chart js
- Chart.js click event to open a custom tooltip does not work sometimes
- Chart.js dynamically upating data using variable
- Animated Word Web in Javascript
- How can I draw a line to the highest datapoint in chart js?
- Chart.js How to get min-max values of X axis?
- Chart.js and Angular 8 - Dynamically updating Chart.js labels and data from *ngfor
- Chart.js - Multiple Doughnut Charts on same Canvas
- Chart.js - Getting data from HTML
- Chart.js two categorical scales
- chart js date range picker apply function
- ChartJS chart is bugged after adding new data
- Background color of the graph affects the other graphs too
- How do you add custom text to tooltips in charts.js
- How to generate color code dynamically by swapping 2 characters within a string using PHP
- Missing Tooltip for some data points using chartjs
- How to move labels' position on Chart.js pie
- How to change the angle of x axis ticks dynamically based on size of name?
- How to add a vertical line on Chart.js when hover a point?
- Chartjs: dynamic data (array) not working
- How to make data always visible on bars Chart.js
- The engine “node” is incompatible with this module when installing React-chartjs-2 Chart.js,
- Chartjs - Doughnut chart with multi layer and running value