I am totally new to html. I was asked to display a simple chart in JS in a page.
This is my code, I am not getting anything displayed.
<html>
<head>
<title>JS Charts</title>
<script type="text/javascript" src="scripts/jscharts.js"></script>
</head>
<body>
<script type="text/javascript" >
var myData = new Array(['2005', 2], ['2006', 1], ['2007', 3], ['2008', 6]);
var myChart = new JSChart('chartid', 'bar');
myChart.setDataArray(myData);
myChart.setBarColor('#42aBdB');
myChart.setBarOpacity(0.8);
myChart.setBarBorderColor('#D9EDF7');
myChart.setBarValues(false);
myChart.setTitleColor('#8C8383');
myChart.setAxisColor('#777E81');
myChart.setAxisValuesColor('#777E81');
myChart.draw();
</script>
</body>
</html>
您必须在HTML文档中添加<div id="chartid"></div>
,如果不正确,请为jscharts.js设置正确的路径!
You need to have a dom reference for your chart :
You have a reference here :
var myChart = new JSChart('chartid', 'bar');
So you need an html reference like :
<div id="chartid"></div>
If you want a very simple chart bar with full working exemple maybe you should use highcharts : http://www.highcharts.com/demo/column-basic
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.