score:2
Accepted answer
You can use chart.update()
method to add a new height based on bars amount. Check code and demo posted below.
Code:
Highcharts.chart('container', {
chart: {
type: 'bar',
events: {
load: function() {
var chart = this,
barsLength = chart.series[0].data.length;
chart.update({
chart: {
height: 100 + 50 * barsLength
}
}, true, false, false);
}
}
},
title: {
text: 'Historic World Population by Region'
},
subtitle: {
text: 'Source: <a href="https://en.wikipedia.org/wiki/World_population">Wikipedia.org</a>'
},
xAxis: {
categories: ['Asia'],
title: {
text: null
}
},
yAxis: {
visible: false
},
tooltip: {
valueSuffix: ' millions'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
},
pointPadding: 0,
groupPadding: 0,
borderWidth: 0,
pointWidth: 20
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
name: 'Year 1800',
data: [107]
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<div id="container"></div>
Demo:
API reference:
Source: stackoverflow.com
Related Query
- How to resize bar chart based on no of x axis categories in HighCharts
- Highcharts - Column Chart Drilldown, how to change the drilldown bar color based on some value
- How do I rotate my HighCharts bar chart so its vertical, not horizontal?
- How to add space between chart and axis in highcharts
- Highcharts Bar Chart - How to set the minimum bar width/length
- Highcharts - Bar - Setting the X axis width and the chart area width to be constant
- Highcharts Change Bar Background Color Based on categories value
- How to place x axis labels on top of horizontal bar chart
- HighCharts - Show categories in x axis intead of the value of x in Bubble Chart
- How to add a horizontal line in Column bar chart in Highcharts plugin?
- How can I add a Bar Chart to my Django based Database?
- How to Make a Dashed Bar Chart Border in Highcharts
- Highcharts - How to force line chart to be visible above X Axis
- How to change color of bar in column chart with different level of percentage in highcharts
- How to remove decimal values on x-axis of bar chart : Highcharts
- How to make split grouped column bar chart in highcharts with percentage?
- Highcharts - Bar chart show full label on Y Axis
- highcharts how to make x and y axis starting on the same zero using categories on yAxis
- How can i load external json data in highcharts to show the bar chart
- How can I prepare a Group Stacked Bar Chart in Highcharts using multiple and different types of data?
- How to make a HighCharts drilldown column/bar chart that does not hide the non-drilldown categories
- highcharts donut pie - How to calculate pie size percentages after resize the chart
- HighCharts basic bar chart provide the xAxis categories with Series
- Highcharts Chart Bar - How can I display in the chart, only one column from my HTML table?
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- How to create a legend for bar colors in a Highcharts bar chart
- How to render a bar chart with different series with only one entry per category in HighCharts
- Highlight the corresponding y axis on mouse overr over the bar chart based on that axis in highchart
- HighCharts how to use different plotOptions per yAxis in a multiple axis chart
- highcharts - How do I show/hide secondary y axis based on optional parameter
More Query from same tag
- How to make highchart points redirect to another component with value in React?
- Highcharts, ROR, how to get labels working
- How to customize the polar chart in this way?
- Removing the circle around a spiderweb chart in Highcahrts
- No output while reading json file in Highcharts
- How to make highchart from view table in Yii2?
- Display year in x axis of line graph highcharts
- Highcharts Windbarb with ajax data loading
- How can I install highcharts-angular *and* highcharts?
- jQuery Highcharts not working with JSF 2.0
- Highcharts - SetState (inactive) not working after redraw
- How do I hide the code for the chart data in highcharts?
- Highchart how to animate from the xaxis bottom line upward
- HighCharts/Javascript: Resample Monthly Data Series to Quarterly/Yearly?
- HighCharts to support RTL
- Highcharts Transition from Column to Spiderweb
- Internet Explorer 9-11 does not fill g element with color (highcharts)
- Highcharts - Series tooltip doesn't work when plotting lines that zigzag on the x axis
- Using chart.update on a chart using renderTo
- "TypeError: c.slice is not a function" when trying to call a function within JQuery
- Hightcharts: Set series label in last point
- Tool tip for static plotline in y-axis
- Production build issue with ChartModule in angular 2
- Changing yAxis and plotOptions for drilldown
- Highcharts issue with multiple X axes
- Viewing IP in highcharts
- javascript for loop through nested json values
- highmap does not display
- in high charts unable to set y axis to 100
- Highcharts shared tooltip making a percentage difference between series