📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
feature: user flow
kruzhambus3caa661c608f
diff --git a/package.json b/package.jsonindex 25111e641..a50bee01c 100644--- a/package.json+++ b/package.json@@ -6,6 +6,8 @@"@blaumaus/react-alert": "^7.0.5","@headlessui/react": "^1.7.14","@heroicons/react": "^2.0.17",+ "@nivo/core": "^0.81.0",+ "@nivo/sankey": "^0.81.0","@reduxjs/toolkit": "^1.9.5","@swetrix/sdk": "^1.0.0","@tailwindcss/forms": "^0.5.3",diff --git a/src/pages/Captcha/View/Panels.tsx b/src/pages/Captcha/View/Panels.tsxindex 6683b57e4..b8b0a549b 100644--- a/src/pages/Captcha/View/Panels.tsx+++ b/src/pages/Captcha/View/Panels.tsx@@ -64,7 +64,6 @@ const PanelContainer = ({ </>)}- {name}</h3><div className='flex'>{(checkIfBarsNeeded(type)) && (@@ -515,6 +514,7 @@ const Panel = ({</PanelContainer>)}+// Showing chart of stats a data (start if)if ((id === 'os' || id === 'br' || id === 'dv') && activeFragment === 1 && !_isEmpty(data)) {const tQuantity = t('project.quantity')diff --git a/src/pages/Project/View/Panels.tsx b/src/pages/Project/View/Panels.tsxindex 4364a1eed..661a2e329 100644--- a/src/pages/Project/View/Panels.tsx+++ b/src/pages/Project/View/Panels.tsx@@ -37,12 +37,13 @@ import Button from 'ui/Button'import Chart from 'ui/Chart'import LiveVisitorsDropdown from './components/LiveVisitorsDropdown'import InteractiveMap from './components/InteractiveMap'+import SankeyChart from './components/SankeyChart'import { iconClassName } from './ViewProject.helpers'const ENTRIES_PER_PANEL = 5const ENTRIES_PER_CUSTOM_EVENTS_PANEL = 6-const panelsWithBars = ['cc', 'ce', 'os', 'br', 'dv']+const panelsWithBars = ['cc', 'ce', 'os', 'br', 'dv', 'pg']// function that checks if there are custom tabs for a specific typeconst checkCustomTabs = (panelID: string, customTabs: any) => {@@ -114,6 +115,26 @@ const PanelContainer = ({/></>)}++ {type === 'pg' && (+ <>+ <ChartPieIcon+ className={cx(iconClassName, 'ml-2 cursor-pointer', {+ 'text-blue-500': activeFragment === 1,+ 'text-gray-900 dark:text-gray-50': activeFragment === 0,+ })}+ onClick={() => setActiveFragment(1)}+ />+ <ArrowsPointingOutIcon+ className={cx(iconClassName, 'ml-2 cursor-pointer text-gray-900 dark:text-gray-50', {+ hidden: activeFragment === 0,+ })}+ onClick={openModal}+ />++ </>+ )}+{/* if this tab using Circle showing stats panel */}{(type === 'ce' || type === 'os' || type === 'br' || type === 'dv') && (<ChartPieIcon@@ -734,6 +755,33 @@ const Panel = ({</PanelContainer>)}++ if (id === 'pg' && activeFragment === 1) {+ return (+ <PanelContainer+ name={name}+ icon={icon}+ type={id}+ activeFragment={activeFragment}+ setActiveFragment={setActiveFragment}+ openModal={() => setModal(true)}+ >+ {!modal && (+ <SankeyChart />+ )}+ <Modal+ onClose={() => setModal(false)}+ closeText={t('common.close')}+ isOpened={modal}+ message={(+ <SankeyChart />+ )}+ size='large'+ />+ </PanelContainer>+ )+ }+// Showing chart of stats a data (start if)if ((id === 'os' || id === 'br' || id === 'dv') && activeFragment === 1 && !_isEmpty(data)) {const tQuantity = t('project.quantity')diff --git a/src/pages/Project/View/components/SankeyChart.tsx b/src/pages/Project/View/components/SankeyChart.tsxnew file mode 100644index 000000000..a1db426ec--- /dev/null+++ b/src/pages/Project/View/components/SankeyChart.tsx@@ -0,0 +1,140 @@+import React from 'react'+import { ResponsiveSankey } from '@nivo/sankey'++const dataTest = {+ nodes: [+ {+ id: 'John',+ nodeColor: 'hsl(127, 70%, 50%)',+ },+ {+ id: 'Raoul',+ nodeColor: 'hsl(132, 70%, 50%)',+ },+ {+ id: 'Jane',+ nodeColor: 'hsl(76, 70%, 50%)',+ },+ {+ id: 'Marcel',+ nodeColor: 'hsl(20, 70%, 50%)',+ },+ {+ id: 'Ibrahim',+ nodeColor: 'hsl(225, 70%, 50%)',+ },+ {+ id: 'Junko',+ nodeColor: 'hsl(28, 70%, 50%)',+ },+ ],+ links: [+ {+ source: 'Junko',+ target: 'John',+ value: 88,+ },+ {+ source: 'Junko',+ target: 'Raoul',+ value: 22,+ },+ {+ source: 'Junko',+ target: 'Jane',+ value: 155,+ },+ {+ source: 'Raoul',+ target: 'John',+ value: 153,+ },+ {+ source: 'Marcel',+ target: 'Ibrahim',+ value: 198,+ },+ {+ source: 'Ibrahim',+ target: 'Junko',+ value: 138,+ },+ {+ source: 'Jane',+ target: 'John',+ value: 13,+ },+ {+ source: 'Jane',+ target: 'Raoul',+ value: 200,+ },+ ],+}++const SankeyChart = ({ data }: {+ data?: any+}) => (+ <ResponsiveSankey+ data={dataTest}+ margin={{+ top: 40, right: 160, bottom: 40, left: 50,+ }}+ align='justify'+ colors={{ scheme: 'category10' }}+ nodeOpacity={1}+ nodeHoverOthersOpacity={0.35}+ nodeThickness={18}+ nodeSpacing={24}+ nodeBorderWidth={0}+ nodeBorderColor={{+ from: 'color',+ modifiers: [+ [+ 'darker',+ 0.8,+ ],+ ],+ }}+ nodeBorderRadius={3}+ linkOpacity={0.5}+ linkHoverOthersOpacity={0.1}+ linkContract={3}+ enableLinkGradient+ labelPosition='outside'+ labelOrientation='vertical'+ labelPadding={16}+ labelTextColor={{+ from: 'color',+ modifiers: [+ [+ 'darker',+ 1,+ ],+ ],+ }}+ legends={[+ {+ anchor: 'bottom-right',+ direction: 'column',+ translateX: 130,+ itemWidth: 100,+ itemHeight: 14,+ itemDirection: 'right-to-left',+ itemsSpacing: 2,+ itemTextColor: '#999',+ symbolSize: 14,+ effects: [+ {+ on: 'hover',+ style: {+ itemTextColor: '#000',+ },+ },+ ],+ },+ ]}+ />+)++export default SankeyChart