diff --git a/studio/components/ui/Charts/AreaChart.stories.tsx b/studio/components/ui/Charts/AreaChart.stories.tsx index 0594186a9d5..59f8982f76d 100644 --- a/studio/components/ui/Charts/AreaChart.stories.tsx +++ b/studio/components/ui/Charts/AreaChart.stories.tsx @@ -20,18 +20,22 @@ const PROPS: AreaChartProps = { } export const AreaChart = () => ( -
+
{[ { title: 'Normal', props: {} }, { title: 'No title', props: { title: undefined } }, { title: 'Minimal Header', props: { minimalHeader: true } }, + { title: 'Minimal Highlighted Value', props: { minimalHeader: true, highlightedValue: 123 } }, { title: 'Highlighted Value', props: { highlightedValue: 123 } }, { title: 'UTC Dates', props: { displayDateInUtc: true } }, - { title: 'Custom date format', props: { customDateFormat: "HH:mm" } }, + { title: 'Custom date format', props: { customDateFormat: 'HH:mm' } }, + { title: 'No data', props: { data: [] } }, + { title: 'Value format', props: { format: 'c' } }, + { title: 'Minimal Value format', props: { minimalHeader: true, format: 'c' } }, ].map(({ title, props }) => ( -
+
{title} -
+
diff --git a/studio/components/ui/Charts/AreaChart.tsx b/studio/components/ui/Charts/AreaChart.tsx index 12f369d15bd..ab511a956ff 100644 --- a/studio/components/ui/Charts/AreaChart.tsx +++ b/studio/components/ui/Charts/AreaChart.tsx @@ -12,6 +12,7 @@ import { CHART_COLORS, DateTimeFormats } from 'components/ui/Charts/Charts.const import ChartHeader from './ChartHeader' import { Datum, CommonChartProps } from './Charts.types' import utc from 'dayjs/plugin/utc' +import ChartNoData from './NoDataPlaceholder' dayjs.extend(utc) export interface AreaChartProps extends CommonChartProps { @@ -41,6 +42,8 @@ const AreaChart: React.FC = ({ // For future reference: https://github.com/supabase/supabase/pull/5311#discussion_r800852828 const chartHeight = 160 + if (data.length === 0) return + const day = (value: number | string) => (displayDateInUtc ? dayjs(value).utc() : dayjs(value)) const highlightedLabel = (focusDataIndex !== null && diff --git a/studio/components/ui/Charts/ChartHeader.tsx b/studio/components/ui/Charts/ChartHeader.tsx index 8ccf18ccc09..c4d841f6bac 100644 --- a/studio/components/ui/Charts/ChartHeader.tsx +++ b/studio/components/ui/Charts/ChartHeader.tsx @@ -35,7 +35,7 @@ const ChartHeader: React.FC = ({
{chartTitle}
- {highlighted} + {highlightedValue && highlighted} {label}
@@ -45,7 +45,7 @@ const ChartHeader: React.FC = ({ return (
{chartTitle} - {highlighted} + {highlightedValue && highlighted} {label}
) diff --git a/studio/components/ui/Charts/ChartNoData.tsx b/studio/components/ui/Charts/ChartNoData.tsx deleted file mode 100644 index 1a89e8647c2..00000000000 --- a/studio/components/ui/Charts/ChartNoData.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { IconBarChart2 } from '@supabase/ui' - -const ChartNoData = ({ - title = 'No data to show', - message = 'May take 24 hours for data to show', -}) => ( -
- -
-

{title}

-

{message}

-
-
-) -export default ChartNoData diff --git a/studio/components/ui/Charts/NoDataPlaceholder.tsx b/studio/components/ui/Charts/NoDataPlaceholder.tsx new file mode 100644 index 00000000000..7fe1bcf96a0 --- /dev/null +++ b/studio/components/ui/Charts/NoDataPlaceholder.tsx @@ -0,0 +1,26 @@ +import { IconBarChart2 } from '@supabase/ui' + +interface Props { + title?: string + message?: string + className?: string +} +const NoDataPlaceholder: React.FC = ({ + title = 'No data to show', + message, + className = '', +}) => ( +
+ +
+

{title}

+ {message &&

{message}

} +
+
+) +export default NoDataPlaceholder