score:0
Why are you loading highcharts with each span? You only need to load it once when the document loads.
Highcharts does not need to load each time a chart is refreshed...it's already there.
All you need to do to refresh individual charts via ajax is return a json object of the data for that chart, and re initialize the chart with the existing options that were set when the page loaded.
score:2
Assuming you have control over the HTML you're rendering, you need to do either;
- Place highcharts (and other scripts) as a dependency in the page container so that you're sure it loads only once.
- Conditionally load HighCharts dynamically rather than statically.
Eg something like this;
function buildChart(func) {
if (window.Highcharts === undefined) {
console.log("Highcharts is not loaded, fetching...");
$.getScript("http://code.highcharts.com/highcharts.js", function () {
alert("HighCharts was loaded");
func(); // build chart
});
}
else {
console.log("HighCharts was already loaded");
func(); // build chart
}
}
// test
buildChart(function () {
// build chart
console.log("Read to build chart with:", window.Highcharts);
})
However, this simple example doesn't cater for concurrent requests whilst highcharts is still being loaded. So for conditional loading like this, I would look into using a library like RequireJS, YepNope or HeadJS which can handle these dependencies for you. You are then able to include the HighCharts script in your components as often as you like and they'll only be loaded once.
Source: stackoverflow.com
Related Query
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- Highcharts display label for pie chart using html table as data source
- HTML table as data source for highstock charts using highcharts
- Using a flask variable as data source for highcharts
- How to create a column range chart in Highcharts using range and navigator functions?
- Rendering Highcharts using Angular js Directives
- How to display the value instead of percentage in a pie chart using jquery Highcharts
- Hiding a Highcharts series without using the legend
- Loading Highcharts via shim using RequireJS and maintaining jQuery dependency
- SyntaxError: JSON.parse: expected property name or '}' while using highcharts
- How do I dynamically change a data point in Highcharts using JavaScript
- Type 'number[]' has no properties in common with type 'XrangePointOptionsObject' in Angular8 using Highcharts
- Getting error while using highcharts in Angular 7
- Javascript Highcharts v3.0.5 - How to hide Y Axis Title when using multiple Y Axis
- JavaScript error when using Highcharts
- Using HighCharts with Backbone
- Using html2canvas to render a highcharts chart to pdf doesn't work on IE and Firefox
- Scraping data from Highcharts using selenium
- Using a fill pattern instead of colour with HighCharts
- Resize highcharts using react-grid-layout not working
- Selecting a point by ID using Highcharts
- Show specific series values in the stack label using highcharts
- Using Highcharts and displaying a message over or on the chart when there is no data
- Library duplication issue using Highcharts in Jaspersoft Studio
- getting error#17 from highcharts while using solid gauge from backbone rails
- Using HighCharts and DotNet.HighCharts to "Play" Multiple Series
- create a sticky tooltip for a point or a permanent label using HighCharts
- Loading Highcharts series from XML using jQuery
- Formatting JSON data monthwise for HighCharts using MySQL
- Not rendering VU-meter Gauge chart using HighCharts in Durandal
More Query from same tag
- Highstock - zoom all by function
- How can I change the text of the back button on this dropdown pie chart?
- Highcharts Stacked Area Data
- How to show multiple pie charts using highcharts
- Highcharts: Change color of Pie Chart section without slice animation
- highcharts, bar chart legend with verticalAlign top not working
- HighCharts not plotting decimal values in x-axis
- How to achieve the best possible performance with mutable data and real-time charts in React?
- responsive highcharts with dynamic font size and widths
- Content besides tooltip are visible
- highchart click event Brakedown browser in iphone
- How to change the scale of an axis with HighChart
- Gradient fill for guage - Highcharts
- Highcharts problem with decimals if there are many data points
- Highcharter - move data label to top of column
- Highcharts plotBand animation
- Show specific data in the highchart's title
- Accessing another list in the dataLabels.formatter function in Highcharts
- How to hide "showInLegend" of Highcharts in angular 8.1?
- Highcharts.js column chart labels and data not displaying properly after 60 columns
- use on click for pie react-highcharts without overriding default onclick function
- Highcharts tooltips with all items in category listed
- How to pass this three inputs (lineEdit, startDate, endDate) to my function (graphdata)
- Angular Highcharts dynamic import produces no additional chunk
- Highcharts - series.remove(); 4 series in chart, only 2 removed
- Highcharts: Decide on charts placement after generation
- Chart rendering issue with resizing <div> container
- How to plot stacked bar chart in highcharts with dynamic data?
- How can I limit the length of a HighCharts PlotLine on the Y-Axis for a BoxPlot?
- Highcharts Toggle Stacking for Multi-Axis Chart