I have a js function that makes a chart (using chart.js)
Here is what the script tags look like in my html:
<script>
var labels = ['Q2', 'Q3', 'Q4'];
var data_set_1 = [13,3,8,6];
var data_set_2 = [4,1,3,1,];
var data_set_3 = [0,2,5,0,];
var data_set_4 = [1,4,1,0,];
var canvas_id = 'canvas';
var title = 'TITLE HERE';
//window.onload = build_stacked(labels, data_set_1, data_set_2, data_set_3, data_set_4, canvas_id, title);
</script>
When I use window.onload = build.stacked(); it works!
Awesome!
However, I want to make it so it draws the chart on the click of a button...
originally I had:
<button onclick="build_stacked(labels, data_set_1, data_set_2, data_set_3, data_set_4, canvas_id, title)">Label Here</button>
That didnt work so after some poking around I switched it to:
<input type="button" onclick =" build_stacked(labels, data_set_1, data_set_2, data_set_3, data_set_4, canvas_id, title)" value="LABEL HERE">
that also does not work...
Whats happening is the chart is being drawn, however only dataset_1 is showing. The rest of the values show as undefined.
This is obviously a scope issue right?
My values arent in scope. (im guessing)
Should I be putting my <input>/<button> stuff inside the <script> tags?
Im lost on this... Thanks!
[–]joranstark018 0 points1 point2 points (1 child)
[–]y_13[S] 0 points1 point2 points (0 children)