|
| 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 { PageSettingsForm, useChartSettings } from "../common/page-settings"; |
| 11 | +import { FramedDemo, Page, PageSection } from "../common/templates"; |
| 12 | + |
| 13 | +export default function () { |
| 14 | + const { chartProps } = useChartSettings(); |
| 15 | + |
| 16 | + const xAxis = { |
| 17 | + title: { text: "X values" }, |
| 18 | + min: 0, |
| 19 | + max: 100, |
| 20 | + }; |
| 21 | + |
| 22 | + const yAxis = { |
| 23 | + title: { text: "Y values" }, |
| 24 | + min: 0, |
| 25 | + max: 100, |
| 26 | + }; |
| 27 | + |
| 28 | + const noDataContent = ( |
| 29 | + <Box textAlign="center" color="inherit"> |
| 30 | + <b>No data available</b> |
| 31 | + <Box variant="p" color="inherit"> |
| 32 | + There is no available data to display |
| 33 | + </Box> |
| 34 | + </Box> |
| 35 | + ); |
| 36 | + |
| 37 | + return ( |
| 38 | + <Page |
| 39 | + title="Core chart: no data states" |
| 40 | + subtitle="The page demonstrates all possible no-data states of the core chart." |
| 41 | + settings={<PageSettingsForm selectedSettings={["height", "showLegend"]} />} |
| 42 | + > |
| 43 | + <PageSection title="Empty state: all" subtitle="No series provided"> |
| 44 | + <FramedDemo> |
| 45 | + <CoreChart |
| 46 | + {...omit(chartProps.cartesian, "ref")} |
| 47 | + highcharts={Highcharts} |
| 48 | + options={{ series: [] }} |
| 49 | + noData={{ statusType: "finished", empty: noDataContent }} |
| 50 | + /> |
| 51 | + </FramedDemo> |
| 52 | + </PageSection> |
| 53 | + |
| 54 | + <PageSection title="Empty state: all (side legend)" subtitle="No series provided"> |
| 55 | + <FramedDemo> |
| 56 | + <CoreChart |
| 57 | + {...omit(chartProps.cartesian, "ref")} |
| 58 | + highcharts={Highcharts} |
| 59 | + options={{ series: [] }} |
| 60 | + legend={{ ...chartProps.cartesian.legend, position: "side" }} |
| 61 | + noData={{ statusType: "finished", empty: noDataContent }} |
| 62 | + /> |
| 63 | + </FramedDemo> |
| 64 | + </PageSection> |
| 65 | + |
| 66 | + <PageSection title="Empty state: data" subtitle="No data provided"> |
| 67 | + <FramedDemo> |
| 68 | + <CoreChart |
| 69 | + {...omit(chartProps.cartesian, "ref")} |
| 70 | + ariaLabel="Cartesian chart in empty state" |
| 71 | + options={{ |
| 72 | + xAxis, |
| 73 | + yAxis, |
| 74 | + series: [{ type: "line", name: "Load", data: [] }], |
| 75 | + }} |
| 76 | + noData={{ statusType: "finished", empty: noDataContent }} |
| 77 | + /> |
| 78 | + </FramedDemo> |
| 79 | + </PageSection> |
| 80 | + |
| 81 | + <PageSection title="Empty state: data (side legend)" subtitle="No data provided"> |
| 82 | + <FramedDemo> |
| 83 | + <CoreChart |
| 84 | + {...omit(chartProps.cartesian, "ref")} |
| 85 | + ariaLabel="Cartesian chart in empty state" |
| 86 | + legend={{ ...chartProps.cartesian.legend, position: "side" }} |
| 87 | + options={{ |
| 88 | + xAxis, |
| 89 | + yAxis, |
| 90 | + series: [{ type: "line", name: "Load", data: [] }], |
| 91 | + }} |
| 92 | + noData={{ statusType: "finished", empty: noDataContent }} |
| 93 | + /> |
| 94 | + </FramedDemo> |
| 95 | + </PageSection> |
| 96 | + </Page> |
| 97 | + ); |
| 98 | +} |
0 commit comments