mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
feat: Add ECharts options overrides to theme system (#34876)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
088ecdd0bf
commit
c2534f9155
@@ -27,11 +27,9 @@ import {
|
||||
Ref,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { merge } from 'lodash';
|
||||
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { styled, useTheme } from '@superset-ui/core';
|
||||
import { styled, useTheme, mergeReplaceArrays } from '@superset-ui/core';
|
||||
import { use, init, EChartsType, registerLocale } from 'echarts/core';
|
||||
import {
|
||||
SankeyChart,
|
||||
@@ -131,6 +129,7 @@ function Echart(
|
||||
zrEventHandlers,
|
||||
selectedValues = {},
|
||||
refs,
|
||||
vizType,
|
||||
}: EchartsProps,
|
||||
ref: Ref<EchartsHandler>,
|
||||
) {
|
||||
@@ -237,11 +236,19 @@ function Echart(
|
||||
return echartsTheme;
|
||||
};
|
||||
|
||||
const themedEchartOptions = merge(
|
||||
{},
|
||||
getEchartsTheme(echartOptions),
|
||||
const baseTheme = getEchartsTheme(echartOptions);
|
||||
const globalOverrides = theme.echartsOptionsOverrides || {};
|
||||
const chartOverrides = vizType
|
||||
? theme.echartsOptionsOverridesByChartType?.[vizType] || {}
|
||||
: {};
|
||||
|
||||
const themedEchartOptions = mergeReplaceArrays(
|
||||
baseTheme,
|
||||
echartOptions,
|
||||
globalOverrides,
|
||||
chartOverrides,
|
||||
);
|
||||
|
||||
chartRef.current?.setOption(themedEchartOptions, true);
|
||||
}
|
||||
}, [didMount, echartOptions, eventHandlers, zrEventHandlers, theme]);
|
||||
|
||||
Reference in New Issue
Block a user