js 生成简单的柱状图
本例与jquery无关,算是简单的柱状图,不需要很复杂,数据获取也很方便
XML/HTML Code
- <div id="chartContainer" style="height: 300px; width: 100%;"> </div>
JavaScript Code
- <script type="text/javascript">
- window.onload = function () {
- var chart = new CanvasJS.Chart("chartContainer",
- {
- title:{
- text: "各国人口",
- },
- axisY: {
- title: "人口"
- },
- legend: {
- verticalAlign: "bottom",
- horizontalAlign: "center"
- },
- theme: "theme2",
- data: [
- {
- type: "column",
- showInLegend: true,
- legendMarkerColor: "grey",
- legendText: "国家(单位亿)",
- dataPoints: [
- {y: 2.90342554, label: "美国" },
- {y: 10.49700118, label: "印度"},
- {y: 13.17442552, label: "中国"},
- ]
- },
- ]
- });
- chart.render();
- }
- </script>
原文地址:http://www.freejs.net/article_jquerywenzi_324.html