Documentation is great for static content, but for remote/ active data I did not figure out how to use methods like update()…
Thanks in advance
Yes, we should add something I guess. Although it's really simple. We can also add an example on how to update dynamically.
http://jsbin.com/wiyolaruka/edit?html,js,console,output
+1 I'm using c3.js now because it supports loading a JSON directly. I think this would be a very valuable feature.
Including such a basic web development task as a shortcut within Chartist is (at least for me) considered as total feature bloat. If you were holding back to use Chartist and all its responsive features just because you'd need to write 4 lines of extra web technology standard code, I really don't understand your reasoning.
fetch('remote/data.json').then(function(response) {
return response.json();
}).then(function(data) {
new Chartist.Line('#chart', data);
});
I fully support adding documentation on how to do this of course!
@gionkunz I think there is a misunderstanding, I'm not suggesting adding a RPC shortcut.
I just can't see in the docs where I can create a chart using JSON. I can see how to use arrays, but not key/value. Am I missing something?
What do you mean by JSON? The data format of Chartist expects a given format which is an object with a labels property that contains an array of labels and a series array that consists of series values arrays. Of course you can also use JSON and parse it to initialize Chartist.
var jsonData = '{"labels":[1,2,3],"series":[[1,2,3]]}';
var data = JSON.parse(jsonData);
var chart = new Chartist.Line('#chart', data);
If you're talking about converting a source data format to Chartist's data format, I suggest you're using some data transformation using Array extra functions.
Just as a suggestion you can look at : http://c3js.org/reference.html#data-json
I'll prefer to use that for now. Thanks.
Closing this issue in favor of #733
Most helpful comment
Including such a basic web development task as a shortcut within Chartist is (at least for me) considered as total feature bloat. If you were holding back to use Chartist and all its responsive features just because you'd need to write 4 lines of extra web technology standard code, I really don't understand your reasoning.