简单教程
提交运行
代码编辑器:
<!doctype html> <meta charset="utf-8" /> <title>Highcharts 基础教程 | 简单教程(www.twle.cn)</title> <script src="https://cdn.hcharts.cn/highcharts/highcharts.js"></script> <div id="container" style="width: 500px; height: 400px; margin: 0 auto"></div> <script> var title = { text: '散点图上添加回归线' }; var xAxis = { min: -0.5, max: 5.5 }; var yAxis = { min: 0 }; var series = [{ type: 'line', name: '回归线', data: [[0, 1.11], [5, 4.51]], marker: { enabled: false }, states: { hover: { lineWidth: 0 } }, enableMouseTracking: false }, { type: 'scatter', name: '观察点', data: [1, 1.5, 2.8, 3.5, 3.9, 4.2], marker: { radius: 4 } } ]; var options = {}; options.title = title; options.xAxis = xAxis; options.yAxis = yAxis; options.series = series; Highcharts.chart('container',options); </script>
运行结果: