Skip to content

Remote Chart #1451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 19, 2025
Merged
Prev Previous commit
Next Next commit
Fixed an issue that the theme is not applied because some properties …
…are not defined
  • Loading branch information
Imiss-U1025 committed Jan 19, 2025
commit 451a0f6b77d902ea37355dcac13dec45c389884c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Big from "big.js";
import { googleMapsApiUrl } from "../chartComp/chartConfigs/chartUrls";
import opacityToHex from "../../util/opacityToHex";
import parseBackground from "../../util/gradientBackgroundColor";
import {chartStyleWrapper, styleWrapper} from "../../util/styleWrapper";

export function transformData(
originData: JSONObject[],
Expand Down Expand Up @@ -143,15 +144,7 @@ export function getEchartsConfig(
"top": props.echartsTitleVerticalConfig.top,
"left":props.echartsTitleConfig.top,
"textStyle": {
"fontFamily": props?.titleStyle?.chartFontFamily || theme?.titleStyle?.fontFamily,
"fontSize": props?.titleStyle?.chartTextSize || theme?.titleStyle?.fontSize || '18',
"fontWeight": props?.titleStyle?.chartTextWeight || theme?.titleStyle?.fontWeight,
"color": props?.titleStyle?.chartTextColor || theme?.titleStyle?.fontColor || "#000000",
"fontStyle": props?.titleStyle?.chartFontStyle || theme?.titleStyle?.fontStyle,
"textShadowColor": props?.titleStyle?.chartShadowColor || theme?.titleStyle?.shadowColor,
"textShadowBlur": props?.titleStyle?.chartBoxShadow?.split('px')[0] || theme?.titleStyle?.boxShadow?.split('px')[0],
"textShadowOffsetX": props?.titleStyle?.chartBoxShadow?.split('px')[1] || theme?.titleStyle?.boxShadow?.split('px')[1],
"textShadowOffsetY": props?.titleStyle?.chartBoxShadow?.split('px')[2] || theme?.titleStyle?.boxShadow?.split('px')[2]
...styleWrapper(props?.titleStyle, theme?.titleStyle)
}
},
"backgroundColor": parseBackground( props?.chartStyle?.background || theme?.chartStyle?.backgroundColor || "#FFFFFF"),
Expand All @@ -166,15 +159,7 @@ export function getEchartsConfig(
"left": props.echartsLegendAlignConfig.left,
"orient": props.echartsLegendOrientConfig.orient,
"textStyle": {
"fontFamily": props?.legendStyle?.chartFontFamily || theme?.legendStyle?.fontFamily,
"fontSize": props?.legendStyle?.chartTextSize || theme?.legendStyle?.fontSize,
"fontWeight": props?.legendStyle?.chartTextWeight || theme?.legendStyle?.fontWeight,
"color": props?.legendStyle?.chartTextColor || theme?.legendStyle?.fontColor || "#000000",
"fontStyle": props?.legendStyle?.chartFontStyle || theme?.legendStyle?.fontStyle,
"textShadowColor": props?.legendStyle?.chartShadowColor || theme?.legendStyle?.shadowColor,
"textShadowBlur": props?.legendStyle?.chartBoxShadow?.split('px')[0] || theme?.legendStyle?.boxShadow?.split('px')[0],
"textShadowOffsetX": props?.legendStyle?.chartBoxShadow?.split('px')[1] || theme?.legendStyle?.boxShadow?.split('px')[1],
"textShadowOffsetY": props?.legendStyle?.chartBoxShadow?.split('px')[2] || theme?.legendStyle?.boxShadow?.split('px')[2]
...styleWrapper(props?.legendStyle, theme?.legendStyle)
}
},
"series": [
Expand All @@ -192,27 +177,12 @@ export function getEchartsConfig(
"sort": props.echartsSortingConfig.sort,
"itemStyle": {
"opacity": props.opacity,
"borderColor": props?.chartStyle?.chartBorderColor || theme?.chartStyle?.borderColor,
"borderWidth": props?.chartStyle?.chartBorderWidth || theme?.chartStyle?.borderWidth,
"borderType": props?.chartStyle?.chartBorderStyle || theme?.chartStyle?.borderType,
"borderRadius": Number(props?.chartStyle?.chartBorderRadius || theme?.chartStyle?.borderRadius),
"shadowColor": props?.chartStyle?.chartShadowColor || theme?.chartStyle?.shadowColor,
"shadowBlur": props?.chartStyle?.chartBoxShadow?.split('px')[0] || theme?.chartStyle?.boxShadow?.split('px')[0],
"shadowOffsetX": props?.chartStyle?.chartBoxShadow?.split('px')[1] || theme?.chartStyle?.boxShadow?.split('px')[1],
"shadowOffsetY": props?.chartStyle?.chartBoxShadow?.split('px')[2] || theme?.chartStyle?.boxShadow?.split('px')[2]
...chartStyleWrapper(props?.chartStyle,theme?.chartStyle),
},
"label": {
"show": props.label,
"position": props.echartsLabelConfig.top,
"fontFamily": props?.labelStyle?.chartFontFamily || theme?.labelStyle?.fontFamily,
"fontSize": props?.labelStyle?.chartTextSize || theme?.labelStyle?.fontSize,
"fontWeight": props?.labelStyle?.chartTextWeight || theme?.labelStyle?.fontWeight,
"color": props?.labelStyle?.chartTextColor || theme?.labelStyle?.fontColor || "#000000",
"fontStyle": props?.labelStyle?.chartFontStyle || theme?.labelStyle?.fontStyle,
"textShadowColor": props?.labelStyle?.chartShadowColor || theme?.labelStyle?.shadowColor,
"textShadowBlur": props?.labelStyle?.chartBoxShadow?.split('px')[0] || theme?.labelStyle?.boxShadow?.split('px')[0],
"textShadowOffsetX": props?.labelStyle?.chartBoxShadow?.split('px')[1] || theme?.labelStyle?.boxShadow?.split('px')[1],
"textShadowOffsetY": props?.labelStyle?.chartBoxShadow?.split('px')[2] || theme?.labelStyle?.boxShadow?.split('px')[2]
...styleWrapper(props?.labelStyle,theme?.labelStyle),
},
"data": props.echartsOption.data
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { googleMapsApiUrl } from "../chartComp/chartConfigs/chartUrls";
import opacityToHex from "../../util/opacityToHex";
import parseBackground from "../../util/gradientBackgroundColor";
import {ba} from "@fullcalendar/core/internal-common";
import {styleWrapper} from "../../util/styleWrapper";
import {chartStyleWrapper, styleWrapper} from "../../util/styleWrapper";

export function transformData(
originData: JSONObject[],
Expand Down Expand Up @@ -195,14 +195,7 @@ export function getEchartsConfig(
},
"itemStyle": {
"opacity": props?.opacity,
"borderColor": props?.chartStyle?.chartBorderColor || theme?.chartStyle?.borderColor,
"borderWidth": props?.chartStyle?.chartBorderWidth || theme?.chartStyle?.borderWidth,
"borderType": props?.chartStyle?.chartBorderStyle || theme?.chartStyle?.borderType,
"borderRadius": Number(props?.chartStyle?.chartBorderRadius || theme?.chartStyle?.borderRadius),
"shadowColor": props?.chartStyle?.chartShadowColor || theme?.chartStyle?.shadowColor,
"shadowBlur": props?.chartStyle?.chartBoxShadow?.split('px')[0] || theme?.chartStyle?.boxShadow?.split('px')[0],
"shadowOffsetX": props?.chartStyle?.chartBoxShadow?.split('px')[1] || theme?.chartStyle?.boxShadow?.split('px')[1],
"shadowOffsetY": props?.chartStyle?.chartBoxShadow?.split('px')[2] || theme?.chartStyle?.boxShadow?.split('px')[2]
...chartStyleWrapper(props?.chartStyle,theme?.chartStyle),
},
"progress": {
"roundCap": props.roundCap,
Expand Down
18 changes: 9 additions & 9 deletions client/packages/lowcoder-comps/src/util/styleWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ export const styleWrapper = (styleContainer: any, themeContainer: any, defaultFo
"color": styleContainer?.chartTextColor || themeContainer?.fontColor || defaultFontColor,
"fontStyle": styleContainer?.chartFontStyle || themeContainer?.fontStyle,
"textShadowColor": styleContainer?.chartShadowColor || themeContainer?.shadowColor,
"textShadowBlur": styleContainer?.chartBoxShadow?.split('px')[0] || themeContainer?.boxShadow?.split('px')[0],
"textShadowOffsetX": styleContainer?.chartBoxShadow?.split('px')[1] || themeContainer?.boxShadow?.split('px')[1],
"textShadowOffsetY": styleContainer?.chartBoxShadow?.split('px')[2] || themeContainer?.boxShadow?.split('px')[2],
"textShadowBlur": styleContainer?.chartBoxShadow?.split('px')[0] || themeContainer?.boxShadow && themeContainer?.boxShadow?.split('px')[0],
"textShadowOffsetX": styleContainer?.chartBoxShadow?.split('px')[1] || themeContainer?.boxShadow && themeContainer?.boxShadow?.split('px')[1],
"textShadowOffsetY": styleContainer?.chartBoxShadow?.split('px')[2] || themeContainer?.boxShadow && themeContainer?.boxShadow?.split('px')[2],
"borderColor": styleContainer?.chartBorderColor || themeContainer?.borderColor || 'inherit',
"borderWidth": styleContainer?.chartBorderWidth || themeContainer?.borderWidth || detailBorderWidth,
"borderType": styleContainer?.chartBorderStyle || themeContainer?.borderType,
"borderRadius": Number(styleContainer?.chartBorderRadius || themeContainer?.borderRadius),
"backgroundColor": styleContainer?.chartBackgroundColor || themeContainer?.backgroundColor || defaultBackgroundColor,
"width": styleContainer?.detailSize?.split('px')[0] || themeContainer?.detailSize.split('px')[0],
"height": styleContainer?.detailSize?.split('px')[1] || themeContainer?.detailSize.split('px')[1],
"padding": styleContainer?.padding?.split('px').filter(Boolean).map(Number) || themeContainer?.padding?.split('px').filter(Boolean).map(Number) || [0,0,0,0]
"width": styleContainer?.detailSize?.split('px')[0] || themeContainer?.detailSize && themeContainer?.detailSize.split('px')[0],
"height": styleContainer?.detailSize?.split('px')[1] || themeContainer?.detailSize && themeContainer?.detailSize.split('px')[1],
"padding": styleContainer?.padding?.split('px').filter(Boolean).map(Number) || themeContainer?.padding && themeContainer?.padding?.split('px').filter(Boolean).map(Number) || [0,0,0,0]
}
}

export const chartStyleWrapper = (styleContainer: any, themeContainer: any, detailBorderWidth = 0) => {

return {
"shadowColor": styleContainer?.chartShadowColor || themeContainer?.shadowColor,
"shadowBlur": styleContainer?.chartBoxShadow?.split('px')[0] || themeContainer?.boxShadow?.split('px')[0],
"shadowOffsetX": styleContainer?.chartBoxShadow?.split('px')[1] || themeContainer?.boxShadow?.split('px')[1],
"shadowOffsetY": styleContainer?.chartBoxShadow?.split('px')[2] || themeContainer?.boxShadow?.split('px')[2],
"shadowBlur": styleContainer?.chartBoxShadow?.split('px')[0] || themeContainer?.boxShadow && themeContainer?.boxShadow?.split('px')[0],
"shadowOffsetX": styleContainer?.chartBoxShadow?.split('px')[1] || themeContainer?.boxShadow && themeContainer?.boxShadow?.split('px')[1],
"shadowOffsetY": styleContainer?.chartBoxShadow?.split('px')[2] || themeContainer?.boxShadow && themeContainer?.boxShadow?.split('px')[2],
"borderColor": styleContainer?.chartBorderColor || themeContainer?.borderColor || 'inherit',
"borderWidth": styleContainer?.chartBorderWidth || themeContainer?.borderWidth || detailBorderWidth,
"borderType": styleContainer?.chartBorderStyle || themeContainer?.borderType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ async function npmLoader(

const applicationId = (!appId || appId && appId === PUBLIC_APP_ID) ? 'none' : appId;

const entry = `${pluginBaseUrl}/${applicationId}/${packageName}@${localPackageVersion}/index.js`;

// const entry = `${pluginBaseUrl}/${applicationId}/${packageName}@${localPackageVersion}/index.js`;
const entry = '../../../../../public/package/index.js';
try {
const module = await import(
/* @vite-ignore */
Expand Down