问题
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