Skip to content

Commit 82e3b47

Browse files
committed
polar chart
1 parent 52bfbbb commit 82e3b47

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,23 @@ export function getEchartsConfig(
218218
transformedData = [{[seriesColumnNames[0] + "_placeholder"]: 0, [seriesColumnNames[0]]: total}, ...transformedData]
219219
}
220220

221+
if(props.chartConfig.subtype === "polar") {
222+
config = {
223+
...config,
224+
polar: {
225+
radius: [props.chartConfig.polarData.polarRadiusDeg, `${props.chartConfig.polarData.polarRadiusSize}%`],
226+
},
227+
radiusAxis: {
228+
max: props.chartConfig.polarData.radiusAxisMax,
229+
},
230+
angleAxis: {
231+
type: 'category',
232+
data: props.chartConfig.polarData.labelData,
233+
startAngle: 75
234+
},
235+
}
236+
}
237+
221238
console.log("TransformedData", transformedData);
222239

223240
config = {

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
showLabelPropertyView,
88
ColorControl,
99
Dropdown,
10+
toArray,
11+
jsonControl,
1012
} from "lowcoder-sdk";
1113
import { changeChildAction, CompAction } from "lowcoder-core";
1214
import { BarSeriesOption } from "echarts";
@@ -25,6 +27,10 @@ const BarTypeOptions = [
2527
label: trans("chart.waterfallBar"),
2628
value: "waterfall",
2729
},
30+
{
31+
label: trans("chart.polar"),
32+
value: "polar",
33+
},
2834
] as const;
2935

3036
export const BarChartConfig = (function () {
@@ -35,6 +41,10 @@ export const BarChartConfig = (function () {
3541
barWidth: withDefault(NumberControl, i18nObjs.defaultBarChartOption.barWidth),
3642
showBackground: BoolControl,
3743
backgroundColor: withDefault(ColorControl, i18nObjs.defaultBarChartOption.barBg),
44+
radiusAxisMax: withDefault(NumberControl, 4),
45+
polarRadiusDeg: withDefault(NumberControl, 30),
46+
polarRadiusSize: withDefault(NumberControl, 80),
47+
labelData: jsonControl(toArray, []),
3848
},
3949
(props): BarSeriesOption => {
4050
const config: BarSeriesOption = {
@@ -48,6 +58,12 @@ export const BarChartConfig = (function () {
4858
showBackground: props.showBackground,
4959
backgroundStyle: {
5060
color: props.backgroundColor,
61+
},
62+
polarData: {
63+
radiusAxisMax: props.radiusAxisMax,
64+
polarRadiusDeg: props.polarRadiusDeg,
65+
polarRadiusSize: props.polarRadiusSize,
66+
labelData: props.labelData,
5167
}
5268

5369
};
@@ -58,6 +74,9 @@ export const BarChartConfig = (function () {
5874
config.label = undefined;
5975
config.stack = "stackValue";
6076
}
77+
if (props.type === "polar") {
78+
config.coordinateSystem = 'polar';
79+
}
6180
return config;
6281
}
6382
)
@@ -81,6 +100,18 @@ export const BarChartConfig = (function () {
81100
{children.showBackground.getView() && children.backgroundColor.propertyView({
82101
label: trans("barChart.bgColor"),
83102
})}
103+
{children.type.getView() === "polar" && children.radiusAxisMax.propertyView({
104+
label: trans("barChart.radiusAxisMax"),
105+
})}
106+
{children.type.getView() === "polar" && children.polarRadiusDeg.propertyView({
107+
label: trans("barChart.polarRadiusDeg"),
108+
})}
109+
{children.type.getView() === "polar" && children.polarRadiusSize.propertyView({
110+
label: trans("barChart.polarRadiusSize"),
111+
})}
112+
{children.type.getView() === "polar" && children.labelData.propertyView({
113+
label: trans("barChart.polarLabelData"),
114+
})}
84115
</>
85116
))
86117
.build();

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ export const en = {
317317
barWidth: 'Bar Width(%)',
318318
showBg: 'Show Bar Background',
319319
bgColor: 'Background Color',
320+
radiusAxisMax: 'Max',
321+
polarRadiusDeg: 'Degree',
322+
polarRadiusSize: 'Size (%)',
323+
polarLabelData: 'Label Data',
320324
defaultTitle: 'Bar Chart',
321325
barType: 'Bar Chart Type',
322326
tooltip: 'Tooltip',
@@ -479,6 +483,7 @@ export const en = {
479483
basicBar: "Basic Bar",
480484
stackedBar: "Stacked Bar",
481485
waterfallBar: "Waterfall Chart",
486+
polar: "Polar",
482487
barType: "Bar Chart Type",
483488
categoryAxis: "Category Axis",
484489
valueAxis: "Value Axis",

0 commit comments

Comments
 (0)