Skip to content

Commit aabc0ef

Browse files
committed
singleAxis chart
1 parent 703a322 commit aabc0ef

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {
22
MultiCompBuilder,
33
dropdownControl,
44
BoolControl,
5+
NumberControl,
6+
withDefault,
57
showLabelPropertyView,
68
} from "lowcoder-sdk";
79
import { ScatterSeriesOption } from "echarts";
@@ -39,6 +41,8 @@ export const ScatterChartConfig = (function () {
3941
{
4042
showLabel: BoolControl,
4143
shape: dropdownControl(ScatterShapeOptions, "circle"),
44+
singleAxis: BoolControl,
45+
divider: withDefault(NumberControl, 1000),
4246
},
4347
(props): ScatterSeriesOption => {
4448
return {
@@ -47,6 +51,8 @@ export const ScatterChartConfig = (function () {
4751
label: {
4852
show: props.showLabel,
4953
},
54+
singleAxis: props.singleAxis,
55+
divider: props.divider,
5056
};
5157
}
5258
)
@@ -56,6 +62,12 @@ export const ScatterChartConfig = (function () {
5662
{children.shape.propertyView({
5763
label: trans("chart.scatterShape"),
5864
})}
65+
{children.singleAxis.propertyView({
66+
label: trans("scatterChart.singleAxis"),
67+
})}
68+
{children.singleAxis.getView() && children.divider.propertyView({
69+
label: trans("scatterChart.divider"),
70+
})}
5971
</>
6072
))
6173
.build();

client/packages/lowcoder-comps/src/comps/scatterChartComp/scatterChartUtils.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ export function getSeriesConfig(props: EchartsConfigProps) {
117117
]
118118
};
119119
}
120+
if(props.chartConfig.singleAxis) {
121+
config.coordinateSystem = 'singleAxis';
122+
config.singleAxisIndex = index;
123+
config.data = [];
124+
config.symbolSize = function(dataItem) {
125+
return dataItem[1] / props.chartConfig.divider;
126+
}
127+
}
120128
if(s.effect) config.type = "effectScatter";
121129
if(s.symbolSize) config.symbolSize = s.symbolSize;
122130
return config;
@@ -184,10 +192,18 @@ export function getEchartsConfig(
184192
.map((s) => s.getView().columnName);
185193
// y-axis is category and time, data doesn't need to aggregate
186194
let transformedData = props.data;
187-
195+
const seriesConfig = getSeriesConfig(props);
196+
const singleAxis = seriesConfig.map((series, idx) => ({
197+
left: 100,
198+
type: 'category',
199+
boundaryGap: false,
200+
top: (idx * 100) / seriesConfig.length + (100/seriesConfig.length/2) + '%',
201+
height: - 100 / seriesConfig.length / 4 + '%',
202+
}));
203+
188204
config = {
189205
...config,
190-
series: getSeriesConfig(props).map(series => ({
206+
series: seriesConfig.map(series => ({
191207
...series,
192208
itemStyle: {
193209
...series.itemStyle,
@@ -200,6 +216,18 @@ export function getEchartsConfig(
200216
})),
201217
};
202218

219+
if(props.chartConfig.singleAxis) {
220+
config.singleAxis = singleAxis;
221+
delete config.xAxis;
222+
delete config.yAxis;
223+
224+
config.title = seriesConfig.map((series, idx) => ({
225+
textBaseline: 'middle',
226+
top: ((idx + 0.5) * 100) / seriesConfig.length + '%',
227+
text: series.name,
228+
}));
229+
}
230+
203231
console.log("Echarts transformedData and config", transformedData, config);
204232
return config;
205233
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ export const en = {
379379
labelLineLength2: "Label Line Length2",
380380
},
381381
scatterChart: {
382+
divider: "Divider",
383+
singleAxis: "Single Axis",
382384
effect: "Effect",
383385
symbolSize: "Symbol Size",
384386
from: "From",

0 commit comments

Comments
 (0)