score:0
use updateChart function and call chart.reflow() inside that function
scope.updatechart = function(){
scope.chart.reflow();
}
call updatechart method every 30 seconds using any refresh mechanism
score:0
I tested it, and it is working very well:
chart-tab is div, and contains high chart div, so you first need to define two DIVs, first for containing the chart('chart-container')
, and second the container of 'chart-container' which is 'chart-tab', then one library must be added('resizesensor')
for adding the event for 'chart-tab' DIV on-change , and here is the function as follows:
new ResizeSensor($('#chart-tab'), function(){ if(chart){ var wid = document.getElementById('chart-tab').clientWidth; var hei = document.getElementById('chart-tab').clientWidth; chart.update({ chart: { width: wid, height: hei } }); } });
score:0
You can make use of chart.update function from anywhere across your project.
Highcharts.charts.forEach(function (chart) {
chart.update({ chart: { width: some value } }, true, true, true);
})
score:0
In my case it was a loading issue that caused the chart container to be too narrow. If you make use of jQuery then load your chart like this
$(document).ready(function() {
let chart = Highcharts.stockChart('chart-container', {
[...]
}
}
score:0
For me using Angular it was solved by moving setting the option in ngAfterViewInit!
score:2
If you do not provide width
property to the chart, it should automatically get the width of the container.
So just remove the width from the chart and give the container width: 100%
and that should work.
If you want a specific width, just change the container width to a specific size. The chart should still be 100% of that size. JSFiddle
Example:
HTML
<div id="container">
<div id="chart"></div>
</div>
JS
var chart = new Highcharts.Chart({
chart: {
renderTo: 'chart',
margin: 0,
height: 200,
defaultSeriesType: 'areaspline'
},
series: [{
data: [33,4,15,6,7,8, 73,2, 33,4,25],
marker: {
enabled: false
}
}]
});
CSS
#container {
width: 100%;
height: 200px;
}
score:4
The issue with Highcharts already reported here. To handle this we can do something like mentioned above. I was also facing the same problem so I have solved it by using
window.dispatchEvent(new Event('resize'));
after rendering my chart like :
this.chartData={
... //some required data object to render chart
}
Highcharts.stockChart('divContainerID', this.chartData, function (chart) {});
window.dispatchEvent(new Event('resize'));
score:5
Try this :
var height= $("#container").height();
var width= $("#container").width();
var chart = new Highcharts.Chart({
chart: {
renderTo: 'chart',
margin: 0,
width: width,
height: height,
defaultSeriesType: 'areaspline'
},
series: [{
data: [33,4,15,6,7,8, 73,2, 33,4,25],
marker: {
enabled: false
}
}]
});
score:5
just simply add CSS
.highcharts-container{
width: 100% !important;
}
.highcharts-root{
width: 100% !important;
}
score:8
I solved it by
window.dispatchEvent(new Event('resize'));
UPD:
- remove width and height attributes.
- add into .css the following code in order to adjust chart block to 100% of #container:
chart { width: 100%; height: 100%; }
2a. another way is - in case if not possible to define container size during "design" time you can reflow chart after chart load (i.e. call chart.reflow(); ):
chart: {
events: {
load: function(event) {
**event.target.reflow();**
}
}
},
See example http://jsfiddle.net/yfjLce3o/
score:9
Set minPadding
and maxPadding
to 0, see: http://jsfiddle.net/sKV9d/3/
score:17
If you remove the options width: 300, height: 200
like this:
var chart = new Highcharts.Chart({
chart: {
renderTo: 'chart',
margin: 0,
defaultSeriesType: 'areaspline'
},
...
it will fill automatically the container.
score:17
The issue is because of jquery UI. after rendering your chart call this code to reflow the chart. This fixed my problem
chart.reflow();
Source: stackoverflow.com
Related Query
- Highcharts - issue about full chart width
- HighCharts full width issue
- Highcharts legend title border not full width
- Highcharts legend spread out to full width
- Issue with last column width in Highcharts
- Highcharts chart width issue on lazy loading of stylesheet
- Highcharts cloud issue with data source when duplicating chart
- Inconsistent columns width issue in highcharts
- Highcharts v7.1.2 width scaling issue when using css transform scale
- Highcharts error 19 issue when adjusting container width that chart displays in
- Highcharts width exceeds container div on first load
- Maximum bar width in Highcharts column charts
- Styling bar colors in Highcharts with a gradient issue
- Fixed y-axis label width in Highcharts
- jQuery UI Tabs and Highcharts display/rendering issue
- Highcharts data series issue with ajax/json and PHP
- Highcharts Solid Gauge Width
- Highcharts Pie Chart ignores percentageDecimals tooltip setting and has floating point inaccuracy issue
- set width of chart, highcharts
- Get Highcharts width
- Highcharts - HTML tooltip & datalabels render issue
- Library duplication issue using Highcharts in Jaspersoft Studio
- Stop HighCharts increasing width of line on hover
- Highcharts multi y-axis min-max issue
- Column width in Highcharts when combined with spline
- Highcharts - Issue with negative values when displaying multiple axes
- highcharts and canvg scaling issue
- Issue Dynamically Changing HighCharts Chart Title
- Highcharts spans beyond bootstrap column width when implemented as an angular directive
- Highcharts + Bootstrap .table-responsive issue
More Query from same tag
- how to add custom button on highstock/highcharts on subplot/addAxis
- On click, passing a variable from Javascript into Rails/Ruby
- Hightcharts Packed Buble chartt for angular 6
- Highcharts drilldown chart: Display/Hide Plot Bands and Lines on drilldown or drillup
- How to generate two heatmap on same scale?
- How to use a variable as js code?
- high chart with large variates data and dynamically create y axis
- HIGHCHARTS - Value of Columns Based on previous Column Value
- Highcharts with Icon Markers Plugin isn't rendering FontAwesome points
- How to change the color of marker-points dynamically based on y-position
- How to convert datetime to epoch time in milliseconds javascript
- How to create data in Json format for highcharts
- How make to fill space after column was hidden in column chart using highchart?
- Revert theme to default
- how to parse json into highcharts
- Highcharts Pie Charts Show Outline When Empty
- Plotbands in Highcharter - When x axis is date
- Highchart Vue - How includes momentjs?
- Highcharts: backgroundColour "layers"?
- Loading JQuery dynamically but highcharts fails
- highcharts xAxis density
- count the points in a group - Highcharts
- Technique to use to reduce the number of javascript lines to write
- Need to link URL in HighChart
- How to place tooltip above point in highcharts x-range?
- Turn series and plot bands on/off using API
- Draw multiple series in Highchart from single JSON data container
- How to show count of data in pie-chart in chartkick rails
- Y axis does not disappear after setting extremes
- Highcharts - Using a function to change the tooltip