Skip to content

Commit d2f4f77

Browse files
committed
Added isColorString.ts, and fixed an issue that put incorrect color.
1 parent 8d1611b commit d2f4f77

File tree

3 files changed

+48
-36
lines changed

3 files changed

+48
-36
lines changed

client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartPropertyView.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export function sankeyChartPropertyView(
4646
{children.nodeWidth.propertyView({ label: trans("sankeyChart.nodeWidth"), tooltip: trans("sankeyChart.nodeWidthTooltip") })}
4747
{children.nodeGap.propertyView({ label: trans("sankeyChart.nodeGap"), tooltip: trans("sankeyChart.nodeGapTooltip") })}
4848

49-
5049
{children.draggable.propertyView({label: trans("sankeyChart.draggable"), tooltip: trans("sankeyChart.draggableTooltip")})}
5150
{children.focus.propertyView({label: trans("sankeyChart.focus"), tooltip: trans("sankeyChart.focusTooltip")})}
5251
{children.tooltip.propertyView({label: trans("sankeyChart.tooltip"), tooltip: trans("echarts.tooltipTooltip")})}

client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartUtils.ts

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Big from "big.js";
1414
import { googleMapsApiUrl } from "../chartComp/chartConfigs/chartUrls";
1515
import {chartStyleWrapper, styleWrapper} from "../../util/styleWrapper";
1616
import parseBackground from "../../util/gradientBackgroundColor";
17+
import isColorString from "../../util/isColorString";
1718

1819
export function transformData(
1920
originData: JSONObject[],
@@ -135,6 +136,10 @@ export function getEchartsConfig(
135136
chartSize?: ChartSize,
136137
theme?: any,
137138
): EChartsOptionWithMap {
139+
console.log(props.echartsOption && props?.echartsOption?.data?.map(item => ({
140+
name: item.name,
141+
itemStyle: item.color && {color: item.color}
142+
})))
138143
if (props.mode === "json") {
139144
let opt={
140145
title: {
@@ -148,43 +153,46 @@ export function getEchartsConfig(
148153
backgroundColor: parseBackground(
149154
props?.chartStyle?.background || theme?.chartStyle?.backgroundColor || "#FFFFFF"
150155
),
151-
"tooltip": props.tooltip&&{
152-
"trigger": "item",
153-
"formatter": "{a} <br/>{b} : {c}%"
154-
},
155-
"series": [
156-
{
157-
"name": props.echartsConfig.type,
158-
"type": props.echartsConfig.type,
159-
left: `${props?.left}%`,
160-
right: `${props?.right}%`,
161-
bottom: `${props?.bottom}%`,
162-
top: `${props?.top}%`,
163-
"label": {
164-
"show": true,
165-
"position": props.echartsLabelConfig.top,
166-
...styleWrapper(props?.detailStyle, theme?.detailStyle,15)
156+
tooltip: props.tooltip&&{
157+
trigger: "item",
158+
formatter: "{a} <br/>{b} : {c}%"
167159
},
168-
"data": props.echartsOption?.data?.map(item => ({name: item.name, itemStyle: {color: item.color}})),
169-
"links":props.echartsOption.links,
170-
emphasis: {
171-
focus: props?.focus ? 'adjacency' : undefined,
172-
},
173-
lineStyle: {
174-
...chartStyleWrapper(props?.lineStyle, theme?.lineStyle),
175-
color: 'gradient',
176-
curveness: props?.curveness,
177-
opacity: props?.opacity,
178-
},
179-
itemStyle: {
180-
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle),
181-
},
182-
nodeWidth: props?.nodeWidth,
183-
nodeGap: props?.nodeGap,
184-
draggable: props?.draggable,
160+
series: [
161+
{
162+
name: props.echartsConfig.type,
163+
type: props.echartsConfig.type,
164+
left: `${props?.left}%`,
165+
right: `${props?.right}%`,
166+
bottom: `${props?.bottom}%`,
167+
top: `${props?.top}%`,
168+
label: {
169+
show: true,
170+
position: props.echartsLabelConfig.top,
171+
...styleWrapper(props?.detailStyle, theme?.detailStyle,15)
172+
},
173+
data: props.echartsOption && props?.echartsOption?.data?.map(item => ({
174+
name: item.name,
175+
itemStyle: isColorString(item.color) && {color: item.color}
176+
})),
177+
links:props.echartsOption.links,
178+
emphasis: {
179+
focus: props?.focus ? 'adjacency' : undefined,
180+
},
181+
lineStyle: {
182+
...chartStyleWrapper(props?.lineStyle, theme?.lineStyle),
183+
color: 'gradient',
184+
curveness: props?.curveness,
185+
opacity: props?.opacity,
186+
},
187+
itemStyle: {
188+
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle),
189+
},
190+
nodeWidth: props?.nodeWidth,
191+
nodeGap: props?.nodeGap,
192+
draggable: props?.draggable,
193+
}
194+
]
185195
}
186-
]
187-
}
188196
return props.echartsOption ? opt : {};
189197

190198
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default function isColorString(color: string) {
2+
const element = document.createElement("isColorString");
3+
element.style.backgroundColor = color;
4+
return element.style.backgroundColor !== '';
5+
}

0 commit comments

Comments
 (0)