score:18
This is a common issue with highcharts. The best advice I could get is to use window.resize()
after Highcharts is shown, but actually there is an API function in Highcharts called reflow
, that could also help.
The solution is to catch bootstrap modal events and update your Highcharts width in callback of shown.bs.modal event:
var chart = $('#container').highcharts();
$('#chart-modal').on('show.bs.modal', function() {
$('#container').css('visibility', 'hidden');
});
$('#chart-modal').on('shown.bs.modal', function() {
$('#container').css('visibility', 'initial');
chart.reflow();
});
See demo. I use visibility
css property here so Highchart won't bounce. This is not ideal, but better than nothing.
score:-1
$('#J_report_graph').on('shown.bs.modal', function (event) {
$("#J_report_graph_container").highcharts({});
});
$("#J_report_graph").modal();
will work as expected
score:0
Apply this
chart: {
events: {
load: function(chart) {
$timeout(function() {
chart.target.reflow();
);
}
}};
score:0
for responsive highcharts with modal on bootstrap 3 just adding this line code on load page
$('#yourmodal').on('off.bs.modal', function() {
$('#yourselector').css('visibility', 'hidden');
});
$('#yourmodal').on('shown.bs.modal', function() {
$('#yourselector').css('visibility', 'initial');
$('#yourselector').highcharts().reflow();
});
score:2
I tried the accepted solution, but in my case I didn't have an option to use a specific module id that already exist in the html, so solution below didn't work for me.
$('<modal-id>').on('shown.bs.modal', function() {
chart.reflow();
});
What I was trying to do is, dynamically adding a modal to the html as an EmberJS component which only has a specific class.
My solution was this:
App.registerComponentFactory('my-chart', SplineChart.extend({
setup: (function() {
$('body')
.off('shown.bs.modal', '.my-modal')
.on('shown.bs.modal', '.my-modal', () => this.reflow());
}).on('init'),
So each time my chart module is initialized, it binds the event handler to the modal. And the
.off('shown.bs.modal', '.my-modal')
part is also needed for unbinding the handler each time when the modal is triggered, otherwise the reflow function was running successfully only in the first attempt.
This may be useful for similar cases.
Source: stackoverflow.com
Related Query
- Highcharts won't fit in Bootstrap 3 modal body
- Fire a bootstrap modal when i click on a stacked bar of highcharts
- How to expand same chart in the highcharts on bootstrap modal onclick a thumbnail chart in angular 6
- Fire bootstrap modal from a highcharts x axis label?
- Open Highcharts in modal window
- highcharts graphs in bootstrap tabs are not displaying properly
- Highcharts spans beyond bootstrap column width when implemented as an angular directive
- Highcharts + Bootstrap .table-responsive issue
- highcharts polar chart, move labels individually to fit small space
- Use Twitter Bootstrap popover with Highcharts
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- Highcharts - Global configuration with common code and unique data & Headings
- Highcharts content in bootstrap carousel is not auto-resizing to carousel
- Highcharts column tooltip - always on top + fit the container
- HighCharts Stock Chart error code 18
- Fullscreen panel bootstrap with highcharts (responsive)
- highcharts change rendered image source on click
- how to use Bootstrap font icons on x-axis lables in highcharts
- How do i add mouse wheel code in Angular2 highcharts in typescript
- how to display 2 same highcharts without duplicate the code
- Use of DotNet HighCharts dll to make charts in code behind
- Highcharts exporting hide data labels if number doesn't fit in stacked bar
- How to edit tooltip in Highcharts C# code
- what means ${demo.css} in example files of highcharts ? That piece of code seems to be literal
- Using Bootstrap Datepicker with Highcharts
- Is there a way to pass in variable element ID from Highcharts to launch a modal window?
- passing json values to highcharts from .net code behind
- how to use highcharts tooltip formatter in python code
- Highcharts graph width is incorrect when scrollbar is present, in bootstrap fluid span
- making title in highcharts clickable and work with bootstrap popover?
More Query from same tag
- Does toggling in React affect highchart display?
- Highchart , how to remove the margins, inside the chart? Creating a 100% zoom?
- How to localize exported files from Highcharts?
- highcharts minPointLength do not work for unstacked bar chart
- Sort stackbar chart in highchart based on size of each stackbar
- Highcharts with PHP var
- Play Framework: PDF'ing a template that uses highcharts JS library via a Job
- Highcharts: Different tick interval in the same axis
- Accessing the response text for JSONP. Flattening multiple objects to text
- Highcharts series line width is not stable
- Highcharts zones feature for imported text file
- JSON and Highcharts
- I want to add border radius in stack graph in high charts for some particular data
- How to remove text which was added via chart.renderer in Highcharts
- Highcharts plot markers move behind spline graph animation
- Javascript Code not running in Wordpress Pages
- Highcharts: xAxis yearly labels centered between ticks
- Highchart plugin not accepting array for series data?
- Highcharts: Delete legend displayed only on chart and keep bottom legend
- Highcharts shown in multiple divs with the same name
- How to add icon/svg/image on X-axis for bar graph onclick event using highcharts?
- Setting color options on Highchart bar chart
- What kind of charts library is being used on this Huffington Post page?
- States Not Working on Highmaps mappoint click
- Snap to month in highchart stock navigator
- R Highcharter: dynamic drilldown in Shiny on the fly
- Server-side rendering with Highcharts in C#
- Dynamic number of highcharter plots
- Highcharts-vue - Calling my own tooltip label formatter function
- vaadin's Invient chart max data size