dashboard: just toggle one chart at the time (overview)

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-03-21 09:55:46 +01:00
parent 7ba60cdaf3
commit e78e88e267
8 changed files with 42 additions and 36 deletions

View File

@@ -1,9 +1,12 @@
'use client';
import { useState } from 'react';
import { ChartSwitch } from '@/components/report/chart';
import { useEventQueryFilters } from '@/hooks/useEventQueryFilters';
import { cn } from '@/utils/cn';
import type { IChartType } from '@openpanel/validation';
import { Widget, WidgetBody } from '../widget';
import { OverviewChartToggle } from './overview-chart-toggle';
import { WidgetButtons, WidgetHead } from './overview-widget';
@@ -16,8 +19,9 @@ interface OverviewTopSourcesProps {
export default function OverviewTopSources({
projectId,
}: OverviewTopSourcesProps) {
const { interval, range, previous, startDate, endDate, chartType } =
const { interval, range, previous, startDate, endDate } =
useOverviewOptions();
const [chartType, setChartType] = useState<IChartType>('bar');
const [filters, setFilter] = useEventQueryFilters();
const isPageFilter = filters.find((filter) => filter.name === 'path');
const [widget, setWidget, widgets] = useOverviewWidget('sources', {
@@ -269,7 +273,7 @@ export default function OverviewTopSources({
<WidgetHead>
<div className="title">
{widget.title}
<OverviewChartToggle />
<OverviewChartToggle {...{ chartType, setChartType }} />
</div>
<WidgetButtons>