Roka545 Roka545 - 3 months ago 17
Javascript Question

Chartjs fiddle not working

I'm completely new to JSFiddle. I'm currently trying to get a scatter chart to show up but nothing is displaying. Can anyone point me in the right direction?

Here's the Fiddle: http://jsfiddle.net/roka545/qf8ejytt/

//Get context with jQuery - using jQuery's .get() method.
let canvas = <HTMLCanvasElement>document.getElementById("myChart");
let ctx = canvas.getContext("2d");

let xAxisMin: number = 4;
let xAxisMax: number = 7;

var scatterChart = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
label: 'Scatter Dataset',
data: [{
x: -10,
y: 0
}, {
x: 0,
y: 10
}, {
x: 10,
y: 5
}]
}]
},
options: {
scales: {
xAxes: [{
type: 'linear',
position: 'bottom'
}]
}
}
});

Answer

You need to add a link to the actual source such as:

https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.min.js

In the external resources, then press plus button.

See here:

http://jsfiddle.net/r7ahsn15/