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
  • Loading branch information
loganek committed Aug 26, 2019
1 parent 39ee810 commit 3a0992f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 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 || false,
metrics: metrics.length > 0 ? metrics : undefined,
annotations: horizontalAnnoations.length > 0 ? { horizontal: horizontalAnnoations } : undefined,
yAxis: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
{
"Ref": "AWS::Region"
},
"\",\"metrics\":[[\"AWS/SQS\",\"ApproximateNumberOfMessagesVisible\",\"QueueName\",\"",
"\",\"stacked\":false,\"metrics\":[[\"AWS/SQS\",\"ApproximateNumberOfMessagesVisible\",\"QueueName\",\"",
{
"Fn::GetAtt": [
"queue",
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-cloudwatch/test/test.dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export = {
DashboardBody: { "Fn::Join": [ "", [
"{\"widgets\":[{\"type\":\"metric\",\"width\":1,\"height\":1,\"x\":0,\"y\":0,\"properties\":{\"view\":\"timeSeries\",\"region\":\"",
{ Ref: "AWS::Region" },
"\",\"yAxis\":{}}}]}"
"\",\"stacked\":false,\"yAxis\":{}}}]}"
]]}
}));

Expand Down Expand Up @@ -113,7 +113,7 @@ export = {
"{\"start\":\"-9H\",\"end\":\"2018-12-17T06:00:00.000Z\",\"periodOverride\":\"inherit\",\
\"widgets\":[{\"type\":\"metric\",\"width\":1,\"height\":1,\"x\":0,\"y\":0,\"properties\":{\"view\":\"timeSeries\",\"region\":\"",
{ Ref: "AWS::Region" },
"\",\"yAxis\":{}}}]}"
"\",\"stacked\":false,\"yAxis\":{}}}]}"
]]}
}));

Expand Down
30 changes: 30 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 All @@ -29,6 +54,7 @@ export = {
['CDK', 'Test', { yAxis: 'left', period: 300, stat: 'Average' }],
['CDK', 'Tast', { yAxis: 'right', period: 300, stat: 'Average' }]
],
stacked: false,
yAxis: {}
}
}]);
Expand All @@ -54,6 +80,7 @@ export = {
metrics: [
['CDK', 'Test', { yAxis: 'left', period: 300, stat: 'Average', label: 'MyMetric', color: '000000' }],
],
stacked: false,
yAxis: {}
}
}]);
Expand Down Expand Up @@ -155,6 +182,7 @@ export = {
fill: 'below',
label: 'this is the annotation',
}] },
stacked: false,
yAxis: {}
}
}]);
Expand Down Expand Up @@ -197,6 +225,7 @@ export = {
label: 'Test >= 1000 for 2 datapoints within 10 minutes',
}]
},
stacked: false,
yAxis: {}
}
}]);
Expand Down Expand Up @@ -239,6 +268,7 @@ export = {
['CDK', 'Test', { yAxis: 'left', period: 300, stat: 'Average' }],
['CDK', 'Tast', { yAxis: 'right', period: 300, stat: 'Average' }]
],
stacked: false,
yAxis: {
left: { label: "Left yAxis", max: 100 },
right: { label: "Right yAxis", min: 10, showUnits: false } }
Expand Down

0 comments on commit 3a0992f

Please sign in to comment.