import { Injectable } from '@angular/core'; import * as _ from "lodash"; import * as legend from "../../config/legend"; import * as series from "../../config/series"; import * as toolbox from "../../config/toolbox"; import * as tooltip from "../../config/tootip"; import * as xAxis from "../../config/xAxis"; import * as yAxis from "../../config/yAxis"; import * as color from "../../config/colors"; import * as backgroundColor from "../../config/backgroundColor"; import * as datazoom from "../../config/datazoom"; import { CommonService } from '../../service/common.service'; import { legendPosition } from './rose-pie-interface' @Injectable({ providedIn: 'root' }) export class RosePieService { constructor( private commonService: CommonService ) { } getDefaultOptionsOfRosePieChart = () => { let style = this.commonService.changeFontSize(); let defaultOptions = { backgroundColor: backgroundColor.backgroundColor, color: color.defaultColors, legend: legend.getLegendRightScroll(style), toolbox: toolbox.getToolboxBasicMenu(), tooltip: tooltip.getTooltipOfPieChart(style), series: series.getRosePieChartSeries(style) } return defaultOptions; } // 更改toolbox显示状态 changeToolboxShow(chartOptions, show: boolean) { chartOptions.toolbox.show = show; } // 更改系列名 changeSeriesName(chartOptions, seriesName: string) { chartOptions.series[0].seriesName = seriesName; } // 更改玫瑰图的类型 changePieChartRoseType(chartOptions, bcacRoseType: 'radius' | 'area') { chartOptions.series[0].roseType = bcacRoseType; } // 设置圆心的位置 changeRadius(chartOptions, bcacPieChartRadius: Array | Array) { chartOptions.series[0].radius = bcacPieChartRadius; } // 设置饼图的半径 changeCenter(chartOptions, bcacPieChartCenter: Array | Array) { chartOptions.series[0].center = bcacPieChartCenter; } // 修改label状态 changeLabelStatus(chartOption, showLabel: boolean) { chartOption.series[0].label.show = showLabel; } // 修改labelLine length changeLabelLineLength(chartOption, labelLineLength: number) { chartOption.series[0].labelLine.length = labelLineLength; } // 修改labelLine length2 changeLabelLineLength2(chartOption, labelLineLength2: number) { chartOption.series[0].labelLine.length2 = labelLineLength2; } // 更改legend位置 changeLegendPosition(chartOption, legendPosition: legendPosition) { let style = this.commonService.changeFontSize(); switch (legendPosition) { case 'bottom': chartOption.legend = legend.getLegendBottomScroll(style) break; case 'right': chartOption.legend = legend.getLegendRightScroll(style) break; } } // 更改legend显示状态 changeLegendShowStatus(chartOptions, showLegend: boolean) { chartOptions.legend.show = showLegend; } // 设置chart数据 changeChartData(chartOptions, bcacChartData: { name: string, value: string | number }[]) { chartOptions.series[0].data = bcacChartData; } }