From c01476238bfecab76e6188b081f9eb1c2a596d96 Mon Sep 17 00:00:00 2001 From: Ochieng Paul Date: Thu, 28 Mar 2024 14:45:49 +0300 Subject: [PATCH 1/4] worked on tooltips on chart legends and disabled tabs in customize component --- .../components/Charts/components/index.jsx | 52 ++++--------------- .../src/common/components/Customise/index.jsx | 31 ++++++----- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/platform/src/common/components/Charts/components/index.jsx b/platform/src/common/components/Charts/components/index.jsx index 0c93b7e57b..b353e5a81f 100644 --- a/platform/src/common/components/Charts/components/index.jsx +++ b/platform/src/common/components/Charts/components/index.jsx @@ -212,36 +212,6 @@ export const CustomDot = (props) => { return ; }; -/** - * Custom legend tooltip component - * @param {Object} props - */ -const CustomLegendTooltip = ({ tooltipText, children, direction, themeClass }) => { - const [visible, setVisible] = useState(false); - - const tooltipClass = { - top: 'bottom-full mb-3', - bottom: 'top-full mt-3', - }[direction]; - - return ( -
setVisible(true)} - onMouseLeave={() => setVisible(false)}> - {children} - {visible && ( -
-

{tooltipText}

-
- )} -
- ); -}; - /** * Customized legend component * @param {Object} props @@ -265,18 +235,18 @@ export const renderCustomizedLegend = (props) => { }); return ( -
+
{sortedPayload.map((entry, index) => ( - -
- - {truncate(entry.value)} -
-
+
+ + {truncate(entry.value)} +
))}
); diff --git a/platform/src/common/components/Customise/index.jsx b/platform/src/common/components/Customise/index.jsx index 8275e66fd5..e11e576048 100644 --- a/platform/src/common/components/Customise/index.jsx +++ b/platform/src/common/components/Customise/index.jsx @@ -11,7 +11,7 @@ import Toast from '@/components/Toast'; import { RxInfoCircled } from 'react-icons/rx'; import { completeTask } from '@/lib/store/services/checklists/CheckList'; -const tabs = ['Locations']; +const tabs = ['Locations', 'Pollutants']; const CustomiseLocationsComponent = ({ toggleCustomise }) => { const dispatch = useDispatch(); @@ -111,20 +111,23 @@ const CustomiseLocationsComponent = ({ toggleCustomise }) => { Select any 4 locations you would like to feature on your overview page.

-
-
- {tabs.map((tab) => ( -
setSelectedTab(tab)} - className={`px-3 py-2 flex justify-center items-center w-full hover:cursor-pointer text-sm font-medium text-secondary-neutral-light-600${ - selectedTab === tab ? 'border rounded-md bg-white shadow-sm' : '' - }`}> - {tab} -
- ))} + {false && ( +
+ {/* Tab section */} +
+ {tabs.map((tab) => ( +
setSelectedTab(tab)} + className={`px-3 py-2 flex justify-center items-center w-full hover:cursor-pointer text-sm font-medium text-secondary-neutral-light-600${ + selectedTab === tab ? 'border rounded-md bg-white shadow-sm' : '' + }`}> + {tab} +
+ ))} +
-
+ )} {selectedTab === tabs[0] && ( )} From 69fdfb1033a49c5dd7b67dc1c8cfdb121979d5a8 Mon Sep 17 00:00:00 2001 From: Ochieng Paul Date: Thu, 28 Mar 2024 15:01:37 +0300 Subject: [PATCH 2/4] Update Charts.js --- platform/src/common/components/Charts/Charts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/src/common/components/Charts/Charts.js b/platform/src/common/components/Charts/Charts.js index 7873860379..ef5e4ba859 100644 --- a/platform/src/common/components/Charts/Charts.js +++ b/platform/src/common/components/Charts/Charts.js @@ -182,7 +182,7 @@ const Charts = ({ chartType = 'line', width = '100%', height = '100%' }) => { } - tickLine={false} + tickLine={true} axisLine={false} padding={{ left: 30, right: 30 }} /> @@ -238,7 +238,7 @@ const Charts = ({ chartType = 'line', width = '100%', height = '100%' }) => { ))} - } axisLine={false} /> + } axisLine={false} /> Date: Thu, 28 Mar 2024 15:26:04 +0300 Subject: [PATCH 3/4] include intervals 0 for the x-axis points and increase character length to 20 for the legends --- platform/src/common/components/Charts/Charts.js | 9 ++++++++- .../src/common/components/Charts/components/index.jsx | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/src/common/components/Charts/Charts.js b/platform/src/common/components/Charts/Charts.js index ef5e4ba859..8438fda1b1 100644 --- a/platform/src/common/components/Charts/Charts.js +++ b/platform/src/common/components/Charts/Charts.js @@ -185,6 +185,7 @@ const Charts = ({ chartType = 'line', width = '100%', height = '100%' }) => { tickLine={true} axisLine={false} padding={{ left: 30, right: 30 }} + interval={0} /> { ))} - } axisLine={false} /> + } + axisLine={false} + /> { }; export const truncate = (str) => { - return str.length > 10 ? str.substr(0, 10 - 1) + '...' : str; + return str.length > 20 ? str.substr(0, 20 - 1) + '...' : str; }; /** @@ -235,7 +235,7 @@ export const renderCustomizedLegend = (props) => { }); return ( -
+
{sortedPayload.map((entry, index) => (
Date: Thu, 28 Mar 2024 16:55:39 +0300 Subject: [PATCH 4/4] updated --- platform/src/common/components/Charts/Charts.js | 9 +-------- .../src/common/components/Charts/components/index.jsx | 5 +++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/platform/src/common/components/Charts/Charts.js b/platform/src/common/components/Charts/Charts.js index 8438fda1b1..ef5e4ba859 100644 --- a/platform/src/common/components/Charts/Charts.js +++ b/platform/src/common/components/Charts/Charts.js @@ -185,7 +185,6 @@ const Charts = ({ chartType = 'line', width = '100%', height = '100%' }) => { tickLine={true} axisLine={false} padding={{ left: 30, right: 30 }} - interval={0} /> { ))} - } - axisLine={false} - /> + } axisLine={false} /> { }); return ( -
+
{sortedPayload.map((entry, index) => (