Skip to content

📈 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!

Use lucide icon for chart type swith

Blue Mouse4dd9777c786e
diff --git a/web/app/pages/Captcha/View/ViewCaptcha.tsx b/web/app/pages/Captcha/View/ViewCaptcha.tsx
index 0a0f41ea1..a3712f66a 100644
--- a/web/app/pages/Captcha/View/ViewCaptcha.tsx
+++ b/web/app/pages/Captcha/View/ViewCaptcha.tsx
@@ -46,10 +46,7 @@ import { useCurrentProject } from '~/providers/CurrentProjectProvider'
import { useTheme } from '~/providers/ThemeProvider'
import Dropdown from '~/ui/Dropdown'
import FlatPicker from '~/ui/Flatpicker'
-import BarChart from '~/ui/icons/BarChart'
-import LineChart from '~/ui/icons/LineChart'
import Loader from '~/ui/Loader'
-import { getItem, setItem } from '~/utils/localstorage'
import routes from '~/utils/routes'
import CCRow from '../../Project/View/components/CCRow'
@@ -188,7 +185,6 @@ const ViewCaptcha = () => {
const timeFormat = useMemo<'12-hour' | '24-hour'>(() => user?.timeFormat || TimeFormat['12-hour'], [user])
const [ref, size] = useSize() as any
const rotateXAxias = useMemo(() => size.width > 0 && size.width < 500, [size])
- const [chartType, setChartType] = useState(getItem('chartType') || chartTypes.line)
const [mainChart, setMainChart] = useState<any>(null)
const { timezone = DEFAULT_TIMEZONE } = user || {}
@@ -259,7 +255,7 @@ const ViewCaptcha = () => {
applyRegions,
timeFormat,
rotateXAxias,
- chartTypes.line, // chartType,
+ chartTypes.line,
)
setChartData(chart)
@@ -379,12 +375,6 @@ const ViewCaptcha = () => {
},
]
- // function set chart type and save to local storage
- const setChartTypeOnClick = (type: string) => {
- setItem('chartType', type)
- setChartType(type)
- }
-
if (authLoading || !project) {
return <PageLoader />
}
@@ -453,46 +443,6 @@ const ViewCaptcha = () => {
buttonClassName='!p-2 rounded-md hover:bg-white border border-gray-50/0 hover:border-gray-300 hover:dark:border-slate-800/50 dark:hover:bg-slate-800 focus:z-10 focus:outline-hidden focus:ring-1 focus:ring-indigo-500 focus:dark:ring-gray-200'
headless
/>
- <div
- className={cx('space-x-2 border-gray-200 sm:mr-3 lg:border-x lg:px-3 dark:border-gray-600', {
- // TODO: Fix a crash when user selects 'bar' chart and refreshes the page:
- // Uncaught TypeError: can't access property "create", point5 is undefined
- hidden: isPanelsDataEmpty || analyticsLoading || true,
- })}
- >
- <button
- type='button'
- title={t('project.barChart')}
- onClick={() => setChartTypeOnClick(chartTypes.bar)}
- className={cx(
- 'relative rounded-md fill-gray-700 p-2 text-sm font-medium focus:z-10 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden dark:fill-gray-50 focus:dark:border-gray-200 focus:dark:ring-gray-200',
- {
- 'border border-gray-300 bg-white stroke-white dark:border-slate-800/50 dark:bg-slate-800 dark:stroke-slate-800':
- chartType === chartTypes.bar,
- 'bg-gray-50 stroke-gray-50 dark:bg-slate-900 dark:stroke-slate-900 [&_svg]:hover:fill-gray-500 [&_svg]:hover:dark:fill-gray-200':
- chartType !== chartTypes.bar,
- },
- )}
- >
- <BarChart className='h-5 w-5 [&_path]:stroke-[3.5%]' />
- </button>
- <button
- type='button'
- title={t('project.lineChart')}
- onClick={() => setChartTypeOnClick(chartTypes.line)}
- className={cx(
- 'relative rounded-md fill-gray-700 p-2 text-sm font-medium focus:z-10 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden dark:fill-gray-50 focus:dark:border-gray-200 focus:dark:ring-gray-200',
- {
- 'border border-gray-300 bg-white stroke-white dark:border-slate-800/50 dark:bg-slate-800 dark:stroke-slate-800':
- chartType === chartTypes.line,
- 'bg-gray-50 stroke-gray-50 dark:bg-slate-900 dark:stroke-slate-900 [&_svg]:hover:fill-gray-500 [&_svg]:hover:dark:fill-gray-200':
- chartType !== chartTypes.line,
- },
- )}
- >
- <LineChart className='h-5 w-5 [&_path]:stroke-[3.5%]' />
- </button>
- </div>
<TBPeriodSelector
activePeriod={activePeriod}
updateTimebucket={updateTimebucket}
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index 3d236681c..378a60961 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -33,6 +33,8 @@ import {
DownloadIcon,
SettingsIcon,
BanIcon,
+ ChartColumnIcon,
+ ChartLineIcon,
} from 'lucide-react'
import React, { useState, useEffect, useMemo, useRef, useCallback, createContext, useContext } from 'react'
import { useHotkeys } from 'react-hotkeys-hook'
@@ -117,8 +119,6 @@ import { useTheme } from '~/providers/ThemeProvider'
import Checkbox from '~/ui/Checkbox'
import Dropdown from '~/ui/Dropdown'
import FlatPicker from '~/ui/Flatpicker'
-import BarChart from '~/ui/icons/BarChart'
-import LineChart from '~/ui/icons/LineChart'
import Loader from '~/ui/Loader'
import Select from '~/ui/Select'
import { trackCustom } from '~/utils/analytics'
@@ -2793,15 +2793,6 @@ const ViewProject = () => {
headless
/>
) : null}
- {/* <button
- type='button'
- title={t('project.refreshStats')}
- onClick={refreshStats}
- className='relative rounded-md border border-gray-50/0 bg-gray-50 p-2 text-sm font-medium hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden dark:bg-slate-900 hover:dark:border-slate-800/50 dark:hover:bg-slate-800 focus:dark:ring-gray-200'
- >
- <RotateCw className='h-5 w-5 text-gray-700 dark:text-gray-50' />
- </button> */}
-
<div
className={cx({
hidden:
@@ -2819,7 +2810,7 @@ const ViewProject = () => {
onClick={() => setChartTypeOnClick(chartTypes.line)}
className='relative rounded-md border border-gray-50/0 bg-gray-50 p-2 text-sm font-medium hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden dark:bg-slate-900 hover:dark:border-slate-800/50 dark:hover:bg-slate-800 focus:dark:ring-gray-200'
>
- <LineChart className='h-5 w-5 [&_path]:stroke-[3.5%]' />
+ <ChartLineIcon className='h-5 w-5 text-gray-700 dark:text-gray-50' />
</button>
) : null}
{chartType === chartTypes.line ? (
@@ -2829,7 +2820,7 @@ const ViewProject = () => {
onClick={() => setChartTypeOnClick(chartTypes.bar)}
className='relative rounded-md border border-gray-50/0 bg-gray-50 p-2 text-sm font-medium hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden dark:bg-slate-900 hover:dark:border-slate-800/50 dark:hover:bg-slate-800 focus:dark:ring-gray-200'
>
- <BarChart className='h-5 w-5 [&_path]:stroke-[3.5%]' />
+ <ChartColumnIcon className='h-5 w-5 text-gray-700 dark:text-gray-50' />
</button>
) : null}
</div>
diff --git a/web/app/ui/icons/BarChart.tsx b/web/app/ui/icons/BarChart.tsx
deleted file mode 100644
index b742322b6..000000000
--- a/web/app/ui/icons/BarChart.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import cx from 'clsx'
-
-interface BarChartProps {
- className?: string
-}
-
-const BarChart = ({ className }: BarChartProps) => (
- <svg className={cx('fill-gray-700 dark:fill-gray-50', className)} viewBox='0 0 448 512'>
- {/* Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. */}
- <path
- xmlns='http://www.w3.org/2000/svg'
- d='M160 80c0-26.5 21.5-48 48-48h32c26.5 0 48 21.5 48 48V432c0 26.5-21.5 48-48 48H208c-26.5 0-48-21.5-48-48V80zM0 272c0-26.5 21.5-48 48-48H80c26.5 0 48 21.5 48 48V432c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V272zM368 96h32c26.5 0 48 21.5 48 48V432c0 26.5-21.5 48-48 48H368c-26.5 0-48-21.5-48-48V144c0-26.5 21.5-48 48-48z'
- />
- </svg>
-)
-
-export default BarChart
diff --git a/web/app/ui/icons/LineChart.tsx b/web/app/ui/icons/LineChart.tsx
deleted file mode 100644
index 884fb5daf..000000000
--- a/web/app/ui/icons/LineChart.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import cx from 'clsx'
-
-interface LineChartProps {
- className?: string
-}
-
-const LineChart = ({ className }: LineChartProps) => (
- <svg className={cx('fill-gray-700 dark:fill-gray-50', className)} viewBox='0 0 512 512'>
- {/* Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. */}
- <path d='M64 64c0-17.7-14.3-32-32-32S0 46.3 0 64V400c0 44.2 35.8 80 80 80H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H80c-8.8 0-16-7.2-16-16V64zm406.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L320 210.7l-57.4-57.4c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L240 221.3l57.4 57.4c12.5 12.5 32.8 12.5 45.3 0l128-128z' />
- </svg>
-)
-
-export default LineChart