Skip to content

Commit

Permalink
remove <div>
Browse files Browse the repository at this point in the history
  • Loading branch information
namnguyen20999 committed Dec 19, 2024
1 parent 8928058 commit e719b7c
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions doc/gui/extension/example_library/front-end/src/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,37 @@
*/

import React, { useMemo } from "react";
import { useDynamicJsonProperty, } from "taipy-gui";
import { useDynamicJsonProperty } from "taipy-gui";

import Plot from "react-plotly.js";
import { Data, Layout } from "plotly.js";

interface DashboardProps {
data?: string;
defaultData?: string;
layout?: string;
defaultLayout?: string;
data?: string;
defaultData?: string;
layout?: string;
defaultLayout?: string;
}

const Dashboard = (props: DashboardProps) => {
const value = useDynamicJsonProperty(props.data, props.defaultData || "", {} as Partial<Data>);
const dashboardLayout = useDynamicJsonProperty(props.layout, props.defaultLayout || "", {} as Partial<Layout>);

const data = useMemo(() => {
if (Array.isArray(value)) {
return value as Data[];
}
return [] as Data[];
}, [value]);

const baseLayout = useMemo(() => {
const layout = {
...dashboardLayout,
};
return layout as Partial<Layout>;
}, [dashboardLayout]);

return (
<div>
<Plot data={data} layout={baseLayout} />
</div>
);
const value = useDynamicJsonProperty(props.data, props.defaultData || "", {} as Partial<Data>);
const dashboardLayout = useDynamicJsonProperty(props.layout, props.defaultLayout || "", {} as Partial<Layout>);

const data = useMemo(() => {
if (Array.isArray(value)) {
return value as Data[];
}
return [] as Data[];
}, [value]);

const baseLayout = useMemo(() => {
const layout = {
...dashboardLayout,
};
return layout as Partial<Layout>;
}, [dashboardLayout]);

return <Plot data={data} layout={baseLayout} />;
};

export default Dashboard;

0 comments on commit e719b7c

Please sign in to comment.