Skip to content

Commit 0fd92c4

Browse files
committed
Improve Bar Chart
1 parent 156b06a commit 0fd92c4

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

client/packages/lowcoder-comps/src/comps/barChartComp/barChartComp.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,17 @@ let BarChartComp = withExposingConfigs(BarChartTmpComp, [
304304

305305

306306
export const BarChartCompWithDefault = withDefault(BarChartComp, {
307-
xAxisKey: "date",
307+
xAxisKey: "month",
308308
series: [
309309
{
310310
dataIndex: genRandomKey(),
311-
seriesName: trans("chart.spending"),
312-
columnName: "spending",
311+
seriesName: "Sales",
312+
columnName: "sales",
313313
},
314314
{
315315
dataIndex: genRandomKey(),
316-
seriesName: trans("chart.budget"),
317-
columnName: "budget",
316+
seriesName: "Target",
317+
columnName: "target",
318318
},
319319
],
320320
});

client/packages/lowcoder-comps/src/comps/barChartComp/barChartConstants.tsx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,40 @@ import { FunnelChartConfig } from "../basicChartComp/chartConfigs/funnelChartCon
3737
import {EchartsTitleVerticalConfig} from "../chartComp/chartConfigs/echartsTitleVerticalConfig";
3838
import {EchartsTitleConfig} from "../basicChartComp/chartConfigs/echartsTitleConfig";
3939

40+
// Enhanced default data for bar charts
41+
export const barChartDefaultData = [
42+
{
43+
month: "Jan",
44+
sales: 1200,
45+
target: 1000
46+
},
47+
{
48+
month: "Feb",
49+
sales: 1500,
50+
target: 1200
51+
},
52+
{
53+
month: "Mar",
54+
sales: 1300,
55+
target: 1400
56+
},
57+
{
58+
month: "Apr",
59+
sales: 1800,
60+
target: 1500
61+
},
62+
{
63+
month: "May",
64+
sales: 1600,
65+
target: 1700
66+
},
67+
{
68+
month: "Jun",
69+
sales: 2100,
70+
target: 1900
71+
}
72+
];
73+
4074
export const ChartTypeOptions = [
4175
{
4276
label: trans("chart.bar"),
@@ -241,9 +275,9 @@ const EchartsOptionComp = withType(EchartsOptionMap, "funnel");
241275
export type CharOptionCompType = keyof typeof ChartOptionMap;
242276

243277
export const chartUiModeChildren = {
244-
title: withDefault(StringControl, trans("echarts.defaultTitle")),
245-
data: jsonControl(toJSONObjectArray, i18nObjs.defaultDataSource),
246-
xAxisKey: valueComp<string>(""), // x-axis, key from data
278+
title: withDefault(StringControl, trans("barChart.defaultTitle")),
279+
data: jsonControl(toJSONObjectArray, barChartDefaultData),
280+
xAxisKey: valueComp<string>("month"), // x-axis, key from data
247281
xAxisDirection: dropdownControl(XAxisDirectionOptions, "horizontal"),
248282
xAxisData: jsonControl(toArray, []),
249283
series: SeriesListComp,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ const BarTypeOptions = [
3333
export const BarChartConfig = (function () {
3434
return new MultiCompBuilder(
3535
{
36-
showLabel: BoolControl,
36+
showLabel: withDefault(BoolControl, true),
3737
type: dropdownControl(BarTypeOptions, "basicBar"),
38-
barWidth: withDefault(NumberControl, i18nObjs.defaultBarChartOption.barWidth),
39-
showBackground: BoolControl,
38+
barWidth: withDefault(NumberControl, 40),
39+
showBackground: withDefault(BoolControl, false),
4040
backgroundColor: withDefault(ColorControl, i18nObjs.defaultBarChartOption.barBg),
4141
radiusAxisMax: NumberControl,
4242
polarRadiusStart: withDefault(StringControl, '30'),

0 commit comments

Comments
 (0)