Skip to content

Commit

Permalink
feat(custom): add graphWidgetSetPeriodToTimeRange (#482)
Browse files Browse the repository at this point in the history
Corresponds with `setPeriodToTimeRange` from
[GraphWidgetProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.GraphWidgetProps.html):
> Whether to show the value from the entire time range. Only applicable
for Bar and Pie charts.

Closes #449

---

_By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license_
  • Loading branch information
echeung-amzn authored Jan 16, 2024
1 parent 4beb259 commit 1346726
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
13 changes: 13 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lib/monitoring/custom/CustomMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ export interface CustomMetricGroup {
* @default BOTTOM
*/
readonly graphWidgetLegend?: LegendPosition;
/**
* @see {GraphWidgetProps.setPeriodToTimeRange}
*/
readonly graphWidgetSetPeriodToTimeRange?: boolean;
/**
* @deprecated use addToSummaryDashboard. addToSummaryDashboard will take precedence over important.
* @see addToSummaryDashboard
Expand Down Expand Up @@ -409,6 +413,8 @@ export class CustomMonitoring extends Monitoring {
leftYAxis: annotatedGroup.metricGroup.graphWidgetAxis,
rightYAxis: annotatedGroup.metricGroup.graphWidgetRightAxis,
legendPosition: annotatedGroup.metricGroup.graphWidgetLegend,
setPeriodToTimeRange:
annotatedGroup.metricGroup.graphWidgetSetPeriodToTimeRange,
};

const widget = useAnomalyDetectionWidget
Expand Down
1 change: 1 addition & 0 deletions test/monitoring/custom/CustomMonitoring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ test("snapshot test", () => {
{
title: "DummyGroup3",
graphWidgetType: GraphWidgetType.PIE,
graphWidgetSetPeriodToTimeRange: true,
metrics: [
// regular metric
new Metric({ metricName: "DummyMetric20", namespace, dimensionsMap }),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1346726

Please sign in to comment.