Hello I have a problem with highstocks when using jquery tabs.
this is the code for the constructor.
Chart = new Highcharts.StockChart({
Chart = new Highcharts.StockChart({
chart: {
renderTo:
'Container',
alignticks:false
},
xAxis: { .......... },
yAxis: [{ ....... }],
series : [{ .......... }]
});
The Container has only half the width of the whole page.
When the page is loaded to the tab containing the graph, then its width is rendered correctly. But when the page is loaded first to another tab, then its width spans the whole width of the page, overlapping with other things on the page. So the page has to be refreshed in order to fix this.
Does anyone have a solution to this?
You could also trigger the window.resize Event
$(window).trigger('resize');
And Highcharts should update the Chart size
Highcharts sets the width of the chart to the width of the containing element. So if the containing element is hidden, it can't get a width.
To fix this you can set the width option when initializing your chart:
Chart = new Highcharts.StockChart({
Chart = new Highcharts.StockChart({
chart: {
renderTo: ...,
width: <SOME WIDTH>
},
xAxis: { .......... },
yAxis: [{ ....... }],
series : [{ .......... }]
});
If you aren't able to set the chart to a proper width I've used this trick to be able to get the width of a hidden element:
jQuery: Get height of hidden element in jQuery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With