How to update line chart with multiple datasets #9993
Unanswered
unluckychild
asked this question in
Q&A
Replies: 1 comment
-
would appreciate some helps here |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Im trying to generate the graph, then on select change get the data for the graph. I could do this fine for bar, pie graphs, but im stuck with line chart because of its multiple datasets. Help me out pls.
`
function cline() {
var e = document.getElementById("lines").value;
var json_url = "pages/graph.php?chart=line&q=" + e;
var data = data || {};
$.getJSON(json_url, data).done(function(response) {
line.data.labels = response.labels;
line.data.datasets.label = response.datasets.label;
line.data.datasets.data = response.datasets.data;
line.update();
});
}
`
data:
{ "labels": ["101/2021","111/2021","121/2021"], "datasets": [ { "label":"papers", "data": [ 3300,4820,1150 ] , }, { "label":"papers A", "data": [ 20,190 ] , }, { "label":"Papers B", "data": [ 2200,3470,1800 ] , }, { "label":"Papers C", "data": [ 990,2000,800 ] , }, ] }
Beta Was this translation helpful? Give feedback.
All reactions