score:2
Accepted answer
you can scale the height of the second chart to match the ratio of the # of elements in the two charts.
chart.js requires a container around the canvas to allow dynamic resizing so you'll need to add that to the html also.
i needed to set maintainaspectratio: false
for this to work
// scale second chart based on ratio of data to the first
var fiddlefactor = 1.05; // determined by guesswork. basic ratio is slightly off.
var ratio = data2.labels.length * fiddlefactor / data1.labels.length;
var container1height = parseint(document.getelementbyid("container1").style.height);
// update height of second chart
document.getelementbyid("container2").style.height = container1height * ratio + 'px';
<div id="container1" class="chart-container" style="position: relative; height:300px;">
<canvas id="mychart"></canvas>
</div>
<div id="container2" class="chart-container" style="position: relative; height:300px;">
<canvas id="mychart2"></canvas>
</div>
Source: stackoverflow.com
Related Query
- How to retain spacing between bars for two different bar charts in Chart.js 2
- ng2 charts bar chart need spacing between 2 bars in series Angular
- How to map json array to two different array for chart
- How to show different product name for every bar in chart js
- How do I get a different label for each bar in a bar chart in ChartJS?
- How can I reduce the spacing between my legend and chart proper in my Chart.JS bar chart, and increase it in the graph area?
- Reduce spacing between bars in horizontal bar chart (chart.js)
- How to reduce the gap between bars on bar chart
- Chart.js Bar Chart: How to remove space between the bars in v2.3?
- How to create rounded bars for Bar Chart.js v2?
- Chart.js Bar Chart - how to chart bars from 0
- How to add second Y-axis for Bar and Line chart in Chart.js?
- Different color for each column in angular-chartjs bar chart
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How to have solid colored bars in angular-chart bar chart
- PrimeNg bar chart how to show a label for the y-axis
- How to make bar chart animation where all bars grow at the same speed?
- chart js data-point between bar charts
- How to remove bars for those bars with zero value in Chartjs bar chart?
- Vue ChartKick - different colours for bar chart
- how to customize tool tip while mouse go over bars on Chart js bar chart
- Chart.js: How to get x-axis labels to show on top of bars in bar chart
- How to use set the color for each bar in a bar chart using chartjs?
- How can I have different values for the chart and the tooltip in chart.js?
- How to draw baseline for bar chart in chart.js
- Mixed Chart calculating difference between two bars - ChartJS
- Charts.js - Bar chart different colors for value intervals not working
- How to set X coordinate for each bar with react chart js 2?
- Issue with chartjs linear gradient for the mixed bar chart in ReactJS is not calculated for each individual Bars
- How to create spacing between Charts and Legends in Chart.js
More Query from same tag
- How to set data values as labels in Chart.js with a Radar Chart
- Chart.js legend style
- chart.js different x axis and tooltip format
- How do I change the colour of a Chart.js line when drawn above/below an arbitary value?
- How to implement concentric doughnut charts in polymer 1.0 using Chart.js?
- How do I change pointBackgroundColor in Line segment on ChartJS?
- Change label color over a specific value in Chart.js
- Chart.js / HTML Canvas - move line
- Need to update tool tip value based on drop down filter after ajax call
- How to draw High-Precision-Numbers in chartjs
- Adding vertical and horizontal scroll to Chart js Bar graph
- How do I get the current step size of a chartjs chart whose stepSize I have not defined?
- How to I optimise these javscript options which is used multiple times on different chart.js graphs?
- ChartJs resizing when parent div is resized
- chartJS generateLegend()
- My canvas/graph jumps to left after creating the object
- How can I draw a line to the highest datapoint in chart js?
- Chart JS Displays Only Bigger Dataset But Has Both Datasets?
- Loop datasets into chart.js?
- How to json_encode associative php array to [{x: key1, y: value1}, {x: key2, y: value2}, ...]?
- 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
- Chart JS ShowChart()bar" is not a chart type error
- Is it possible to display values where the display ends instead of on top of the points with chartjs?
- How to change X-axis interval in chart.js
- How to scale label size radar chart chart.js
- chartjs-plugin-zoom not working with my React project
- ChartJS - Graphic with multiple values on the same date
- How to have custom colors in ng2-charts and chart.js according to data?
- ChartJs error in displaying my array data
- Bar Chart in Angular JS Using Chartjs