I am trying to use the Chartist.js framework to create charts and graphs for my site. But for some reason I keep getting the error "Chartist is not defined"
I can't figure out how to fix this error. Please see the code below:
<!DOCTYPE html>
<html>
<head>
<script src=".js/latest/chartist.min.js"></script>
<link href="https//cdn.jsdelivr/chartist.js/latest/chartist.min.css" rel="stylesheet" type="text/css" />
<link href=':300' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<title>Chartist.js - Simple line chart</title>
<script>
// THIS IS WHERE THE ERROR OCCURS
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
[2, 3, 2, 4, 5],
[0, 2.5, 3, 2, 3],
[1, 2, 2.5, 3.5, 4]
]
}, {
width: 500,
height: 300
});
</script>
</head>
<body>
<div class="ct-chart"></div>
</body>
</html>
Does anyone know what I am doing wrong? Thanks in advance.
I am trying to use the Chartist.js framework to create charts and graphs for my site. But for some reason I keep getting the error "Chartist is not defined"
I can't figure out how to fix this error. Please see the code below:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr/chartist.js/latest/chartist.min.js"></script>
<link href="https//cdn.jsdelivr/chartist.js/latest/chartist.min.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis./css?family=Oxygen:300' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<title>Chartist.js - Simple line chart</title>
<script>
// THIS IS WHERE THE ERROR OCCURS
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
[2, 3, 2, 4, 5],
[0, 2.5, 3, 2, 3],
[1, 2, 2.5, 3.5, 4]
]
}, {
width: 500,
height: 300
});
</script>
</head>
<body>
<div class="ct-chart"></div>
</body>
</html>
Does anyone know what I am doing wrong? Thanks in advance.
Share Improve this question edited May 26, 2015 at 11:05 Ralt 2,2161 gold badge27 silver badges39 bronze badges asked May 26, 2015 at 10:20 SkywalkerSkywalker 5,20417 gold badges66 silver badges127 bronze badges 1- Did you find my answer helpful? – Vassilis Pits Commented May 26, 2015 at 13:20
1 Answer
Reset to default 7Move your scripts to the footer:
<!DOCTYPE html>
<html>
<head>
<link href="https//cdn.jsdelivr/chartist.js/latest/chartist.min.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis./css?family=Oxygen:300' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<title>Chartist.js - Simple line chart</title>
</head>
<body>
<div class="ct-chart"></div>
<script src="https://cdn.jsdelivr/chartist.js/latest/chartist.min.js"></script>
<script>
// THIS IS WHERE THE ERROR OCCURS
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
[2, 3, 2, 4, 5],
[0, 2.5, 3, 2, 3],
[1, 2, 2.5, 3.5, 4]
]
}, {
width: 500,
height: 300
});
</script>
</body>
</html>
http://plnkr.co/edit/3sAdiBJaaue3x9kgBRZw?p=preview
And it's working like a charm :)