chartist
chartist copied to clipboard
Snippest for - how to change/update the chart data
It took me something like 3 hours(started to work on it at 22:00 and finished at 01:30). My problem was that I need to pull/change data from an http request. I tried all the combination I can think of but managed to scrape something:
axios({
'method': 'get',
'url': API_ADDRESS
}).then(response => {
let items = []
response.data.data.forEach(item => {
// item['unumber'] is 1,489.49
items.push(parseFloat(item['unumber'].replace(",", "")))
})
// This is a line chat.
document.querySelector('.ct-chart').__chartist__.update({'series': [items]})
})
Now, I did not see any cookbook or snippets, and the documentation about it is pretty dimmed on how to update so... if there's any place I can add it I'll create a P.
Hello @RoySegall 👋
Chartist has recently been updated to version 1.0
with some new exciting changes like ESM and TypeScript support. The migration guide can be found right here.
Please let me know if the question is still relevant to you so we can further look into it!