diff --git a/frontend/app/components/shared/Insights/SankeyChart/SankeyChart.stories.tsx b/frontend/app/components/shared/Insights/SankeyChart/SankeyChart.stories.tsx new file mode 100644 index 000000000..f0e3ed21e --- /dev/null +++ b/frontend/app/components/shared/Insights/SankeyChart/SankeyChart.stories.tsx @@ -0,0 +1,20 @@ +import { storiesOf } from '@storybook/react'; +import SankeyChart from './SankeyChart'; + +const data = { + nodes: [ + { name: 'Home Page' }, + { name: 'Dashboard' }, + { name: 'Preferences' }, + { name: 'Billing' }, + + ], + links: [ + { source: 0, target: 1, value: 100 }, + { source: 1, target: 2, value: 50 }, + { source: 1, target: 3, value: 50 }, + { source: 2, target: 3, value: 10 }, + ], +}; + +storiesOf('SankeyChart', module).add('Pure', () => ); diff --git a/frontend/app/components/shared/Insights/SankeyChart/SankeyChart.tsx b/frontend/app/components/shared/Insights/SankeyChart/SankeyChart.tsx new file mode 100644 index 000000000..c09888102 --- /dev/null +++ b/frontend/app/components/shared/Insights/SankeyChart/SankeyChart.tsx @@ -0,0 +1,121 @@ +import React from 'react'; +import { Sankey, Tooltip, Rectangle, Layer, ResponsiveContainer } from 'recharts'; + +interface Props { + data: any; +} +function SankeyChart(props: Props) { + const { data } = props; + return ( +
+
Sankey Chart
+
+ + } + nodePadding={50} + nodeWidth={10} + margin={{ + left: 10, + right: 100, + top: 10, + bottom: 10, + }} + link={} + > + + + + + + + }/> + + +
+
+ ); +} + +export default SankeyChart; + +const CustomTooltip = (props: any) => { + console.log('props', props); + return ( +
test
+ ) + // if (active && payload && payload.length) { + // return ( + //
+ //

{`${label} : ${payload[0].value}`}

+ //

{getIntroOfPage(label)}

+ //

Anything you want can be displayed here.

+ //
+ // ); + // } + + return null; +}; + +function CustomNodeComponent({ x, y, width, height, index, payload, containerWidth }: any) { + const isOut = x + width + 6 > containerWidth; + return ( + + + + {payload.name} + + + {payload.value + 'k'} + + + ); +} + +const CustomLinkComponent = (props: any) => { + const [fill, setFill] = React.useState('url(#linkGradient)'); + const { sourceX, targetX, sourceY, targetY, sourceControlX, targetControlX, linkWidth, index } = + props; + return ( + + { + setFill('rgba(0, 136, 254, 0.5)'); + }} + onMouseLeave={() => { + setFill('url(#linkGradient)'); + }} + /> + + ); +}; diff --git a/frontend/app/components/shared/Insights/SankeyChart/index.ts b/frontend/app/components/shared/Insights/SankeyChart/index.ts new file mode 100644 index 000000000..d651de3d0 --- /dev/null +++ b/frontend/app/components/shared/Insights/SankeyChart/index.ts @@ -0,0 +1 @@ +export { default } from './SankeyChart'; diff --git a/frontend/app/components/shared/Insights/ScatterChart/ScatterChart.stories.tsx b/frontend/app/components/shared/Insights/ScatterChart/ScatterChart.stories.tsx new file mode 100644 index 000000000..a56381cf7 --- /dev/null +++ b/frontend/app/components/shared/Insights/ScatterChart/ScatterChart.stories.tsx @@ -0,0 +1,23 @@ +import { storiesOf } from '@storybook/react'; +import ScatterChart from './ScatterChart'; + +const data01 = [ + { x: 100, y: 200, z: 200 }, + { x: 120, y: 100, z: 260 }, + { x: 170, y: 300, z: 400 }, + { x: 140, y: 250, z: 280 }, + { x: 150, y: 400, z: 500 }, + { x: 110, y: 280, z: 200 }, +]; +const data02 = [ + { x: 200, y: 260, z: 240 }, + { x: 240, y: 290, z: 220 }, + { x: 190, y: 290, z: 250 }, + { x: 198, y: 250, z: 210 }, + { x: 180, y: 280, z: 260 }, + { x: 210, y: 220, z: 230 }, +]; + +storiesOf('ScatterChart', module).add('Pure', () => ( + +)); diff --git a/frontend/app/components/shared/Insights/ScatterChart/ScatterChart.tsx b/frontend/app/components/shared/Insights/ScatterChart/ScatterChart.tsx new file mode 100644 index 000000000..3d0566b4e --- /dev/null +++ b/frontend/app/components/shared/Insights/ScatterChart/ScatterChart.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import { + ScatterChart, + Scatter, + Tooltip, + CartesianGrid, + XAxis, + YAxis, + ZAxis, + Legend, + ResponsiveContainer, +} from 'recharts'; + +interface Props { + dataFirst: any; + dataSecond: any; +} +function ScatterChartComponent(props: Props) { + const { dataFirst, dataSecond } = props; + return ( +
+
Scatter Chart
+
+ + + + + + + + + + + + +
+
+ ); +} + +export default ScatterChartComponent; diff --git a/frontend/app/components/shared/Insights/ScatterChart/index.ts b/frontend/app/components/shared/Insights/ScatterChart/index.ts new file mode 100644 index 000000000..26b894075 --- /dev/null +++ b/frontend/app/components/shared/Insights/ScatterChart/index.ts @@ -0,0 +1 @@ +export { default } from './ScatterChart';