import type { EchartOptionsProps, EchartWidgetOptionProps } from './types' /** * Returns the shared base ECharts options used across all EChart-based widgets (bar, pie, histogram, etc.). * * @remarks * Configures grid spacing, tooltip styling, legend, axis pointer, and the default color palette * derived from the MUI theme. */ export function getCommonOptions({ theme, }: EchartWidgetOptionProps): EchartOptionsProps { return { grid: { left: parseInt(theme.spacing(1)), top: parseInt(theme.spacing(3)), right: parseInt(theme.spacing(1)), bottom: parseInt(theme.spacing(4)), containLabel: true, }, toolbox: { show: false, }, tooltip: { axisPointer: { type: 'line', }, backgroundColor: theme.palette.grey[900], borderWidth: 0, padding: [parseInt(theme.spacing(1)), parseInt(theme.spacing(1))], textStyle: { color: theme.palette.common.white, fontSize: 11, fontFamily: theme.typography.caption.fontFamily, }, trigger: 'axis', }, legend: { type: 'scroll', bottom: 0, }, axisPointer: { lineStyle: { color: theme.palette.grey[400], }, }, xAxis: {}, yAxis: {}, color: [ theme.palette.secondary.main, ...Object.values( (theme.palette as { qualitative?: { bold?: Record } }) .qualitative?.bold ?? {}, ), ], } }