Skip to content

Add data field to all required part of eCharts and set default values of them. #1493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add missing data fields and default values
  • Loading branch information
Imiss-U1025 committed Feb 3, 2025
commit 77b63e80835fb531b9198bc55da0b9834c38d124
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ export function getEchartsConfig(
mapOptions,
showCharts,
} = props;
let newMapOptions: any = {...mapOptions};
newMapOptions.series = [{...newMapOptions.series[0]}];
if(props.echartsData && props.echartsData.length > 0) newMapOptions.series[0].data = props.echartsData;

const echartsOption = mapOptions && showCharts ? mapOptions : {};
const echartsOption = newMapOptions && showCharts ? newMapOptions : {};
return {
gmap: {
center: [mapCenterLng, mapCenterLat],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultCandleStickChartOption.data),
echartsOption: jsonControl(toObject, i18nObjs.defaultCandleStickChartOption),
echartsTitle: withDefault(StringControl, trans("candleStickChart.defaultTitle")),
echartsTitleData: jsonControl(toArray),
echartsTitleData: jsonControl(toArray, i18nObjs.defaultCandleStickChartOption.xAxis.data),
echartsTitleVerticalConfig: EchartsTitleVerticalConfig,
echartsLabelConfig: EchartsLabelConfig,
echartsTitleConfig:EchartsTitleConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultFunnelChartOption.data),
echartsOption: jsonControl(toObject, i18nObjs.defaultFunnelChartOption),
echartsTitle: withDefault(StringControl, trans("funnelChart.defaultTitle")),
echartsTitleVerticalConfig: EchartsTitleVerticalConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsCategories: jsonControl(toArray, i18nObjs.defaultGraphChartOption.categories),
echartsLinks: jsonControl(toArray, i18nObjs.defaultGraphChartOption.links),
echartsNodes: jsonControl(toArray, i18nObjs.defaultGraphChartOption.nodes),
echartsOption: jsonControl(toObject, i18nObjs.defaultGraphChartOption),
echartsTitle: withDefault(StringControl, trans("graphChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export function graphChartPropertyView(
const jsonModePropertyView = (
<>
<Section name={trans("chart.config")}>
{children.echartsData.propertyView({ label: trans("chart.data") })}
{children.echartsCategories.propertyView({ label: trans("graphChart.categories") })}
{children.echartsLinks.propertyView({ label: trans("graphChart.links") })}
{children.echartsNodes.propertyView({ label: trans("graphChart.nodes") })}
{children.echartsTitle.propertyView({ label: trans("graphChart.title"), tooltip: trans("echarts.titleTooltip") })}
{children.echartsTitleConfig.getPropertyView()}
{children.echartsTitleVerticalConfig.getPropertyView()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ export function getEchartsConfig(

"type": "graph",
"layout": "force",
'categories': props?.echartsData?.categories || props.echartsOption.categories,
'links': props?.echartsData.length !== 0 && props?.echartsData || props.echartsOption.links,
'categories': props?.echartsCategories.length !== 0 && props?.echartsCategories || props.echartsOption.categories,
'links': props?.echartsLinks.length !== 0 && props?.echartsLinks || props.echartsOption.links,
"force": {
"repulsion": props.repulsion,
"gravity": props?.gravity,
Expand All @@ -165,20 +165,20 @@ export function getEchartsConfig(
edgeSymbolSize: [0, props?.arrowSize],
symbolSize: props?.pointSize,
lineStyle: {
color: props.echartsData?.color?.lineColor || props.echartsOption?.color?.lineColor || "#00000033",
color: props.echartsOption?.color?.lineColor || "#00000033",
...chartStyleWrapper(props?.chartStyle,theme?.chartStyle),
width: props?.lineWidth || 1,
curveness: props?.curveness
},
'nodes': props?.echartsData?.nodes || props.echartsOption.nodes,
'nodes': props?.echartsNodes.length !==0 && props?.echartsNodes || props.echartsOption.nodes,
itemStyle: {
"color": props.echartsData?.color?.pointColor || props.echartsOption?.color?.pointColor || "#0000ff",
"color": props.echartsOption?.color?.pointColor || "#0000ff",
...chartStyleWrapper(props?.chartStyle,theme?.chartStyle),
},
}
],
}
return props.echartsData || props.echartsOption ? opt : {};
return props.echartsOption ? opt : {};

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultHeatmapChartOption.data),
echartsDataX: jsonControl(toArray, i18nObjs.defaultHeatmapChartOption.xAxis),
echartsDataY: jsonControl(toArray, i18nObjs.defaultHeatmapChartOption.yAxis),
echartsColor: jsonControl(toArray, i18nObjs.defaultHeatmapChartOption.color),
echartsOption: jsonControl(toObject, i18nObjs.defaultHeatmapChartOption),
echartsTitle: withDefault(StringControl, trans("heatmapChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export function heatmapChartPropertyView(
<>
<Section name={trans("chart.config")}>
{children.echartsData.propertyView({ label: trans("chart.data") })}
{children.echartsDataX.propertyView({ label: trans("heatmapChart.xAxisData") })}
{children.echartsDataY.propertyView({ label: trans("heatmapChart.yAxisData") })}
{children.echartsColor.propertyView({ label: trans("heatmapChart.color") })}
{children.echartsTitleConfig.getPropertyView()}
{children.echartsTitleVerticalConfig.getPropertyView()}
{children.echartsLegendAlignConfig.getPropertyView()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultRadarChartOption.series),
echartsIndicators: jsonControl(toArray, i18nObjs.defaultRadarChartOption.indicator),
echartsOption: jsonControl(toObject, i18nObjs.defaultRadarChartOption),
echartsTitle: withDefault(StringControl, trans("radarChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function radarChartPropertyView(
<>
<Section name={trans("chart.config")}>
{children.echartsData.propertyView({ label: trans("chart.data") })}

{children.echartsIndicators.propertyView({ label: trans("radarChart.indicators") })}
{children.echartsTitleConfig.getPropertyView()}
{children.echartsTitleVerticalConfig.getPropertyView()}
{children.legendVisibility.getView() && children.echartsLegendAlignConfig.getPropertyView()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function getEchartsConfig(
},
radar: [
{
indicator: props.echartsData.indicator || props.echartsOption.indicator,
indicator: (props.echartsIndicators.length !== 0 && props.echartsIndicators) || props.echartsOption.indicator,
center: [`${props?.position_x}%`, `${props?.position_y}%`],
startAngle: props?.startAngle,
endAngle: props?.endAngle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultSankeyChartOption.data),
echartsLinks: jsonControl(toArray, i18nObjs.defaultSankeyChartOption.links),
echartsOption: jsonControl(toObject, i18nObjs.defaultSankeyChartOption),
echartsTitle: withDefault(StringControl, trans("sankeyChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function sankeyChartPropertyView(
<>
<Section name={trans("chart.config")}>
{children.echartsData.propertyView({ label: trans("chart.data") })}
{children.echartsLinks.propertyView({ label: trans("chart.links") })}

{children.echartsTitleConfig.getPropertyView()}
{children.echartsTitleVerticalConfig.getPropertyView()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function getEchartsConfig(
name: item.name,
itemStyle: isColorString(item.color) && {color: item.color}
})),
links: props.echartsData.links || props.echartsOption.links,
links: (props.echartsLinks.length !== 0 && props.echartsLinks) || props.echartsOption.links,
emphasis: {
focus: props?.focus ? 'adjacency' : undefined,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultSunburstChartOption.data),
echartsLevels: jsonControl(toArray, i18nObjs.defaultSunburstChartOption.levels),
echartsOption: jsonControl(toObject, i18nObjs.defaultSunburstChartOption),
echartsTitle: withDefault(StringControl, trans("sunburstChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function sunburstChartPropertyView(
<>
<Section name={trans("chart.config")}>
{children.echartsData.propertyView({ label: trans("chart.data") })}
{children.echartsLevels.propertyView({ label: trans("sunburstChart.levels") })}

{children.echartsTitleConfig.getPropertyView()}
{children.echartsTitleVerticalConfig.getPropertyView()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function getEchartsConfig(
backgroundColor: parseBackground(
props?.chartStyle?.background || theme?.chartStyle?.backgroundColor || "#FFFFFF"
),
color: props.echartsData.data?.map(data => data.color) || props.echartsOption.data?.map(data => data.color),
color: props.echartsOption.data?.map(data => data.color),
tooltip: props.tooltip&&{
trigger: "item",
formatter: "{b}: {c}"
Expand All @@ -161,7 +161,7 @@ export function getEchartsConfig(
center: [`${props?.position_x}%`, `${props?.position_y}%`],
symbolSize: 7,
data: props?.echartsData.length !== 0 && props?.echartsData || props.echartsOption.data,
levels: props.echartsData.levels || props.echartsOption.levels,
levels: props.echartsLevels.length !==0 && props.echartsLevels || props.echartsOption.levels,
itemStyle: {
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle)
},
Expand All @@ -173,7 +173,7 @@ export function getEchartsConfig(
}
],
}
return props.echartsData || props.echartsOption ? opt : {};
return props.echartsOption ? opt : {};

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultThemeriverChartOption.data),
echartsColors: jsonControl(toArray, i18nObjs.defaultThemeriverChartOption.color),
echartsOption: jsonControl(toObject, i18nObjs.defaultThemeriverChartOption),
echartsTitle: withDefault(StringControl, trans("themeriverChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function themeriverChartPropertyView(
<>
<Section name={trans("chart.config")}>
{children.echartsData.propertyView({ label: trans("chart.data") })}
{children.echartsColors.propertyView({ label: trans("themeriverChart.colors") })}

{children.echartsTitleConfig.getPropertyView()}
{children.echartsTitleVerticalConfig.getPropertyView()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ export function getEchartsConfig(
shadowColor: "rgba(0, 0, 0, 0.8)"
}
},
color: props.echartsData?.color && props.echartsData.color || props.echartsOption?.color && props.echartsOption.color
color: props.echartsColors.length !== 0 && props.echartsColors || props.echartsOption?.color && props.echartsOption.color
},
]
}

return props.echartsData || props.echartsOption ? opt : {};
return props.echartsOption ? opt : {};

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultTreeChartOption.data),
echartsOption: jsonControl(toObject, i18nObjs.defaultTreeChartOption),
echartsTitle: withDefault(StringControl, trans("treeChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export const chartUiModeChildren = {
};

let chartJsonModeChildren: any = {
echartsData: jsonControl(toArray),
echartsData: jsonControl(toArray, i18nObjs.defaultTreemapChartOption.data),
echartsOption: jsonControl(toObject, i18nObjs.defaultTreemapChartOption),
echartsTitle: withDefault(StringControl, trans("treemapChart.defaultTitle")),
echartsLegendConfig: EchartsLegendConfig,
Expand Down
10 changes: 10 additions & 0 deletions client/packages/lowcoder-comps/src/i18n/comps/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const en = {
},
themeriverChart: {
themeriverType: 'Themeriver Chart Type',
colors: 'Colors',
title: 'Title',
defaultTitle: 'Themeriver Chart',
tooltip: 'Tooltip',
Expand All @@ -23,6 +24,7 @@ export const en = {
},
sunburstChart: {
sunburstType: 'Sunburst Chart Type',
levels: 'Levels',
title: 'Title',
defaultTitle: 'Sunburst Chart',
tooltip: 'Tooltip',
Expand Down Expand Up @@ -73,6 +75,9 @@ export const en = {
lineWidthTooltip: "Set the Line Width of the Chart."
},
graphChart: {
categories: 'Categories',
nodes: 'Nodes',
links: 'Links',
graphType: 'Graph Chart Type',
title: 'Title',
defaultTitle: 'Graph Chart',
Expand Down Expand Up @@ -105,6 +110,9 @@ export const en = {
},
heatmapChart: {
heatmapType: 'Heatmap Chart Type',
color: 'Colors',
xAxisData: 'X-Axis Data',
yAxisData: 'Y-Axis Data',
title: 'Title',
left: 'Left',
defaultLeft:'15',
Expand Down Expand Up @@ -145,6 +153,7 @@ export const en = {
areaFlagTooltip: "Divide the area into a Line or a Circle.",
indicatorVisibility: "Indicator",
indicatorVisibilityTooltip: "Show or hide the Indicator of the Chart.",
indicators: 'Indicators',
},
candleStickChart: {
candleStickType: 'CandleStick Chart Type',
Expand Down Expand Up @@ -361,6 +370,7 @@ export const en = {
chart: {
delete: "Delete",
data: "Data",
links: "Links",
mode: "Mode",
config: "Configuration",
UIMode: "UI Mode",
Expand Down
Loading