Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import opacityToHex from "../../util/opacityToHex";
import parseBackground from "../../util/gradientBackgroundColor";
import {ba} from "@fullcalendar/core/internal-common";
import {chartStyleWrapper, styleWrapper} from "../../util/styleWrapper";
import { mergeCartesianAxis } from "../../util/echartsThemeUtils";

export function transformData(
originData: JSONObject[],
Expand Down Expand Up @@ -310,22 +311,27 @@ export function getEchartsConfig(
);
config = {
...config,
xAxis: mergeCartesianAxis(
theme,
finalXyConfig.xConfig.type,
finalXyConfig.xConfig,
props?.xAxisStyle,
11,
{
data: finalXyConfig.xConfig.type === "category" && (props.xAxisData as []).length!==0?props?.xAxisData:transformedData.map((i: any) => i[props.xAxisKey]),
}
),
// @ts-ignore
xAxis: {
...finalXyConfig.xConfig,
axisLabel: {
...styleWrapper(props?.xAxisStyle, theme?.xAxisStyle, 11)
},
data: finalXyConfig.xConfig.type === "category" && (props.xAxisData as []).length!==0?props?.xAxisData:transformedData.map((i: any) => i[props.xAxisKey]),
},
// @ts-ignore
yAxis: {
...finalXyConfig.yConfig,
axisLabel: {
...styleWrapper(props?.yAxisStyle, theme?.yAxisStyle, 11)
},
data: finalXyConfig.yConfig.type === "category" && (props.xAxisData as []).length!==0?props?.xAxisData:transformedData.map((i: any) => i[props.xAxisKey]),
},
yAxis: mergeCartesianAxis(
theme,
finalXyConfig.yConfig.type,
finalXyConfig.yConfig,
props?.yAxisStyle,
11,
{
data: finalXyConfig.yConfig.type === "category" && (props.xAxisData as []).length!==0?props?.xAxisData:transformedData.map((i: any) => i[props.xAxisKey]),
}
),
};

if(props.chartConfig.race) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { XAXisComponentOption, YAXisComponentOption } from "echarts";
import { ChartSize, XAxisDirectionType } from "../chartConstants";
import { i18n } from "lowcoder-core";
import {
MultiCompBuilder,
withContext,
Expand All @@ -11,9 +10,27 @@ import {
isNumeric,
} from "lowcoder-sdk";
import { i18nObjs, trans } from "i18n/comps";
import _, { isNil } from "lodash";
import _ from "lodash";
import { xAxisTypeUrl } from "./chartUrls";

/** Y-axis format from Properties; undefined when the format field is left empty. */
function buildUserAxisLabelFormatter(formatEvaluator: unknown) {
if (typeof formatEvaluator !== "function") {
return undefined;
}
const evaluate = formatEvaluator as (ctx: { value: unknown }) => string;
const sample = evaluate({ value: 0 });
if (sample == null || String(sample).trim() === "") {
return undefined;
}
return {
formatter: (value: string | number) => {
const formatted = evaluate({ value });
return formatted != null && formatted !== "" ? formatted : String(value);
},
};
}

const XAxisTypeOptions = [
{
label: trans("chart.auto"),
Expand Down Expand Up @@ -137,24 +154,10 @@ export const YAxisConfig = (function () {
align: "left",
},
};
const numberFormat = new Intl.NumberFormat(i18n.locales, {
notation: "compact",
});
(config.axisLabel as any) = {
formatter: (value: string | number) => {
const res = (props.formatter as any)({ value: value });
if (!isNil(res) && res !== "") {
return res;
}
if (
(props.yAxisType === "value" || props.yAxisType === "log") &&
typeof value === "number"
) {
return numberFormat.format(value);
}
return value + "";
},
};
const userAxisLabel = buildUserAxisLabelFormatter(props.formatter);
if (userAxisLabel) {
(config.axisLabel as any) = userAxisLabel;
}
if (props.yAxisType === "log") {
(config as any).logBase = props.logBase || 10;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { calcXYConfig } from "comps/chartComp/chartConfigs/cartesianAxisConfig";
import Big from "big.js";
import { googleMapsApiUrl } from "./chartConfigs/chartUrls";
import {chartStyleWrapper, styleWrapper} from "../../util/styleWrapper";
import { mergeCartesianAxis } from "../../util/echartsThemeUtils";
import parseBackground from "../../util/gradientBackgroundColor";

export function transformData(
Expand Down Expand Up @@ -260,20 +261,19 @@ export function getEchartsConfig(
);
config = {
...config,
xAxis: mergeCartesianAxis(
theme,
finalXyConfig.xConfig.type,
finalXyConfig.xConfig,
props?.xAxisStyle
),
// @ts-ignore
xAxis: {
...finalXyConfig.xConfig,
axisLabel: {
...styleWrapper(props?.xAxisStyle, theme?.xAxisStyle, 11)
}
},
// @ts-ignore
yAxis: {
...finalXyConfig.yConfig,
axisLabel: {
...styleWrapper(props?.yAxisStyle, theme?.yAxisStyle, 11)
}
},
yAxis: mergeCartesianAxis(
theme,
finalXyConfig.yConfig.type,
finalXyConfig.yConfig,
props?.yAxisStyle
),
};
}
// console.log("Echarts transformedData and config", transformedData, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ BoxplotChartTmpComp = withViewFn(BoxplotChartTmpComp, (comp) => {
notMerge
lazyUpdate
opts={{ locale: getEchartsLocale() }}
theme={themeConfig}
option={option}
mode={mode}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import _ from "lodash";
import { googleMapsApiUrl } from "../basicChartComp/chartConfigs/chartUrls";
import parseBackground from "../../util/gradientBackgroundColor";
import {chartStyleWrapper, styleWrapper} from "../../util/styleWrapper";
import { mergeCartesianAxis } from "../../util/echartsThemeUtils";
// Define the configuration interface to match the original transform

interface AggregateConfig {
Expand Down Expand Up @@ -155,21 +156,25 @@ export function getEchartsConfig(
...gridPos,
containLabel: true,
},
xAxis: {
name: props.xAxisKey,
nameLocation: 'middle',
nameGap: 30,
scale: true,
axisLabel: {
...styleWrapper(props?.xAxisStyle, theme?.xAxisStyle, 11)
}
},
yAxis: {
type: "category",
axisLabel: {
...styleWrapper(props?.yAxisStyle, theme?.yAxisStyle, 11)
}
},
xAxis: mergeCartesianAxis(
theme,
"value",
{
name: props.xAxisKey,
nameLocation: 'middle',
nameGap: 30,
scale: true,
},
props?.xAxisStyle
),
yAxis: mergeCartesianAxis(
theme,
"category",
{
type: "category",
},
props?.yAxisStyle
),
dataset: [
{
id: 'raw',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { googleMapsApiUrl } from "../chartComp/chartConfigs/chartUrls";
import { useContext } from "react";
import parseBackground from "../../util/gradientBackgroundColor";
import {styleWrapper} from "../../util/styleWrapper";
import { mergeCartesianAxis } from "../../util/echartsThemeUtils";

export function transformData(
originData: JSONObject[],
Expand Down Expand Up @@ -172,39 +173,44 @@ export function getEchartsConfig(
height: props?.dataZoomHeight
}
],
yAxis: {
type: "value",
scale: true,
splitArea: props?.axisFlagVisibility && {
show: true,
areaStyle: {
color: props?.echartsData?.axisColor || props?.echartsOption?.axisColor
}
},
axisLabel: {
...styleWrapper(props?.yAxisStyle, theme?.yAxisStyle, 13),
}
},
xAxis: props?.echartsOption && {
type: 'category',
data: props?.echartsTitleData.length && props?.echartsTitleData || props?.echartsData.xAxis && props?.echartsData.xAxis.data || props?.echartsOption.xAxis && props?.echartsOption.xAxis.data,
splitArea: !props?.axisFlagVisibility && {
show: true,
areaStyle: {
// Provide multiple colors to alternate through
color: props?.echartsData?.axisColor || props?.echartsOption?.axisColor
yAxis: mergeCartesianAxis(
theme,
"value",
{
type: "value",
scale: true,
splitArea: props?.axisFlagVisibility && {
show: true,
areaStyle: {
color: props?.echartsData?.axisColor || props?.echartsOption?.axisColor
}
},
},
axisLabel: {
...styleWrapper(props?.xAxisStyle, theme?.xAxisStyle, 13),
},
boundaryGap: true,
// Turn off x-axis split lines if desired, so you only see colored areas
splitLine: {
show: false
props?.yAxisStyle,
13
),
xAxis: props?.echartsOption && mergeCartesianAxis(
theme,
"category",
{
type: 'category',
data: props?.echartsTitleData.length && props?.echartsTitleData || props?.echartsData.xAxis && props?.echartsData.xAxis.data || props?.echartsOption.xAxis && props?.echartsOption.xAxis.data,
boundaryGap: true,
splitLine: {
show: false
},
},
// Show split areas, each day with a different background color
},
props?.xAxisStyle,
13,
{
splitArea: !props?.axisFlagVisibility && {
show: true,
areaStyle: {
color: props?.echartsData?.axisColor || props?.echartsOption?.axisColor
},
},
}
),
series: props?.echartsOption && [
{
name: props?.echartsConfig.type,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { XAXisComponentOption, YAXisComponentOption } from "echarts";
import { ChartSize, XAxisDirectionType } from "../chartConstants";
import { i18n } from "lowcoder-core";
import {
MultiCompBuilder,
withContext,
Expand All @@ -11,9 +10,27 @@ import {
isNumeric,
} from "lowcoder-sdk";
import { i18nObjs, trans } from "i18n/comps";
import _, { isNil } from "lodash";
import _ from "lodash";
import { xAxisTypeUrl } from "./chartUrls";

/** Y-axis format from Properties; undefined when the format field is left empty. */
function buildUserAxisLabelFormatter(formatEvaluator: unknown) {
if (typeof formatEvaluator !== "function") {
return undefined;
}
const evaluate = formatEvaluator as (ctx: { value: unknown }) => string;
const sample = evaluate({ value: 0 });
if (sample == null || String(sample).trim() === "") {
return undefined;
}
return {
formatter: (value: string | number) => {
const formatted = evaluate({ value });
return formatted != null && formatted !== "" ? formatted : String(value);
},
};
}

const XAxisTypeOptions = [
{
label: trans("chart.auto"),
Expand Down Expand Up @@ -137,24 +154,10 @@ export const YAxisConfig = (function () {
align: "left",
},
};
const numberFormat = new Intl.NumberFormat(i18n.locales, {
notation: "compact",
});
(config.axisLabel as any) = {
formatter: (value: string | number) => {
const res = (props.formatter as any)({ value: value });
if (!isNil(res) && res !== "") {
return res;
}
if (
(props.yAxisType === "value" || props.yAxisType === "log") &&
typeof value === "number"
) {
return numberFormat.format(value);
}
return value + "";
},
};
const userAxisLabel = buildUserAxisLabelFormatter(props.formatter);
if (userAxisLabel) {
(config.axisLabel as any) = userAxisLabel;
}
if (props.yAxisType === "log") {
(config as any).logBase = props.logBase || 10;
}
Expand Down
Loading
Loading