Static Highcharts graphic with external csv data and dynamic footnote

给你一囗甜甜゛ 提交于 2021-01-07 02:17:34

问题


I have a highcharts graphic, which consists of a static javascript code and external dynamic csv data. (The external CSV data is updated daily, the Javascript code remains unchanged). Now I would like to add a footnote, e.g. using "caption", which should also be dynamic. How can I make the footer dynamic?

The jsfiddle example is here: https://jsfiddle.net/martindfurrer/kx5ebgny/

caption: {
   text: 'The Javascript code is static, the data is in a csv file. This text 
      should also be dynamic, i.e. should be read out of the csv file.'
}

回答1:


You get csv data in load event and update your chart with a formatted resposne, for example:

    chart: {
        events: {
            load: function() {
                fetch('https://demo-live-data.highcharts.com/vs-load.csv')
                    .then(response => response.text())
                    .then(data => {
                        this.update({
                            caption: {
                                text: data
                            }
                        });
                    });
            }
        }
    }

Live demo: jsfiddle

API Reference: api.highcharts.com



来源:https://stackoverflow.com/questions/64991611/static-highcharts-graphic-with-external-csv-data-and-dynamic-footnote

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!