import { DOUGHNUT } from '@/services/data/tuples/chart-def/chart-doughnut' ; import { ChartDataSet } from '@/services/data/tuples/chart-types' ; import { ECharts } from '@/services/data/tuples/echarts/echarts-types' ; import { Report } from '@/services/data/tuples/report-types' ; import { BASE_COLORS_24 } from '../../basic/colors' ; import { cleanUselessValues } from './data-utils' ; import { buildDecal } from './decal-utils' ; import { DefaultChartUtils } from './default-chart-utils' ; import { buildEChartsLegend } from './legend-utils' ; import { buildEChartsPie , buildSeriesData } from './pie-utils' ; import { buildEChartsTitle } from './title-utils' ; import { buildToolbox } from './toolbox-utils' ; import { ChartOptions } from './types' ; export class ChartDoughnutUtils extends DefaultChartUtils { constructor ( ) { super ( DOUGHNUT ) ; } async buildOptions ( report , dataset ) { const { chart } = report ; const groups = this . buildDescartesByDimensions ( report , dataset ) ; const data = buildSeriesData ( chart , groups , this . formatNumber ) ; return cleanUselessValues ( { color : BASE_COLORS_24 , title : buildEChartsTitle ( chart as ECharts ) , tooltip : { trigger : 'item' } , legend : buildEChartsLegend ( chart as ECharts , groups . map ( ( { value } ) => value ) ) , series : [ buildEChartsPie ( chart as ECharts , data , { type : 'pie' , insideRadius : '50%' , outsideRadius : '75%' } ) ] , aria : buildDecal ( chart ) , toolbox : buildToolbox ( chart , report , dataset ) } ) ; } }