Skip to content
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

feat: Add SetPeriodToTimeRange to GraphWidget #13776

Closed
Closed
Show file tree
Hide file tree
Changes from 4 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
11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,17 @@ dashboard.addWidgets(new GraphWidget({
}));
```

The graph can show the value from the entire time range.

```ts
dashboard.addWidgets(new GraphWidget({
// ...
// ...

setPeriodToTimeRange: true,
}));
```

NetaNir marked this conversation as resolved.
Show resolved Hide resolved
### Alarm widget

An alarm widget shows the graph and the alarm line of a single alarm:
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch/lib/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ export interface GraphWidgetProps extends MetricWidgetProps {
* @default TimeSeries
*/
readonly view?: GraphWidgetView;

/**
* Whether to show the value from the entire time range.
*
* @default false
*/
readonly setPeriodToTimeRange?: boolean;
}

/**
Expand Down Expand Up @@ -276,6 +283,7 @@ export class GraphWidget extends ConcreteWidget {
},
legend: this.props.legendPosition !== undefined ? { position: this.props.legendPosition } : undefined,
liveData: this.props.liveData,
setPeriodToTimeRange: this.props.setPeriodToTimeRange,
},
}];
}
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { Test } from 'nodeunit';
import { Alarm, AlarmWidget, Color, GraphWidget, GraphWidgetView, LegendPosition, LogQueryWidget, Metric, Shading, SingleValueWidget, LogQueryVisualizationType } from '../lib';

export = {
'add stacked property to graphs'(test: Test) {
'add stacked and setPeriodToTimeRange properties to graphs'(test: Test) {
// WHEN
const stack = new Stack();
const widget = new GraphWidget({
title: 'Test widget',
stacked: true,
setPeriodToTimeRange: true
});

// THEN
Expand All @@ -22,12 +23,14 @@ export = {
region: { Ref: 'AWS::Region' },
stacked: true,
yAxis: {},
setPeriodToTimeRange: true
},
}]);

test.done();
},


'add metrics to graphs on either axis'(test: Test) {
// WHEN
const stack = new Stack();
Expand Down