Skip to content

Commit

Permalink
fix(cloudwatch): don't ignore 'stacked' property in GraphWidget class (
Browse files Browse the repository at this point in the history
…#2103) (#3796)

Stacked property was available and documented in the GraphWidget class, but it wasn't used for generating the cloudformation template. This change fixes the problem.

Fixes #2103
  • Loading branch information
loganek authored and Elad Ben-Israel committed Aug 28, 2019
1 parent 3a0cde0 commit 527b362
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-cloudwatch/lib/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export class GraphWidget extends ConcreteWidget {
view: 'timeSeries',
title: this.props.title,
region: this.props.region || cdk.Aws.REGION,
stacked: this.props.stacked,
metrics: metrics.length > 0 ? metrics : undefined,
annotations: horizontalAnnoations.length > 0 ? { horizontal: horizontalAnnoations } : undefined,
yAxis: {
Expand Down
25 changes: 25 additions & 0 deletions packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@ import { Test } from 'nodeunit';
import { Alarm, AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib';

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

// THEN
test.deepEqual(stack.resolve(widget.toJson()), [{
type: 'metric',
width: 6,
height: 6,
properties: {
view: 'timeSeries',
title: 'Test widget',
region: { Ref: 'AWS::Region' },
stacked: true,
yAxis: {}
}
}]);

test.done();
},

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

0 comments on commit 527b362

Please sign in to comment.