chore: add echarts 6 features in codegen

* chore: add echarts 6 features in codegen

* update according to 772cf01859
This commit is contained in:
Yue JIN
2025-08-09 14:56:35 +08:00
committed by Justineo
parent e568005bb2
commit c232e71c47

View File

@ -8,6 +8,7 @@ const COMPONENTS_MAP = {
singleAxis: "SingleAxisComponent", singleAxis: "SingleAxisComponent",
parallel: "ParallelComponent", parallel: "ParallelComponent",
calendar: "CalendarComponent", calendar: "CalendarComponent",
matrix: "MatrixComponent",
graphic: "GraphicComponent", graphic: "GraphicComponent",
toolbox: "ToolboxComponent", toolbox: "ToolboxComponent",
tooltip: "TooltipComponent", tooltip: "TooltipComponent",
@ -21,6 +22,7 @@ const COMPONENTS_MAP = {
legend: "LegendComponent", legend: "LegendComponent",
dataZoom: "DataZoomComponent", dataZoom: "DataZoomComponent",
visualMap: "VisualMapComponent", visualMap: "VisualMapComponent",
thumbnail: "ThumbnailComponent",
aria: "AriaComponent", aria: "AriaComponent",
dataset: "DatasetComponent", dataset: "DatasetComponent",
@ -41,6 +43,7 @@ const CHARTS_MAP = {
tree: "TreeChart", tree: "TreeChart",
treemap: "TreemapChart", treemap: "TreemapChart",
graph: "GraphChart", graph: "GraphChart",
chord: "ChordChart",
gauge: "GaugeChart", gauge: "GaugeChart",
funnel: "FunnelChart", funnel: "FunnelChart",
parallel: "ParallelChart", parallel: "ParallelChart",
@ -84,7 +87,13 @@ const CHARTS_GL_MAP = {
linesGL: "LinesGLChart", linesGL: "LinesGLChart",
}; };
const FEATURES = ["UniversalTransition", "LabelLayout"]; const FEATURES = [
"UniversalTransition",
"LabelLayout",
"AxisBreak",
// "LegacyGridContainLabel",
"ScatterJitter",
];
const RENDERERS_MAP = { const RENDERERS_MAP = {
canvas: "CanvasRenderer", canvas: "CanvasRenderer",
svg: "SVGRenderer", svg: "SVGRenderer",
@ -155,7 +164,7 @@ function collectDeps(option) {
if (INJECTED_COMPONENTS.includes(key)) { if (INJECTED_COMPONENTS.includes(key)) {
return; return;
} }
const val = option[key]; let val = option[key];
if (Array.isArray(val) && !val.length) { if (Array.isArray(val) && !val.length) {
return; return;
@ -172,12 +181,12 @@ function collectDeps(option) {
} }
}); });
let series = option.series; const series = Array.isArray(option.series) ? option.series : [option.series];
if (!Array.isArray(series)) { let hasScatterSeries = false;
series = [series];
}
series.forEach((seriesOpt) => { series.forEach((seriesOpt) => {
if (seriesOpt.type === "scatter") {
hasScatterSeries = true;
}
if (CHARTS_MAP[seriesOpt.type]) { if (CHARTS_MAP[seriesOpt.type]) {
deps.push(CHARTS_MAP[seriesOpt.type]); deps.push(CHARTS_MAP[seriesOpt.type]);
} }
@ -204,6 +213,21 @@ function collectDeps(option) {
deps.push("UniversalTransition"); deps.push("UniversalTransition");
} }
}); });
Object.keys(option).forEach((key) => {
if (key.endsWith("Axis")) {
const val = option[key];
for (const axisOption of Array.isArray(val) ? val : [val]) {
if (hasScatterSeries && +axisOption.jitter > 0) {
deps.push("ScatterJitter");
}
if (axisOption.breaks && axisOption.breaks.length > 0) {
deps.push("AxisBreak");
}
}
}
});
// Dataset transform // Dataset transform
if (option.dataset && Array.isArray(option.dataset)) { if (option.dataset && Array.isArray(option.dataset)) {
option.dataset.forEach((dataset) => { option.dataset.forEach((dataset) => {