Skip to content
Open
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
3 changes: 2 additions & 1 deletion pages/03-core/boost.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function () {
</Checkbox>
),
},
"hoverDebounce",
]}
/>
}
Expand All @@ -56,7 +57,7 @@ function Component({ boostEnabled }: { boostEnabled: boolean }) {
const { chartProps } = useChartSettings({ boost: true });
return (
<CoreChart
{...chartProps.cartesian}
{...chartProps.core}
chartHeight={500}
options={{
boost: { enabled: boostEnabled },
Expand Down
2 changes: 1 addition & 1 deletion pages/03-core/core-bar-chart.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function () {
const { chartProps } = useChartSettings();

return (
<Page title="Core bar chart" settings={<PageSettingsForm selectedSettings={["showLegend"]} />}>
<Page title="Core bar chart" settings={<PageSettingsForm selectedSettings={["showLegend", "hoverDebounce"]} />}>
<div style={{ height: 400 }}>
<CoreChart
{...chartProps.core}
Expand Down
5 changes: 2 additions & 3 deletions pages/03-core/core-dual-axis-chart.page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { omit } from "lodash";

import Link from "@cloudscape-design/components/link";

import CoreChart from "../../lib/components/internal-do-not-use/core-chart";
Expand Down Expand Up @@ -128,12 +126,13 @@ export default function () {
"showLegendTitle",
"showLegendActions",
"legendHorizontalScroll",
"hoverDebounce",
]}
/>
}
>
<CoreChart
{...omit(chartProps.cartesian, "ref")}
{...chartProps.core}
chartHeight={400}
ariaLabel="Dual axis line chart"
tooltip={{ placement: "outside" }}
Expand Down
7 changes: 3 additions & 4 deletions pages/03-core/core-legend.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { useRef, useState } from "react";
import Highcharts from "highcharts";
import { omit } from "lodash";

import Link from "@cloudscape-design/components/link";
import SpaceBetween from "@cloudscape-design/components/space-between";
Expand Down Expand Up @@ -190,7 +189,7 @@ export default function () {
<Page
title="Core Legend demo"
subtitle="The page demonstrates the use of the core legend."
settings={<PageSettingsForm selectedSettings={["showLegendTitle", "showLegendActions"]} />}
settings={<PageSettingsForm selectedSettings={["showLegendTitle", "showLegendActions", "hoverDebounce"]} />}
>
<SpaceBetween direction="vertical" size="m">
<CoreLegend
Expand Down Expand Up @@ -237,7 +236,7 @@ export default function () {
})}
/>
<CoreChart
{...omit(chartProps.pie, "ref")}
{...chartProps.core}
highcharts={Highcharts}
chartHeight={400}
legend={{ enabled: false }}
Expand Down Expand Up @@ -276,7 +275,7 @@ export default function () {
}}
/>
<CoreChart
{...omit(chartProps.cartesian, "ref")}
{...chartProps.core}
highcharts={Highcharts}
chartHeight={300}
legend={{ enabled: false }}
Expand Down
1 change: 1 addition & 0 deletions pages/03-core/core-line-chart.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default function () {
"tooltipSeriesSorting",
"zoom",
"hideZoomControls",
"hoverDebounce",
]}
/>
}
Expand Down
17 changes: 15 additions & 2 deletions pages/03-core/heatmap.page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { ComponentType } from "react";

