Skip to content

Commit 22763c5

Browse files
authored
Merge branch 'main' into fix/url-sanitization
2 parents 973ce63 + f96878f commit 22763c5

File tree

4 files changed

+107
-3
lines changed

4 files changed

+107
-3
lines changed

pages/03-core/boost.page.tsx

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import Checkbox from "@cloudscape-design/components/checkbox";
5+
6+
import CoreChart from "../../lib/components/internal-do-not-use/core-chart";
7+
import { dateFormatter } from "../common/formatters";
8+
import { PageSettings, PageSettingsForm, useChartSettings } from "../common/page-settings";
9+
import { Page } from "../common/templates";
10+
import pseudoRandom from "../utils/pseudo-random";
11+
12+
interface ThisPageSettings extends PageSettings {
13+
boostEnabled: boolean;
14+
}
15+
16+
export default function () {
17+
const {
18+
settings: { boostEnabled = false },
19+
setSettings,
20+
} = useChartSettings<ThisPageSettings>();
21+
return (
22+
<Page
23+
title="Boost module"
24+
subtitle="This demonstrates the use of the boost module"
25+
settings={
26+
<PageSettingsForm
27+
selectedSettings={[
28+
{
29+
content: (
30+
<Checkbox
31+
checked={boostEnabled}
32+
onChange={({ detail }) => setSettings({ boostEnabled: detail.checked })}
33+
>
34+
Enable boost module
35+
</Checkbox>
36+
),
37+
},
38+
]}
39+
/>
40+
}
41+
>
42+
<Component boostEnabled={boostEnabled} />
43+
</Page>
44+
);
45+
}
46+
47+
const domain: number[] = [];
48+
for (
49+
let time = new Date("2015-01-01").getTime();
50+
time < new Date("2025-01-01").getTime();
51+
time += 12 * 60 * 60 * 1000
52+
) {
53+
domain.push(time);
54+
}
55+
function Component({ boostEnabled }: { boostEnabled: boolean }) {
56+
const { chartProps } = useChartSettings({ boost: true });
57+
return (
58+
<CoreChart
59+
{...chartProps.cartesian}
60+
chartHeight={500}
61+
options={{
62+
boost: { enabled: boostEnabled },
63+
plotOptions: { series: { boostThreshold: 1 } },
64+
series: [
65+
{
66+
name: "Site 1",
67+
type: "spline",
68+
data: domain.map((x, index) => ({
69+
x,
70+
y: Math.round(1000 + pseudoRandom() * 10 * index),
71+
})),
72+
},
73+
{
74+
name: "Site 2",
75+
type: "spline",
76+
data: domain.map((x, index) => ({
77+
x,
78+
y: Math.round(99_000 - pseudoRandom() * 10 * index),
79+
})),
80+
},
81+
],
82+
xAxis: [
83+
{
84+
type: "linear",
85+
title: { text: "Time (UTC)" },
86+
min: domain[0],
87+
max: domain[domain.length - 1],
88+
valueFormatter: dateFormatter,
89+
},
90+
],
91+
yAxis: [{ title: { text: "Bytes transferred" }, min: 0, max: 100_000 }],
92+
}}
93+
ariaLabel="Large chart"
94+
tooltip={{
95+
placement: "outside",
96+
}}
97+
/>
98+
);
99+
}

pages/common/page-settings.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export function useChartSettings<SettingsType extends PageSettings = PageSetting
7474
more?: boolean;
7575
xrange?: boolean;
7676
solidgauge?: boolean;
77+
boost?: boolean;
7778
} = {},
7879
): {
7980
settings: SettingsType;

pages/common/use-highcharts.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export function useHighcharts({
1010
more = false,
1111
xrange = false,
1212
solidgauge = false,
13-
}: { more?: boolean; xrange?: boolean; solidgauge?: boolean } = {}) {
13+
boost = false,
14+
}: { more?: boolean; xrange?: boolean; solidgauge?: boolean; boost?: boolean } = {}) {
1415
const [highcharts, setHighcharts] = useState<null | typeof Highcharts>(null);
1516

1617
useEffect(() => {
@@ -29,6 +30,9 @@ export function useHighcharts({
2930
if (solidgauge) {
3031
await import("highcharts/modules/solid-gauge");
3132
}
33+
if (boost) {
34+
await import("highcharts/modules/boost");
35+
}
3236

3337
if (isDevelopment) {
3438
await import("highcharts/modules/debugger");
@@ -38,7 +42,7 @@ export function useHighcharts({
3842
};
3943

4044
load();
41-
}, [more, xrange, solidgauge]);
45+
}, [more, xrange, solidgauge, boost]);
4246

4347
return highcharts;
4448
}

src/internal/utils/test-i18n-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface TestI18nProviderProps {
1111

1212
export function TestI18nProvider({ messages = {}, locale = "en", children }: TestI18nProviderProps) {
1313
return (
14-
<I18nProvider locale={locale} messages={[{ "@cloudscape-design/components": { [locale]: messages } }]}>
14+
<I18nProvider locale={locale} messages={[{ "cloudscape-design-components": { [locale]: messages } }]}>
1515
{children}
1616
</I18nProvider>
1717
);

0 commit comments

Comments
 (0)