简单教程
提交运行
代码编辑器:
<!doctype html> <meta charset="utf-8" /> <title>Highcharts 基础教程 | 简单教程(www.twle.cn)</title> <script src="https://cdn.hcharts.cn/highcharts/highcharts.js"></script> <script src="https://cdn.hcharts.cn/highcharts/modules/data.js"></script> <div id="container" style="width: 500px; height: 400px; margin: 0 auto"></div> <table id="datatable" style="display:none"> <thead> <tr><th></th><th>Jane</th><th>John</th></tr> </thead> <tbody> <tr><th>Apples</th><td>3</td><td>4</td></tr> <tr><th>Pears</th><td>2</td><td>0</td></tr> <tr><th>Plums</th><td>5</td><td>11</td></tr> <tr><th>Bananas</th><td>1</td><td>1</td></tr> <tr><th>Oranges</th><td>2</td><td>4</td></tr> </tbody> </table> <script> var data = { table: 'datatable' }; var chart = { type: 'column' }; var title = { text: '从网页中的 HTML 表格中读取数据' }; var yAxis = { allowDecimals: false, title: { text: 'Units' } }; var tooltip = { formatter: function () { return '<b>' + this.series.name + '</b><br/>' + this.point.y + ' ' + this.point.name.toLowerCase(); } }; var credits = { enabled: false }; var options = {}; options.chart = chart; options.title = title; options.yAxis = yAxis; options.tooltip = tooltip; options.credits = credits; options.data = data; var chart = Highcharts.chart('container',options); </script>
运行结果: