import { Component, OnInit } from '@angular/core'; import { CommomService } from 'src/app/core/services/commom.service' @Component({ selector: 'app-pyramid-sub-bar-chart-new', templateUrl: './pyramid-sub-bar-chart-new.component.html', styleUrls: ['./pyramid-sub-bar-chart-new.component.scss'] }) export class PyramidSubBarChartNewComponent implements OnInit { constructor( private commonService: CommomService ) { } chartTitle: string; fileName: string; loading: boolean; data: any; xAxisName: string; tooltipUnit:string; ngOnInit() { this.chartTitle = "行政区达标率"; this.initChart(); } initChart() { this.xAxisName = "达标率(%)" this.tooltipUnit = "%" let tempDataArr1 = ['-100', '-99', '-96', '-91', '-90', '-87', '-86', '-85', '-81', '-79', '-76', '-74', '-73', '-69', '-67', '-65', '-63', '-60'] let tempDataArr2 = tempDataArr1.map(item => { return Math.abs(+item).toFixed(0); }) let data = { seriesName: ['昼间', '夜间'], stack: '达标率', xData: [tempDataArr1, tempDataArr2], yData: ["东城", "西城", '朝阳', '丰台', '石景山', '海淀', '顺义', '通州', '大兴', '房山', '门头沟', '昌平', '平谷', '密云', '怀柔', '延庆'], } this.data = data; this.loading = false; } }