Angular Highcharts - 带回归线的散点图
以下是带有回归线的散点图示例。
我们已经在Highcharts 配置语法章节中看到了用于绘制图表的配置。
下面给出了带有回归线的散点图示例。
配置
现在让我们看看采取的其他配置/步骤。
series 系列
将图表类型配置为基于散点图。 series.type 决定图表的系列类型。 这里,默认值为"line"。
series : [{
type: 'scatter'
}]
示例
app.component.ts
import { Component } from '@angular/core';
import * as Highcharts from 'highcharts';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
highcharts = Highcharts;
chartOptions = {
title : {
text: '带回归线的散点图'
},
xAxis : {
min: -0.5,
max: 5.5
},
yAxis : {
min: 0
},
series : [
{
type: 'line',
name: 'Regression Line',
data: [[0, 1.11], [5, 4.51]],
marker: {
enabled: false
},
states: {
hover: {
lineWidth: 0
}
},
enableMouseTracking: false
},
{
type: 'scatter',
name: 'Observations',
data: [1, 1.5, 2.8, 3.5, 3.9, 4.2],
marker: {
radius: 4
}
}]
};
}
结果
验证结果。
❮ angular_highcharts_combinations.html

