Skip to content

Commit a7ab349

Browse files
authored
[WC-2676]: Custom charts events (and more) [WIP] (#1402)
2 parents 8bcadd6 + c4d7821 commit a7ab349

24 files changed

+320
-307
lines changed

packages/pluggableWidgets/any-chart-web/src/AnyChart.tsx

-10
This file was deleted.

packages/pluggableWidgets/any-chart-web/src/hooks/useAnyChart.ts

-151
This file was deleted.

packages/pluggableWidgets/any-chart-web/src/package.xml

-11
This file was deleted.

packages/pluggableWidgets/any-chart-web/src/utils/ChartDataProcessor.ts

-79
This file was deleted.

packages/pluggableWidgets/any-chart-web/README.md renamed to packages/pluggableWidgets/custom-chart-web/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## AnychartWeb
1+
## Custom chart
22

33
[My widget description]
44

packages/pluggableWidgets/any-chart-web/package.json renamed to packages/pluggableWidgets/custom-chart-web/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@mendix/any-chart-web2",
3-
"widgetName": "AnyChart",
2+
"name": "@mendix/custom-chart-web",
3+
"widgetName": "CustomChart",
44
"version": "1.0.0",
55
"description": "",
66
"copyright": "© Mendix Technology BV 2024. All rights reserved.",
@@ -14,18 +14,18 @@
1414
"developmentPort": 3000
1515
},
1616
"mxpackage": {
17-
"name": "AnyChart",
17+
"name": "CustomChart",
1818
"type": "widget",
19-
"mpkName": "com.mendix.widget.web.AnyChart.mpk"
19+
"mpkName": "com.mendix.widget.web.CustomChart.mpk"
2020
},
2121
"marketplace": {
2222
"minimumMXVersion": "10.16.0",
2323
"appNumber": 1234,
24-
"appName": "AnyChart"
24+
"appName": "Custom chart"
2525
},
2626
"testProject": {
2727
"githubUrl": "https://github.com/mendix/testProjects",
28-
"branchName": "any-chart-web"
28+
"branchName": "custom-chart-web"
2929
},
3030
"packagePath": "com.mendix.widget.web",
3131
"scripts": {
@@ -34,9 +34,9 @@
3434
"build": "pluggable-widgets-tools build:web",
3535
"format": "pluggable-widgets-tools format",
3636
"lint": "eslint --ext .jsx,.js,.ts,.tsx src/",
37-
"test": "echo 'FIXME: Finish any-chart-web unit test migration'",
38-
"e2e": "echo 'FIXME: Finish any-chart-web e2e test migration'",
39-
"e2edev": "echo 'FIXME: Finish any-chart-web e2e test migration'",
37+
"test": "echo 'FIXME: Finish custom-chart-web unit test migration'",
38+
"e2e": "echo 'FIXME: Finish custom-chart-web e2e test migration'",
39+
"e2edev": "echo 'FIXME: Finish custom-chart-web e2e test migration'",
4040
"release": "pluggable-widgets-tools release:web",
4141
"create-gh-release": "rui-create-gh-release",
4242
"publish-marketplace": "rui-publish-marketplace",

packages/pluggableWidgets/any-chart-web/src/AnyChart.editorConfig.ts renamed to packages/pluggableWidgets/custom-chart-web/src/CustomChart.editorConfig.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import { Properties } from "@mendix/pluggable-widgets-tools";
12
import {
23
StructurePreviewProps,
34
structurePreviewPalette
45
} from "@mendix/widget-plugin-platform/preview/structure-preview-api";
5-
import { AnyChartPreviewProps } from "../typings/AnyChartProps";
6+
import { CustomChartPreviewProps } from "../typings/CustomChartProps";
67

7-
export function getPreview(_values: AnyChartPreviewProps, isDarkMode: boolean): StructurePreviewProps {
8+
export function getProperties(_values: CustomChartPreviewProps, defaultProperties: Properties): Properties {
9+
return defaultProperties;
10+
}
11+
12+
export function getPreview(_values: CustomChartPreviewProps, isDarkMode: boolean): StructurePreviewProps {
813
const palette = structurePreviewPalette[isDarkMode ? "dark" : "light"];
914
const sampleChartSvg = `
1015
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -33,7 +38,7 @@ export function getPreview(_values: AnyChartPreviewProps, isDarkMode: boolean):
3338
children: [
3439
{
3540
type: "Text",
36-
content: "Any Chart",
41+
content: "Custom Chart",
3742
fontColor: palette.text.primary,
3843
fontSize: 10,
3944
bold: true

packages/pluggableWidgets/any-chart-web/src/AnyChart.editorPreview.tsx renamed to packages/pluggableWidgets/custom-chart-web/src/CustomChart.editorPreview.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ReactElement, createElement } from "react";
2-
import { AnyChartPreviewProps } from "../typings/AnyChartProps";
3-
import AnyChart from "./AnyChart";
2+
import { CustomChartPreviewProps } from "../typings/CustomChartProps";
3+
import CustomChart from "./CustomChart";
44

55
const defaultSampleData = `[{
66
"type": "scatter",
@@ -38,9 +38,9 @@ const defaultConfig = `{
3838
"staticPlot": true
3939
}`;
4040

41-
export function preview(props: AnyChartPreviewProps): ReactElement {
41+
export function preview(props: CustomChartPreviewProps): ReactElement {
4242
const containerProps = {
43-
name: "preview-chart",
43+
name: "preview-custom-chart",
4444
class: props.class,
4545
style: props.styleObject,
4646
tabIndex: 0,
@@ -51,10 +51,10 @@ export function preview(props: AnyChartPreviewProps): ReactElement {
5151
sampleLayout: props.sampleLayout,
5252
configurationOptions: props.configurationOptions || defaultConfig,
5353
widthUnit: props.widthUnit,
54-
width: props.width || 100,
54+
width: props.width || 75,
5555
heightUnit: props.heightUnit,
5656
height: props.height || 75
5757
};
5858

59-
return <AnyChart {...containerProps} />;
59+
return <CustomChart {...containerProps} />;
6060
}
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ReactElement, createElement } from "react";
2+
import { CustomChartContainerProps } from "../typings/CustomChartProps";
3+
import { useCustomChart } from "./hooks/useCustomChart";
4+
import { useActionEvents } from "./hooks/useActionEvents";
5+
import "./ui/CustomChart.scss";
6+
7+
export default function CustomChart(props: CustomChartContainerProps): ReactElement {
8+
const { chartRef, containerStyle } = useCustomChart(props);
9+
const { handleClick } = useActionEvents(props);
10+
11+
return (
12+
<div
13+
ref={chartRef}
14+
className="widget-custom-chart"
15+
style={containerStyle}
16+
tabIndex={props.tabIndex}
17+
onClick={handleClick}
18+
/>
19+
);
20+
}

0 commit comments

Comments
 (0)