我只是尝试使用RGraph生成一个图表,这样我就可以开始使用SQL来操作图形了。然而,我遇到的问题是,它根本没有显示基本的图形。有人知道我哪里出问题了吗?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Charts</title>
<script src="JAVASCRIPT/RGraph.common.core.js"></script>
<script src="JAVASCRIPT/RGraph.bar.js"></script>
</head>
<body>
<canvas id="cvs1" width="600" height="250">[No canvas support]</canvas>
<script>
window.onload = function ()
{
var bar = new RGraph.Bar({
id:'cvs1',
data: [4,5,3,8,4,9,6,5,3],
options: {
backgroundGridDashed: true,
labels: ['Mal', 'Barry', 'Gary', 'Neil', 'Kim', 'Pete', 'Lou', 'Fred', 'Jobe'],
title: 'A dashed background grid',
strokestyle: 'rgba(0,0,0,0)',
textAccessible: true
}
}).draw();
};
</script>
</body>
</html>浏览器错误
Uncaught :无法读取属性'getContext‘的null RGraph.Bar @ RGraph.bar.js:28 window.onload @ Charts.php:17
发布于 2016-09-16 16:21:13
我测试了你的代码。它没有什么问题,但它似乎非常依赖于您正在使用的RGraph版本。尝试下载RGraph的最新版本并将“库”下的内容(或者仅仅是您需要的两个文件)解压缩到'JAVASCRIPT‘文件夹中。
发布于 2021-01-26 15:36:45
下面是一些更新的代码(在被问到之后,有几个属性名称发生了变化)。
bar = new RGraph.Bar({
id:'cvs1',
data: [4,5,3,8,4,9,6,5,3],
options: {
backgroundGridDashed: true,
xaxisLabels: ['Mal', 'Barry', 'Gary', 'Neil', 'Kim', 'Pete', 'Lou', 'Fred', 'Jobe'],
title: 'A dashed background grid',
colorsStroke: 'transparent'
// textAccessible: true // Defaults to true anyway
}
}).draw();https://stackoverflow.com/questions/39535311
复制相似问题