import { CoreChartProps } from "../../lib/components/core/interfaces";
import { InternalHoverProps } from "../../lib/components/core/internal-interfaces";
import CoreChart from "../../lib/components/internal-do-not-use/core-chart";
import { PageSettingsForm, useChartSettings } from "../common/page-settings";
import { Page } from "../common/templates";
import { useHighcharts } from "../common/use-highcharts";
import pseudoRandom from "../utils/pseudo-random";
Expand Down Expand Up @@ -39,13 +44,21 @@ function generateHeatmapData() {

const { series, instances } = generateHeatmapData();

const HoverCoreChart = CoreChart as ComponentType<CoreChartProps & InternalHoverProps>;

export default function () {
const highcharts = useHighcharts({ heatmap: true });
const { chartProps } = useChartSettings();

return (
<Page title="Heatmap Chart Demo" subtitle="Heatmap with generated data for 10 EC2 instances.">
<CoreChart
<Page
title="Heatmap Chart Demo"
subtitle="Heatmap with generated data for 10 EC2 instances."
settings={<PageSettingsForm selectedSettings={["hoverDebounce"]} />}
>
<HoverCoreChart
highcharts={highcharts}
hoverDebounce={chartProps.core.hoverDebounce}
chartHeight={600}
keyboardNavigation={true}
verticalAxisTitlePlacement="side"
Expand Down
4 changes: 2 additions & 2 deletions pages/03-core/simple-zooming.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { useCallback, useEffect, useRef, useState } from "react";
import Highcharts from "highcharts";
import { omit } from "lodash";

import { KeyCode } from "@cloudscape-design/component-toolkit/internal";
import BreadcrumbGroup from "@cloudscape-design/components/breadcrumb-group";
Expand Down Expand Up @@ -108,6 +107,7 @@ export default function () {
"showLegend",
"tooltipSize",
"tooltipPlacement",
"hoverDebounce",
{
content: (
<Checkbox
Expand Down Expand Up @@ -137,7 +137,7 @@ function Charts() {
settings: { keepZoomingFrame = true },
chartProps,
} = useChartSettings<ThisPageSettings>({ more: true });
const commonProps = omit(chartProps.cartesian, ["ref"]);
const commonProps = chartProps.core;
const scatterChartRef = useRef<CoreChartProps.ChartAPI>(null) as React.MutableRefObject<CoreChartProps.ChartAPI>;
const getScatterChart = () => scatterChartRef.current!;
const navigatorChartRef = useRef<CoreChartProps.ChartAPI>(null) as React.MutableRefObject<CoreChartProps.ChartAPI>;
Expand Down
13 changes: 9 additions & 4 deletions pages/03-core/solidgauge.page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { omit } from "lodash";

import CoreChart from "../../lib/components/internal-do-not-use/core-chart";
import { PageSettingsForm, useChartSettings } from "../common/page-settings";
import { Page } from "../common/templates";
Expand All @@ -28,12 +26,19 @@ export default function () {
subtitle="This page demonstrates the use of solid gauge charts for displaying single-value metrics."
settings={
<PageSettingsForm
selectedSettings={["showLegend", "legendPosition", "showLegendTitle", "showLegendActions", "useFallback"]}
selectedSettings={[
"showLegend",
"legendPosition",
"showLegendTitle",
"showLegendActions",
"useFallback",
"hoverDebounce",
]}
/>
}
>
<CoreChart
{...omit(chartProps.cartesian, "ref")}
{...chartProps.core}
options={{
series,
chart: {
Expand Down
18 changes: 16 additions & 2 deletions pages/common/page-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Select from "@cloudscape-design/components/select";
import SpaceBetween from "@cloudscape-design/components/space-between";

import { CartesianChartProps, PieChartProps } from "../../lib/components";
import { InternalZoomProps } from "../../lib/components/core/internal-interfaces";
import { InternalHoverProps, InternalZoomProps } from "../../lib/components/core/internal-interfaces";
import { CoreChartProps } from "../../src/core/interfaces";
import { useHighcharts } from "./use-highcharts";

Expand Down Expand Up @@ -47,6 +47,7 @@ export interface PageSettings {
useFallback: boolean;
zoom: boolean;
hideZoomControls: boolean;
hoverDebounce: number;
}

const DEFAULT_SETTINGS: PageSettings = {
Expand Down Expand Up @@ -75,6 +76,7 @@ const DEFAULT_SETTINGS: PageSettings = {
zoom: false,
hideZoomControls: false,
tooltipSeriesSorting: "as-added",
hoverDebounce: 0,
};

export const PageSettingsContext = createContext<PageSettings>(DEFAULT_SETTINGS);
Expand All @@ -92,7 +94,7 @@ export function useChartSettings<SettingsType extends PageSettings = PageSetting
chartProps: {
cartesian: Omit<CartesianChartProps, "series"> & InternalZoomProps & { ref: React.Ref<CartesianChartProps.Ref> };
pie: Omit<PieChartProps, "series"> & { ref: React.Ref<PieChartProps.Ref> };
core: Omit<CoreChartProps, "series" | "options"> & InternalZoomProps;
core: Omit<CoreChartProps, "series" | "options"> & InternalZoomProps & InternalHoverProps;
};
isEmpty: boolean;
} {
Expand All @@ -119,6 +121,7 @@ export function useChartSettings<SettingsType extends PageSettings = PageSetting
useFallback: parseBoolean(defaultSettings.useFallback, urlParams.useFallback),
zoom: parseBoolean(defaultSettings.zoom, urlParams.zoom),
hideZoomControls: parseBoolean(defaultSettings.hideZoomControls, urlParams.hideZoomControls),
hoverDebounce: parseNumber(defaultSettings.hoverDebounce, urlParams.hoverDebounce),
} as PageSettings as SettingsType;
const setSettings = (partial: Partial<SettingsType>) => {
setUrlParams(partial as Partial<AppUrlParams & Partial<SettingsType>>);
Expand Down Expand Up @@ -206,6 +209,7 @@ export function useChartSettings<SettingsType extends PageSettings = PageSetting
emphasizeBaseline: settings.emphasizeBaseline,
verticalAxisTitlePlacement: settings.verticalAxisTitlePlacement,
zoom,
hoverDebounce: settings.hoverDebounce > 0 ? settings.hoverDebounce : undefined,
},
},
isEmpty: settings.emptySeries || settings.seriesLoading || settings.seriesError,
Expand Down Expand Up @@ -517,6 +521,16 @@ export function PageSettingsForm({
Hide zoom controls
</Checkbox>
);
case "hoverDebounce":
return (
<FormField label="Hover debounce (ms)" description="0 disables the delay.">
<Input
type="number"
value={settings.hoverDebounce.toString()}
onChange={({ detail }) => setSettings({ hoverDebounce: detail.value ? parseInt(detail.value) : 0 })}
/>
</FormField>
);
case "useFallback":
return (
<Checkbox
Expand Down
Loading
Loading