-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6fd8f9
commit b55af56
Showing
9 changed files
with
388 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/lab/src/components/Flow/stories/CustomDrop/BarChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { css } from "@emotion/css"; | ||
import { HvFlowNode } from "@hitachivantara/uikit-react-lab"; | ||
import { HvBarChart } from "@hitachivantara/uikit-react-viz"; | ||
import { useStore } from "reactflow"; | ||
|
||
import { data } from "./data"; | ||
|
||
export const BarChart = (props) => { | ||
const { id } = props; | ||
const nodes = useStore((state) => state.getNodes()); | ||
const edges = useStore((state) => state.edges); | ||
const dataNodeId = edges.find((e) => e.target === id)?.source; | ||
const dataNode = nodes.find((n) => n.id === dataNodeId); | ||
|
||
return ( | ||
<HvFlowNode | ||
description="Bar Chart" | ||
expanded | ||
classes={{ root: css({ width: 500 }) }} | ||
{...props} | ||
> | ||
{dataNode && dataNode.data && dataNode.data.country && ( | ||
<div> | ||
<HvBarChart | ||
data={data[dataNode.data.country]} | ||
groupBy="Month" | ||
measures="Precipitation" | ||
grid={{ top: 10, bottom: 40, right: 10, left: 40 }} | ||
/> | ||
</div> | ||
)} | ||
</HvFlowNode> | ||
); | ||
}; | ||
|
||
BarChart.meta = { | ||
label: "Bar Chart", | ||
groupId: "visualizations", | ||
inputs: [ | ||
{ | ||
label: "Data", | ||
isMandatory: true, | ||
accepts: ["data"], | ||
}, | ||
], | ||
}; |
46 changes: 46 additions & 0 deletions
46
packages/lab/src/components/Flow/stories/CustomDrop/LineChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { css } from "@emotion/css"; | ||
import { HvFlowNode } from "@hitachivantara/uikit-react-lab"; | ||
import { HvLineChart } from "@hitachivantara/uikit-react-viz"; | ||
import { useStore } from "reactflow"; | ||
|
||
import { data } from "./data"; | ||
|
||
export const LineChart = (props) => { | ||
const { id } = props; | ||
const nodes = useStore((state) => state.getNodes()); | ||
const edges = useStore((state) => state.edges); | ||
const dataNodeId = edges.find((e) => e.target === id)?.source; | ||
const dataNode = nodes.find((n) => n.id === dataNodeId); | ||
|
||
return ( | ||
<HvFlowNode | ||
description="Line Chart" | ||
expanded | ||
classes={{ root: css({ width: 500 }) }} | ||
{...props} | ||
> | ||
{dataNode && dataNode.data && dataNode.data.country && ( | ||
<div> | ||
<HvLineChart | ||
data={data[dataNode.data.country]} | ||
groupBy="Month" | ||
measures="Precipitation" | ||
grid={{ top: 10, bottom: 40, right: 10, left: 40 }} | ||
/> | ||
</div> | ||
)} | ||
</HvFlowNode> | ||
); | ||
}; | ||
|
||
LineChart.meta = { | ||
label: "Line Chart", | ||
groupId: "visualizations", | ||
inputs: [ | ||
{ | ||
label: "Data", | ||
isMandatory: true, | ||
accepts: ["data"], | ||
}, | ||
], | ||
}; |
33 changes: 33 additions & 0 deletions
33
packages/lab/src/components/Flow/stories/CustomDrop/Precipitation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { HvFlowNode } from "@hitachivantara/uikit-react-lab"; | ||
|
||
import { data } from "./data"; | ||
|
||
export const Precipitation = (props) => { | ||
return ( | ||
<HvFlowNode | ||
description="Precipitation data" | ||
expanded | ||
params={[ | ||
{ | ||
id: "country", | ||
label: "Country", | ||
type: "select", | ||
options: Object.keys(data), | ||
}, | ||
]} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
Precipitation.meta = { | ||
label: "Precipitation", | ||
groupId: "sources", | ||
outputs: [ | ||
{ | ||
label: "Data", | ||
isMandatory: true, | ||
provides: "data", | ||
}, | ||
], | ||
}; |
35 changes: 35 additions & 0 deletions
35
packages/lab/src/components/Flow/stories/CustomDrop/data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const months = [ | ||
"January", | ||
"February", | ||
"March", | ||
"April", | ||
"May", | ||
"June", | ||
"July", | ||
"August", | ||
"September", | ||
"October", | ||
"November", | ||
"December", | ||
]; | ||
|
||
export const data = { | ||
portugal: { | ||
Month: months, | ||
Precipitation: [ | ||
12.6, 15.9, 19.0, 26.0, 28.2, 70.7, 145.6, 132.2, 78.7, 22.8, 4.0, 2.9, | ||
], | ||
}, | ||
usa: { | ||
Month: months, | ||
Precipitation: [ | ||
32.2, 17.2, 12.9, 22.0, 11.2, 99.7, 92.6, 11.2, 23.7, 19.8, 2.0, 7.9, | ||
], | ||
}, | ||
japan: { | ||
Month: months, | ||
Precipitation: [ | ||
12.4, 34.9, 18.0, 45.2, 33.2, 67.7, 187.6, 245.2, 22.7, 12.8, 1.0, 6.9, | ||
], | ||
}, | ||
}; |
Oops, something went wrong.