hmmftg commented on issue #10848:
URL: https://github.com/apache/echarts/issues/10848#issuecomment-1968511699

   Hi, I have the same issue and resolved it with adding new handler metric at 
backend and this setInterval function(Hope this helps someone):
   
   ```js
   setInterval(function() {
        fetch(
                '/metrics?metricName',
                {
                        method: 'GET',
                        headers: {
                                'X-RapidAPI-Key': 
'************************************',
                                'X-RapidAPI-Host': 
'weatherbit-v1-mashape.p.rapidapi.com'
                        }
                }
        )
        .then(response => response.json())
        .then(response => {
                const gChart = myChartInstance;
                var options = gChart.getOption();
   
                for (var seri in response) {
                        appendToSeries(options, seri, response);
                }
   
                gChart.setOption(options);
        })
        .catch(err => console.error(err))
   }, 2000);
   function appendToSeries(options, id, response) {
        const value = response[id];
        var seriesData = options.series.find(seri=>(seri.name == 
value.name.split("#")[0])).data;
                         // remove data after 240 nodes
        if(seriesData.length>240){
                seriesData.shift();
        }
        seriesData.push(value);
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to