From 1e77033a184a6b7a47ecb04c7677a83cfe5e8bbe Mon Sep 17 00:00:00 2001 From: keppere <50957820+keppere@users.noreply.github.com> Date: Tue, 4 Feb 2025 12:56:27 +0700 Subject: [PATCH 001/106] chart beta (#338) * feat: chart beta * refact: change theme provider --- src/app/storybook/chart-editor/page.tsx | 104 ++++++ src/app/storybook/chart/page.tsx | 7 +- src/app/storybook/layout.tsx | 5 +- src/components/chart/chart-type-button.tsx | 34 ++ src/components/chart/chartTypes.ts | 87 +++++ src/components/chart/echartOptionsBuilder.ts | 370 +++++++++++++++++++ src/components/chart/edit-chart-menu.tsx | 116 ++++++ src/components/chart/index.tsx | 330 +++++++++-------- 8 files changed, 902 insertions(+), 151 deletions(-) create mode 100644 src/app/storybook/chart-editor/page.tsx create mode 100644 src/components/chart/chart-type-button.tsx create mode 100644 src/components/chart/chartTypes.ts create mode 100644 src/components/chart/echartOptionsBuilder.ts create mode 100644 src/components/chart/edit-chart-menu.tsx diff --git a/src/app/storybook/chart-editor/page.tsx b/src/app/storybook/chart-editor/page.tsx new file mode 100644 index 00000000..cf9d48ee --- /dev/null +++ b/src/app/storybook/chart-editor/page.tsx @@ -0,0 +1,104 @@ +"use client"; +import Chart from "@/components/chart"; +import { ChartData, ChartValue } from "@/components/chart/chartTypes"; +import EditChartMenu from "@/components/chart/edit-chart-menu"; +import { useState } from "react"; + +const data: ChartData[] = [ + { + seller: 49, + seller2: 1049, + _year: 2019, + }, + { + seller: 590, + seller2: 1590, + _year: 2020, + }, + { + seller: 7908, + seller2: 8908, + _year: 2021, + }, + { + seller: 4985, + seller2: 5985, + _year: 2022, + }, + { + seller: 2638, + seller2: 3638, + _year: 2023, + }, + { + seller: 4, + seller2: 1004, + _year: 2024, + }, +]; + +const lineChartValue: ChartValue = { + connection_id: null, + created_at: "2025-01-31T08:44:04.868Z", + id: "94019f17-a1e0-4db2-b89e-4457cbed3ce4", + model: "chart", + name: "New Chart", + params: { + id: "94019f17-a1e0-4db2-b89e-4457cbed3ce4", + name: "New Chart", + type: "line", + model: "chart", + apiKey: "", + layers: [ + { + sql: "select count(*) as seller,count(*) + 1000 as seller2, year(l192_new.supplier.registered_date) as _year\nFROM\n supplier\nGROUP BY _year\nhaving _year is not null\nORDER BY _year\n", + type: "line", + }, + ], + options: { + text: "Hello world", + theme: "afterburn", + xAxisKey: "_year", + yAxisKeys: ["seller", "seller2"], + foreground: "#ffffff", + xAxisLabel: "cust year", + yAxisLabel: "cust sellers", + gradientStop: "#42788F", + gradientStart: "#2C4F5E", + backgroundType: "gradient", + yAxisKeyColors: { + seller: "#E75F98", + seller2: "#FFA285", + }, + xAxisLabelHidden: false, + yAxisLabelHidden: false, + yAxisLabelDisplay: "right", + }, + source_id: "856a1855-2bee-4d87-9756-a783088c0568", + created_at: "2025-01-31T08:44:04.868Z", + updated_at: "2025-01-31T08:44:04.868Z", + workspace_id: "3db2e96f-ee43-412d-be09-25fc02d3a463", + connection_id: null, + }, + source_id: "856a1855-2bee-4d87-9756-a783088c0568", + type: "line", + updated_at: "2025-02-02T13:44:55.532Z", + workspace_id: "3db2e96f-ee43-412d-be09-25fc02d3a463", +}; + +export default function StorybookChartEditorPage() { + const [chartValue, setChartValue] = useState(lineChartValue); + const [items, setItems] = useState(data); + const [modifier, setModifier] = useState({}); + return ( +
Type
+Text
+ ++ +
+| + {key} + | + ))} +
|---|
| + {row[key] || ""} + | + ))} +
{
const sizeX = 1;
const sizeY = 1;
- let style: React.CSSProperties = {
+ const style: React.CSSProperties = {
fontSize: sizeX === 1 && sizeY === 1 ? "30px" : "60px",
lineHeight: sizeX === 1 && sizeY === 1 ? "36px" : "68px",
};
@@ -152,13 +152,13 @@ const TableComponent = ({ data }: OuterbaseChartProps) => {
);
};
-const ChartComponent = ({ value, data, modifier }: OuterbaseChartProps) => {
+const ChartComponent = ({ value, data }: OuterbaseChartProps) => {
const domRef = useRef Select X Axis Y Axis Label X Axis Label Data Format Text Text Color Text{props.value.name}
+ Board
- Base
-
StorybookCreateDialogPage
+
+