在我的 Angular App 组件文件中。请找到组件 html 和 ts 文件的屏幕截图。你能告诉我订阅和图表选项有什么错误吗。
import { Component, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { ChartserviceService } from '../service/chartservice.service';
import { LineChartModel} from '../model/chartmodel.model';
import { EChartsOption } from 'echarts';
@Component({
selector: 'app-linechart',
templateUrl: './linechart.component.html',
styleUrls: ['./linechart.component.css']
})
export class LinechartComponent implements OnInit {
subscription: Subscription;
chartOption: EChartsOption;
//chartModel = new LineChartModel();
constructor(public chartService : ChartserviceService) { }
ngOnInit(): void {
this.subscription = this.chartService.getChartData().subscribe(data => {
this.basicLineChart(data);
})
}
basicLineChart(echartData : LineChartModel[]){
this.chartOption = {
tooltip : {
show : true
},
backgroundColor : 'transparent',
xAxis: {
type: 'category',
data: echartData.map(m=>({
value : m.name
}))
},
yAxis: {
type: 'value'
},
series: [{
data: echartData.map(m=>({
value : m.value
})),
type: 'line'
}]
}
}
}
组件 TS 文件截图。