import React, { lazy, Suspense } from "react"; import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget"; import Skeleton from "components/utils/Skeleton"; import { retryPromise } from "utils/AppsmithUtils"; import { EventType } from "constants/AppsmithActionConstants/ActionConstants"; import propertyConfig from "./propertyConfig"; import { ChartType, CustomFusionChartConfig, AllChartData, ChartSelectedDataPoint, } from "../constants"; import { WidgetType } from "constants/WidgetConstants"; import { ChartComponentProps } from "../component"; const ChartComponent = lazy(() => retryPromise(() => import( /* webpackPrefetch: true, webpackChunkName: "charts" */ "../component" ), ), ); class ChartWidget extends BaseWidget { static getMetaPropertiesMap(): Record { return { selectedDataPoint: undefined, }; } static getPropertyPaneConfig() { return propertyConfig; } onDataPointClick = (selectedDataPoint: ChartSelectedDataPoint) => { this.props.updateWidgetMetaProperty( "selectedDataPoint", selectedDataPoint, { triggerPropertyName: "onDataPointClick", dynamicString: this.props.onDataPointClick, event: { type: EventType.ON_DATA_POINT_CLICK, }, }, ); }; getPageView() { return ( }> ); } static getWidgetType(): WidgetType { return "CHART_WIDGET"; } } export interface ChartWidgetProps extends WidgetProps { chartType: ChartType; chartData: AllChartData; customFusionChartConfig: CustomFusionChartConfig; xAxisName: string; yAxisName: string; chartName: string; isVisible?: boolean; allowHorizontalScroll: boolean; } type ChartComponentPartialProps = Omit; export interface ChartWidgetProps extends WidgetProps, ChartComponentPartialProps { onDataPointClick?: string; } export default ChartWidget;