admin 管理员组文章数量: 1086019
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 :)
本文标签: javascriptChartist not defined errorStack Overflow
版权声明:本文标题:javascript - Chartist not defined error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744000745a2516399.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论