import { Component, OnInit } from '@angular/core'; import { CommomService } from 'src/app/core/services/commom.service' @Component({ selector: 'app-negative-bar-sub-chart-new', templateUrl: './negative-bar-sub-chart-new.component.html', styleUrls: ['./negative-bar-sub-chart-new.component.scss'] }) export class NegativeBarSubChartNewComponent implements OnInit { constructor( private commonService: CommomService ) { } bcacChartTitle: string = ""; bcacFileName: string = ""; bcacYAxisName: string = "" bcacChartloading: boolean = true; bcacTooltipUnit: string = ""; bcacData; ngOnInit() { let style = this.commonService.changeFontSize() this.bcacChartTitle = "行政区达标率" this.bcacFileName = "行政区达标率" this.initChart(style); } initChart(style) { let datas = this.makeData(50, 7, 16); style.interval.right = "110"; let params = { customGrid: style.interval, datas: datas, seriesNames: [ "东城区", "西城区", "朝阳区", "丰台区", "石景山区", "海淀区", "门头沟区", "房山区", "通州区", "顺义区", "昌平区", "大兴区", "怀柔区", "平谷区", "密云区", "延庆区" ], }; this.bcacYAxisName = "达标率(%)"; this.bcacData = params; } // 数据模拟 private makeData(baseValue, number, seriesNumber): any[] { let seriesDatas = []; for (let j = 0; j < seriesNumber; j++) { let datas = []; if (j % 3 == 0) { baseValue = 40; } else { baseValue = 70; } let funcZones = ["0类", "1类", "2类", "3类", "4a类", "4b类"]; if (number > funcZones.length) { number = funcZones.length; } for (let i = 0; i < number; i++) { let value = ( baseValue + 10 * Math.random() ).toFixed(1); datas.push([funcZones[i], value]); } seriesDatas.push(datas); } return seriesDatas; } }