generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 9
chore: Adds boost module demo #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| }} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix addresses an issue with tests caused by https://github.com/cloudscape-design/components/pull/3899/files#diff-5513c9055041b70f7511f96c78bc5f3e4f822a02c27586691b1291d3de342020R22
There was a problem hiding this comment.
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