diff --git a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/SelectAxisDropdownContent.tsx b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/SelectAxisDropdownContent.tsx index 0ca96378e..e9fcbafab 100644 --- a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/SelectAxisDropdownContent.tsx +++ b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/SelectAxisDropdownContent.tsx @@ -1,4 +1,4 @@ -import { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; import type { IColumnLabelFormat } from '@/components/ui/charts/interfaces/columnLabelInterfaces'; import { useMemoizedFn } from 'ahooks'; import React, { useMemo } from 'react'; @@ -10,7 +10,6 @@ import { BarAndLineAxis, ChartEncodes, ChartType, ColumnSettings } from '@/compo import { EditBarRoundness } from './EditBarRoundness'; import { EditShowDataLabel } from './EditShowDataLabel'; import { EditShowBarLabelAsPercentage } from './EditShowLabelAsPercentage'; -import { Divider } from 'antd'; import { EditLabelStyle } from './EditLabelStyle'; import { EditSeparator } from './EditSeparator'; import { EditDecimals } from './EditDecimals'; @@ -26,6 +25,7 @@ import { EditReplaceMissingData } from './EditReplaceMissingData'; import { EditLineStyle } from './EditLineStyle'; import isEmpty from 'lodash/isEmpty'; import { useGetCurrencies } from '@/api/buster_rest/nextjs/currency'; +import { cn } from '@/lib/classMerge'; export const SelectAxisDropdownContent: React.FC<{ columnSetting: IBusterMetricChartConfig['columnSettings'][string]; @@ -85,7 +85,7 @@ export const SelectAxisDropdownContent: React.FC<{ }); return ( -
+
{!hideTitle && } - {} + {
} ); }; @@ -450,7 +450,7 @@ const TitleComponent: React.FC<{
{formattedTitle}
- +
); }); diff --git a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.stories.tsx b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.stories.tsx new file mode 100644 index 000000000..27cc9ebeb --- /dev/null +++ b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.stories.tsx @@ -0,0 +1,120 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { + SelectAxisColumnPopover, + type SelectAxisColumnPopoverProps +} from './SelectAxisColumnPopover'; +import { Button } from '@/components/ui/buttons/Button'; +import { ChartType, IColumnLabelFormat } from '@/components/ui/charts'; +import { SelectAxisContainerId } from './config'; +import type { IBusterMetricChartConfig, SimplifiedColumnType } from '@/api/asset_interfaces'; +import { http, HttpResponse } from 'msw'; + +const meta: Meta = { + title: 'Controllers/EditMetricController/SelectAxisColumnPopover', + component: SelectAxisColumnPopover, + parameters: { + layout: 'centered', + msw: { + handlers: [ + http.get(`api/currency`, () => { + return HttpResponse.json([ + { code: 'USD', description: 'United States Dollar', flag: 'πŸ‡ΊπŸ‡Έ' }, + { code: 'EUR', description: 'Euro', flag: 'πŸ‡ͺπŸ‡Ί' }, + { code: 'GBP', description: 'British Pound', flag: 'πŸ‡¬πŸ‡§' }, + { code: 'CNY', description: 'Chinese Yuan', flag: 'πŸ‡¨πŸ‡³' }, + { code: 'JPY', description: 'Japanese Yen', flag: 'πŸ‡―πŸ‡΅' } + ]); + }) + ] + } + }, + decorators: [ + (Story) => ( +
+ +
+ ) + ] +}; + +export default meta; + +type Story = StoryObj; + +const mockProps: SelectAxisColumnPopoverProps = { + columnLabelFormat: { + columnType: 'string' as SimplifiedColumnType, + style: 'currency' as const, + displayName: 'Test Column', + numberSeparatorStyle: ',' as const, + minimumFractionDigits: 0, + maximumFractionDigits: 2, + currency: 'USD', + convertNumberTo: null, + dateFormat: 'auto', + useRelativeTime: false, + isUTC: false, + multiplier: 1, + prefix: '', + suffix: '', + replaceMissingDataWith: null, + makeLabelHumanReadable: true, + compactNumbers: false + } as IColumnLabelFormat, + columnSetting: { + showDataLabels: false, + showDataLabelsAsPercentage: false, + columnVisualization: 'bar' as const, + lineWidth: 2, + lineStyle: 'line' as const, + lineType: 'normal' as const, + lineSymbolSize: 0, + barRoundness: 8 + } as IBusterMetricChartConfig['columnSettings'][string], + id: 'test-id', + selectedChartType: ChartType.Bar, + barGroupType: 'group', + lineGroupType: 'stack', + zoneId: SelectAxisContainerId.XAxis, + selectedAxis: { + x: ['test-id'], + y: [], + category: [], + size: [], + tooltip: [], + y2: [] + }, + rowCount: 10, + children: +}; + +export const Default: Story = { + args: { + ...mockProps, + children: + } +}; + +export const WithDifferentAxis: Story = { + args: { + ...mockProps, + zoneId: SelectAxisContainerId.YAxis, + selectedAxis: { + x: [], + y: ['test-id'], + category: [], + size: [], + tooltip: [], + y2: [] + }, + children: + } +}; + +export const WithLargeDataset: Story = { + args: { + ...mockProps, + rowCount: 1000, + children: + } +}; diff --git a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.tsx b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.tsx index 2d23bcf78..5e9abbe07 100644 --- a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.tsx +++ b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.tsx @@ -5,7 +5,7 @@ import { SelectAxisDropdownContent } from './SelectAxisColumnContent'; import { type IBusterMetricChartConfig } from '@/api/asset_interfaces'; import type { SelectAxisContainerId } from './config'; -interface SelectAxisColumnPopoverProps { +export interface SelectAxisColumnPopoverProps { columnLabelFormat: IColumnLabelFormat; columnSetting: IBusterMetricChartConfig['columnSettings'][string]; children: React.ReactNode; @@ -24,6 +24,7 @@ export const SelectAxisColumnPopover = React.memo( }>