Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions pages/03-core/boost.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import Checkbox from "@cloudscape-design/components/checkbox";

import CoreChart from "../../lib/components/internal-do-not-use/core-chart";
import { dateFormatter } from "../common/formatters";
import { PageSettings, PageSettingsForm, useChartSettings } from "../common/page-settings";
import { Page } from "../common/templates";
import pseudoRandom from "../utils/pseudo-random";

interface ThisPageSettings extends PageSettings {
boostEnabled: boolean;
}

export default function () {
const {
settings: { boostEnabled = false },
setSettings,
} = useChartSettings<ThisPageSettings>();
return (
<Page
title="Boost module"
subtitle="This demonstrates the use of the boost module"
settings={
<PageSettingsForm
selectedSettings={[
{
content: (
<Checkbox
checked={boostEnabled}
onChange={({ detail }) => setSettings({ boostEnabled: detail.checked })}
>
Enable boost module
</Checkbox>
),
},
]}
/>
}
>
<Component boostEnabled={boostEnabled} />
</Page>
);
}

const domain: number[] = [];
for (
let time = new Date("2015-01-01").getTime();
time < new Date("2025-01-01").getTime();
time += 12 * 60 * 60 * 1000
) {
domain.push(time);
}
function Component({ boostEnabled }: { boostEnabled: boolean }) {
const { chartProps } = useChartSettings({ boost: true });
return (
<CoreChart
{...chartProps.cartesian}
chartHeight={500}
options={{
boost: { enabled: boostEnabled },
plotOptions: { series: { boostThreshold: 1 } },
series: [
{
name: "Site 1",
type: "spline",
data: domain.map((x, index) => ({
x,
y: Math.round(1000 + pseudoRandom() * 10 * index),
})),
},
{
name: "Site 2",
type: "spline",
data: domain.map((x, index) => ({
x,
y: Math.round(99_000 - pseudoRandom() * 10 * index),
})),
},
],
xAxis: [
{
type: "linear",
title: { text: "Time (UTC)" },
min: domain[0],
max: domain[domain.length - 1],
valueFormatter: dateFormatter,
},
],
yAxis: [{ title: { text: "Bytes transferred" }, min: 0, max: 100_000 }],
}}
ariaLabel="Large chart"
tooltip={{
placement: "outside",
}}
/>
);
}
1 change: 1 addition & 0 deletions pages/common/page-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
more?: boolean;
xrange?: boolean;
solidgauge?: boolean;
boost?: boolean;
} = {},
): {
settings: SettingsType;
Expand Down Expand Up @@ -106,7 +107,7 @@
useFallback: parseBoolean(defaultSettings.useFallback, urlParams.useFallback),
} as PageSettings as SettingsType;
const setSettings = (partial: Partial<SettingsType>) => {
setUrlParams(partial as any);

Check warning on line 110 in pages/common/page-settings.tsx

View workflow job for this annotation

GitHub Actions / build / build

Unexpected any. Specify a different type
};

const cartesianChartRef = useRef<CartesianChartProps.Ref>(null);
Expand Down
8 changes: 6 additions & 2 deletions pages/common/use-highcharts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export function useHighcharts({
more = false,
xrange = false,
solidgauge = false,
}: { more?: boolean; xrange?: boolean; solidgauge?: boolean } = {}) {
boost = false,
}: { more?: boolean; xrange?: boolean; solidgauge?: boolean; boost?: boolean } = {}) {
const [highcharts, setHighcharts] = useState<null | typeof Highcharts>(null);

useEffect(() => {
Expand All @@ -29,6 +30,9 @@ export function useHighcharts({
if (solidgauge) {
await import("highcharts/modules/solid-gauge");
}
if (boost) {
await import("highcharts/modules/boost");
}

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

load();
}, [more, xrange, solidgauge]);
}, [more, xrange, solidgauge, boost]);

return highcharts;
}
2 changes: 1 addition & 1 deletion src/internal/utils/test-i18n-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface TestI18nProviderProps {

export function TestI18nProvider({ messages = {}, locale = "en", children }: TestI18nProviderProps) {
return (
<I18nProvider locale={locale} messages={[{ "@cloudscape-design/components": { [locale]: messages } }]}>
<I18nProvider locale={locale} messages={[{ "cloudscape-design-components": { [locale]: messages } }]}>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jperals, this failure should have been captured by the dry-run, here is a change to the actions to enable dry-runs for chart components: cloudscape-design/actions#103

{children}
</I18nProvider>
);
Expand Down
Loading