Skip to content

Commit 05d813a

Browse files
committed
chore: add no-data-states to core section
1 parent 0b8e2aa commit 05d813a

File tree

2 files changed

+82
-55
lines changed

2 files changed

+82
-55
lines changed

pages/03-core/empty-line-chart.page.tsx

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import Highcharts from "highcharts";
5+
import { omit } from "lodash";
6+
7+
import Box from "@cloudscape-design/components/box";
8+
9+
import CoreChart from "../../lib/components/internal-do-not-use/core-chart";
10+
import { PageSettings, PageSettingsForm, useChartSettings } from "../common/page-settings";
11+
import { FramedDemo, Page, PageSection } from "../common/templates";
12+
13+
interface ThisPageSettings extends PageSettings {
14+
showInLegend?: boolean;
15+
}
16+
17+
export default function () {
18+
const { chartProps } = useChartSettings<ThisPageSettings>();
19+
20+
const noDataContent = (
21+
<Box textAlign="center" color="inherit">
22+
<b>No data available</b>
23+
<Box variant="p" color="inherit">
24+
There is no available data to display
25+
</Box>
26+
</Box>
27+
);
28+
29+
return (
30+
<Page
31+
title="Core chart: no data states"
32+
subtitle="The page demonstrates all possible no-data states of the core chart."
33+
settings={<PageSettingsForm selectedSettings={["height", "showLegend"]} />}
34+
>
35+
<PageSection title="Empty state: all" subtitle="No series provided">
36+
<FramedDemo>
37+
<CoreChart
38+
{...omit(chartProps.cartesian, "ref")}
39+
highcharts={Highcharts}
40+
options={{ series: [] }}
41+
noData={{ statusType: "finished", empty: noDataContent }}
42+
/>
43+
</FramedDemo>
44+
</PageSection>
45+
46+
<PageSection title="Empty state: all (side legend)" subtitle="No series provided">
47+
<FramedDemo>
48+
<CoreChart
49+
{...omit(chartProps.cartesian, "ref")}
50+
highcharts={Highcharts}
51+
options={{ series: [] }}
52+
legend={{ ...chartProps.cartesian.legend, position: "side" }}
53+
noData={{ statusType: "finished", empty: noDataContent }}
54+
/>
55+
</FramedDemo>
56+
</PageSection>
57+
58+
<PageSection title="Empty state: data" subtitle="No data provided">
59+
<FramedDemo>
60+
<CoreChart
61+
{...omit(chartProps.cartesian, "ref")}
62+
ariaLabel="Cartesian chart in empty state"
63+
options={{ series: [{ type: "line", name: "Load", data: [] }] }}
64+
noData={{ statusType: "finished", empty: noDataContent }}
65+
/>
66+
</FramedDemo>
67+
</PageSection>
68+
69+
<PageSection title="Empty state: data (side legend)" subtitle="No data provided">
70+
<FramedDemo>
71+
<CoreChart
72+
{...omit(chartProps.cartesian, "ref")}
73+
ariaLabel="Cartesian chart in empty state"
74+
legend={{ ...chartProps.cartesian.legend, position: "side" }}
75+
options={{ series: [{ type: "line", name: "Load", data: [] }] }}
76+
noData={{ statusType: "finished", empty: noDataContent }}
77+
/>
78+
</FramedDemo>
79+
</PageSection>
80+
</Page>
81+
);
82+
}

0 commit comments

Comments
 (0)