Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts How to Show Loading Animation At Set Data

I have highcharts graphics. When I create my page I show empty graphics (I don't set data attribute and there is only titles of graphics, inside of them is empty.) I get data from server asynchronously and call

setData()

function at callback. However user sees an empty page and I want to show a loading image for them. This: http://api.highcharts.com/highcharts#loading doesn't work for me.

Any ideas?

like image 751
kamaci Avatar asked Aug 27 '12 19:08

kamaci


People also ask

How can I tell if Highcharts are loaded?

To determine that chart is fully loaded you can use load event, because load event is invoked when all elements are drown (API reference https://api.highcharts.com/highcharts/chart.events.load). However when you are using series animation this runs in a timeout, then load event is invoked before animation will finish.

How display no data available message in Highcharts?

To show 'no data' message on a pie chart, you need to remove data from a chart. Also, the 'no data' feature requires the file no-data-to-display. js to be loaded in the page. If you want to show some kind of info when data is hidden, you can add custom text with Chart.

What is plot options in Highcharts?

The plotOptions is a wrapper object for config objects for each series type. The config objects for each series can also be overridden for each series item as given in the series array. Configuration options for the series are given in three levels. Options for all series in a chart are given in the plotOptions.

Can Highcharts be used in server?

Traditionally Highcharts or Highstock graphs runs in the browser on the client side. However in some cases it could be preferred to run on the server or in a way interacting with server side applications.


2 Answers

I did it work as explained at given URL:

function updateGraphic(url, chartName) {
    chartName.showLoading();
    $.getJSON(url, function(data){
        chartName.series[0].setData(data);
        chartName.hideLoading();
    });
}
like image 106
kamaci Avatar answered Oct 16 '22 07:10

kamaci


"Loading.." word seems too amateur. Use that trick instead

var chart = new Highcharts.Chart(options);
chart.showLoading('<img src="/images/spinner.gif">');

$.getJSON(url, function(data){
       //load data to chart
       chart.hideLoading();
});
like image 35
Kadir Ercetin Avatar answered Oct 16 '22 07:10

Kadir Ercetin