import { COLORS } from '../graph.const'; function percentageFormatter() { return this.percentage !== 0 ? `${Math.round(this.percentage)} %` : `${this.point.name}`; } /** * Provides chart property i.e type of graph to be rendered. * * @remarks * This constant is part of the {@link CircularChartUtils}. * * @beta */ export const CircularChartProperties = { treemap: 'TreeMap', pie: 'PieChart', }; /** * Provides chart options. * * @remarks * This constant is part of the {@link CircularChartUtils}. * * @beta */ const DefaultChartOptions = { TreeMap: { colorAxis: { minColor: COLORS.treemapAxisMinColor, maxColor: COLORS.treemapAxisMaxColor, }, }, PieChart: {}, }; /** * Parse chart options based on type. * * @remarks * This method is part of the {@link CircularChartUtils}. * * @param type - A string indicating the 'type of graph to render'. * * @returns The parsed default chart options depending upon the type. * * @beta */ export const getDefaultChartOptions = (type = CircularChartProperties.pie): {} => { return DefaultChartOptions[CircularChartProperties[type]]; }; /** * Parse tooltip * * @remarks * This method is part of the {@link CircularChartUtils}. * * @returns The parsed tooltip * * @beta */ export const getDefaultTooltip = (): {} => { return { trigger: 'item', formatter: '{b} - {d}%', }; };