Skip to content

Commit ec054bb

Browse files
committed
tangent chart
1 parent ed7d742 commit ec054bb

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

client/packages/lowcoder-comps/src/comps/barChartComp/barChartUtils.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function getSeriesConfig(props: EchartsConfigProps) {
107107
encodeY = props.xAxisKey;
108108
}
109109
return {
110-
name: props.chartConfig.subtype === "waterfall" && index === 0?s.getView().seriesName + "_placeholder":s.getView().seriesName,
110+
name: props.chartConfig.subtype === "waterfall" && index === 0?" ":s.getView().seriesName,
111111
selectedMode: "single",
112112
select: {
113113
itemStyle: {
@@ -212,8 +212,8 @@ export function getEchartsConfig(
212212
}, 0)
213213
const total = sum;
214214
transformedData.map(d => {
215-
d[`${seriesColumnNames[0]}_placeholder`] = sum - d[seriesColumnNames[0]];
216-
sum = d[`${seriesColumnNames[0]}_placeholder`];
215+
d[` `] = sum - d[seriesColumnNames[0]];
216+
sum = d[` `];
217217
})
218218
transformedData = [{[seriesColumnNames[0] + "_placeholder"]: 0, [seriesColumnNames[0]]: total}, ...transformedData]
219219
}
@@ -225,11 +225,14 @@ export function getEchartsConfig(
225225
radius: [props.chartConfig.polarData.polarRadiusDeg, `${props.chartConfig.polarData.polarRadiusSize}%`],
226226
},
227227
radiusAxis: {
228-
max: props.chartConfig.polarData.radiusAxisMax,
228+
type: props.chartConfig.polarData.polarIsTangent?'category':undefined,
229+
data: props.chartConfig.polarData.polarIsTangent?props.chartConfig.polarData.labelData:undefined,
230+
max: props.chartConfig.polarData.polarIsTangent?undefined:props.chartConfig.polarData.radiusAxisMax || undefined,
229231
},
230232
angleAxis: {
231-
type: 'category',
232-
data: props.chartConfig.polarData.labelData,
233+
type: props.chartConfig.polarData.polarIsTangent?undefined:'category',
234+
data: props.chartConfig.polarData.polarIsTangent?undefined:props.chartConfig.polarData.labelData,
235+
max: props.chartConfig.polarData.polarIsTangent?props.chartConfig.polarData.radiusAxisMax || undefined:undefined,
233236
startAngle: 75
234237
},
235238
}
@@ -302,6 +305,24 @@ export function getEchartsConfig(
302305
}
303306
},
304307
};
308+
309+
//Waterfall x-label initialization
310+
if(props.chartConfig?.subtype === "waterfall" && props.xAxisData.length === 0) {
311+
//default labels
312+
config.xAxis.data = ["Total"];
313+
for(let i=1; i<transformedData.length; i++)
314+
config.xAxis.data.push(`Column${i}`);
315+
}
316+
317+
//Polar x-label initialization
318+
if(props.chartConfig?.subtype === "polar" && props.chartConfig.polarData.labelData.length === 0) {
319+
//default labels
320+
let labelData = [];
321+
for(let i=0; i<transformedData.length; i++)
322+
labelData.push(`C${i+1}`);
323+
if(props.chartConfig.polarData.polarIsTangent && config.radiusAxis.data.length === 0) config.radiusAxis.data = labelData;
324+
if(!props.chartConfig.polarData.polarIsTangent && config.angleAxis.data.length === 0) config.angleAxis.data = labelData;
325+
}
305326
console.log("Config", config);
306327
console.log("Props", props);
307328
}

client/packages/lowcoder-comps/src/comps/basicChartComp/chartConfigs/barChartConfig.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ export const BarChartConfig = (function () {
4141
barWidth: withDefault(NumberControl, i18nObjs.defaultBarChartOption.barWidth),
4242
showBackground: BoolControl,
4343
backgroundColor: withDefault(ColorControl, i18nObjs.defaultBarChartOption.barBg),
44-
radiusAxisMax: withDefault(NumberControl, 4),
44+
radiusAxisMax: NumberControl,
4545
polarRadiusDeg: withDefault(NumberControl, 30),
4646
polarRadiusSize: withDefault(NumberControl, 80),
47+
polarIsTangent: withDefault(BoolControl, false),
4748
labelData: jsonControl(toArray, []),
4849
},
4950
(props): BarSeriesOption => {
@@ -64,6 +65,7 @@ export const BarChartConfig = (function () {
6465
polarRadiusDeg: props.polarRadiusDeg,
6566
polarRadiusSize: props.polarRadiusSize,
6667
labelData: props.labelData,
68+
polarIsTangent: props.polarIsTangent,
6769
}
6870

6971
};
@@ -100,6 +102,9 @@ export const BarChartConfig = (function () {
100102
{children.showBackground.getView() && children.backgroundColor.propertyView({
101103
label: trans("barChart.bgColor"),
102104
})}
105+
{children.type.getView() === "polar" && children.polarIsTangent.propertyView({
106+
label: trans("barChart.polarIsTangent"),
107+
})}
103108
{children.type.getView() === "polar" && children.radiusAxisMax.propertyView({
104109
label: trans("barChart.radiusAxisMax"),
105110
})}

client/packages/lowcoder-comps/src/i18n/comps/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ export const en = {
317317
barWidth: 'Bar Width(%)',
318318
showBg: 'Show Bar Background',
319319
bgColor: 'Background Color',
320+
polarIsTangent: 'Tangential Chart',
320321
radiusAxisMax: 'Max',
321322
polarRadiusDeg: 'Degree',
322323
polarRadiusSize: 'Size (%)',

0 commit comments

Comments
 (0)