网站首页
百度ECharts
ECharts实例
ECharts入门
地图大全
ECharts官网
源代码:
点击运行 》
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Highcharts 实例</title> <script src="/js/jquery-1.9.0.min.js"></script> <!-- 引入 chart.js --> <script src="/js/highcharts.js"></script> <script src="js/data.js"></script> </head> <body> <div id="myChart" width='100%' height='450'></div> <script type="text/javascript"> $(document).ready(function() { var title = { text: 'Daily visits at www.highcharts.com' }; var subtitle = { text: 'Source: Google Analytics' }; var xAxis = { tickInterval: 7 * 24 * 3600 * 1000, // one week tickWidth: 0, gridLineWidth: 1, labels: { align: 'left', x: 3, y: -3 } }; var yAxis = [{ // left y axis title: { text: null }, labels: { align: 'left', x: 3, y: 16, format: '{value:.,0f}' }, showFirstLabel: false },{ // right y axis linkedTo: 0, gridLineWidth: 0, opposite: true, title: { text: null }, labels: { align: 'right', x: -3, y: 16, format: '{value:.,0f}' }, showFirstLabel: false } ]; var tooltip = { shared: true, crosshairs: true } var legend = { align: 'left', verticalAlign: 'top', y: 20, floating: true, borderWidth: 0 }; var plotOptions = { series: { cursor: 'pointer', point: { events: { click: function (e) { hs.htmlExpand(null, { pageOrigin: { x: e.pageX || e.clientX, y: e.pageY || e.clientY }, headingText: this.series.name, maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x) + ':
' + this.y + ' visits', width: 200 }); } } }, marker: { lineWidth: 1 } } } var series = [{ name: 'All visits', lineWidth: 4, marker: { radius: 4 } }, { name: 'New visitors' }] var json = {}; json.title = title; json.subtitle = subtitle; json.xAxis = xAxis; json.yAxis = yAxis; json.tooltip = tooltip; json.legend = legend; json.series = series; json.plotOptions = plotOptions; var data = { csvURL: 'analytics.csv', beforeParse: function (csv) { return csv.replace(/\n\n/g, '\n'); } }; json.data = data; $('#myChart').highcharts(json); }); </script> </body> </html>
运行结果: