From 83065ff13b3d418d4d9151182358ff42a23e10dc Mon Sep 17 00:00:00 2001 From: kpiljoong Date: Wed, 1 May 2019 17:33:14 +0900 Subject: [PATCH 1/4] feat(cloudwatch): add support for yAxis to graph Support setting for the y-axis on a graph: min, max, label, and showUnits. Fixes #2385 --- packages/@aws-cdk/aws-cloudwatch/lib/graph.ts | 44 ++++------------- packages/@aws-cdk/aws-cloudwatch/lib/index.ts | 1 + packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts | 49 +++++++++++++++++++ .../aws-cloudwatch/test/test.graphs.ts | 47 +++++++++++++++++- 4 files changed, 106 insertions(+), 35 deletions(-) create mode 100644 packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts index fb28630a4bae3..a80db60c5f7b3 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts @@ -3,6 +3,7 @@ import { Alarm } from "./alarm"; import { Metric } from "./metric"; import { parseStatistic } from './util.statistic'; import { ConcreteWidget } from "./widget"; +import { YAxis } from "./yaxis"; /** * Basic properties for widgets that display metrics @@ -45,11 +46,9 @@ export interface AlarmWidgetProps extends MetricWidgetProps { readonly alarm: Alarm; /** - * Range of left Y axis - * - * @default 0..automatic + * Left Y axis */ - readonly leftAxisRange?: YAxisRange; + readonly leftYAxis?: YAxis; } /** @@ -78,7 +77,7 @@ export class AlarmWidget extends ConcreteWidget { alarms: [this.props.alarm.alarmArn] }, yAxis: { - left: this.props.leftAxisRange !== undefined ? this.props.leftAxisRange : { min: 0 } + left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : { min: 0 } } } }]; @@ -115,18 +114,14 @@ export interface GraphWidgetProps extends MetricWidgetProps { readonly stacked?: boolean; /** - * Range of left Y axis - * - * @default 0..automatic + * Left Y axis */ - readonly leftAxisRange?: YAxisRange; + readonly leftYAxis?: YAxis; /** - * Range of right Y axis - * - * @default 0..automatic + * Right Y axis */ - readonly rightAxisRange?: YAxisRange; + readonly rightYAxis?: YAxis; } /** @@ -158,8 +153,8 @@ export class GraphWidget extends ConcreteWidget { (this.props.rightAnnotations || []).map(mapAnnotation('right'))) }, yAxis: { - left: this.props.leftAxisRange !== undefined ? this.props.leftAxisRange : { min: 0 }, - right: this.props.rightAxisRange !== undefined ? this.props.rightAxisRange : { min: 0 }, + left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : { min: 0 }, + right: this.props.rightYAxis !== undefined ? this.props.rightYAxis : { min: 0 }, } } }]; @@ -204,25 +199,6 @@ export class SingleValueWidget extends ConcreteWidget { } } -/** - * A minimum and maximum value for either the left or right Y axis - */ -export interface YAxisRange { - /** - * The minimum value - * - * @default Automatic - */ - readonly min?: number; - - /** - * The maximum value - * - * @default Automatic - */ - readonly max?: number; -} - /** * Horizontal annotation to be added to a graph */ diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/index.ts b/packages/@aws-cdk/aws-cloudwatch/lib/index.ts index 5940a823ca866..e015d833e3b3f 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/index.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/index.ts @@ -5,6 +5,7 @@ export * from './layout'; export * from './metric'; export * from './text'; export * from './widget'; +export * from './yaxis'; // AWS::CloudWatch CloudFormation Resources: export * from './cloudwatch.generated'; diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts b/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts new file mode 100644 index 0000000000000..46a6539a46b03 --- /dev/null +++ b/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts @@ -0,0 +1,49 @@ +/** + * Properties for a Y-Axis + */ +export interface YAxisProps { + /** + * The min value + * + * @default 0 + */ + readonly min?: number; + + /** + * The max value + * + * @default No maximum value + */ + readonly max?: number; + + /** + * The label + * + * @default No label + */ + readonly label?: string; + + /** + * Whether to show units + * + * @default None (means true) + */ + readonly showUnits?: boolean; +} + +/** + * An Y-Axis on a CloudWatch dashboard widget + */ +export class YAxis { + public readonly min?: number; + public readonly max?: number; + public readonly label?: string; + public readonly showUnits?: boolean; + + constructor(props: YAxisProps) { + this.min = props.min || 0; + this.max = props.max; + this.label = props.label; + this.showUnits = props.showUnits; + } +} diff --git a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts index 8a3073ffd0750..a248d2d6422d4 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts @@ -1,6 +1,6 @@ import { Stack } from '@aws-cdk/cdk'; import { Test } from 'nodeunit'; -import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib'; +import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget, YAxis } from '../lib'; export = { 'add metrics to graphs on either axis'(test: Test) { @@ -205,4 +205,49 @@ export = { test.done(); }, + + 'add yAxis to graph'(test: Test) { + // WHEN + const stack = new Stack(); + const widget = new GraphWidget({ + title: 'My fancy graph', + left: [ + new Metric({ namespace: 'CDK', metricName: 'Test' }) + ], + right: [ + new Metric({ namespace: 'CDK', metricName: 'Tast' }) + ], + leftYAxis: new YAxis({ + label: "Left yAxis", + max: 100 + }), + rightYAxis: new YAxis({ + label: "Right yAxis", + min: 10, + showUnits: false + }) + }); + + // THEN + test.deepEqual(stack.node.resolve(widget.toJson()), [{ + type: 'metric', + width: 6, + height: 6, + properties: { + view: 'timeSeries', + title: 'My fancy graph', + region: { Ref: 'AWS::Region' }, + metrics: [ + ['CDK', 'Test', { yAxis: 'left', period: 300, stat: 'Average' }], + ['CDK', 'Tast', { yAxis: 'right', period: 300, stat: 'Average' }] + ], + annotations: { horizontal: [] }, + yAxis: { + left: { label: "Left yAxis", min: 0, max: 100 }, + right: { label: "Right yAxis", min: 10, showUnits: false } } + } + }]); + + test.done(); + }, }; From 364cd50e2849ab14bc61407435dbdafe4a585ece Mon Sep 17 00:00:00 2001 From: kpiljoong Date: Wed, 1 May 2019 17:33:14 +0900 Subject: [PATCH 2/4] feat(cloudwatch): add support for yAxis to graph Support setting for the y-axis on a graph: min, max, label, and showUnits. Fixes #2385 --- packages/@aws-cdk/aws-cloudwatch/lib/graph.ts | 44 ++++------------- packages/@aws-cdk/aws-cloudwatch/lib/index.ts | 1 + packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts | 49 +++++++++++++++++++ .../aws-cloudwatch/test/test.graphs.ts | 47 +++++++++++++++++- 4 files changed, 106 insertions(+), 35 deletions(-) create mode 100644 packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts index fb28630a4bae3..a80db60c5f7b3 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts @@ -3,6 +3,7 @@ import { Alarm } from "./alarm"; import { Metric } from "./metric"; import { parseStatistic } from './util.statistic'; import { ConcreteWidget } from "./widget"; +import { YAxis } from "./yaxis"; /** * Basic properties for widgets that display metrics @@ -45,11 +46,9 @@ export interface AlarmWidgetProps extends MetricWidgetProps { readonly alarm: Alarm; /** - * Range of left Y axis - * - * @default 0..automatic + * Left Y axis */ - readonly leftAxisRange?: YAxisRange; + readonly leftYAxis?: YAxis; } /** @@ -78,7 +77,7 @@ export class AlarmWidget extends ConcreteWidget { alarms: [this.props.alarm.alarmArn] }, yAxis: { - left: this.props.leftAxisRange !== undefined ? this.props.leftAxisRange : { min: 0 } + left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : { min: 0 } } } }]; @@ -115,18 +114,14 @@ export interface GraphWidgetProps extends MetricWidgetProps { readonly stacked?: boolean; /** - * Range of left Y axis - * - * @default 0..automatic + * Left Y axis */ - readonly leftAxisRange?: YAxisRange; + readonly leftYAxis?: YAxis; /** - * Range of right Y axis - * - * @default 0..automatic + * Right Y axis */ - readonly rightAxisRange?: YAxisRange; + readonly rightYAxis?: YAxis; } /** @@ -158,8 +153,8 @@ export class GraphWidget extends ConcreteWidget { (this.props.rightAnnotations || []).map(mapAnnotation('right'))) }, yAxis: { - left: this.props.leftAxisRange !== undefined ? this.props.leftAxisRange : { min: 0 }, - right: this.props.rightAxisRange !== undefined ? this.props.rightAxisRange : { min: 0 }, + left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : { min: 0 }, + right: this.props.rightYAxis !== undefined ? this.props.rightYAxis : { min: 0 }, } } }]; @@ -204,25 +199,6 @@ export class SingleValueWidget extends ConcreteWidget { } } -/** - * A minimum and maximum value for either the left or right Y axis - */ -export interface YAxisRange { - /** - * The minimum value - * - * @default Automatic - */ - readonly min?: number; - - /** - * The maximum value - * - * @default Automatic - */ - readonly max?: number; -} - /** * Horizontal annotation to be added to a graph */ diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/index.ts b/packages/@aws-cdk/aws-cloudwatch/lib/index.ts index 5940a823ca866..e015d833e3b3f 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/index.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/index.ts @@ -5,6 +5,7 @@ export * from './layout'; export * from './metric'; export * from './text'; export * from './widget'; +export * from './yaxis'; // AWS::CloudWatch CloudFormation Resources: export * from './cloudwatch.generated'; diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts b/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts new file mode 100644 index 0000000000000..46a6539a46b03 --- /dev/null +++ b/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts @@ -0,0 +1,49 @@ +/** + * Properties for a Y-Axis + */ +export interface YAxisProps { + /** + * The min value + * + * @default 0 + */ + readonly min?: number; + + /** + * The max value + * + * @default No maximum value + */ + readonly max?: number; + + /** + * The label + * + * @default No label + */ + readonly label?: string; + + /** + * Whether to show units + * + * @default None (means true) + */ + readonly showUnits?: boolean; +} + +/** + * An Y-Axis on a CloudWatch dashboard widget + */ +export class YAxis { + public readonly min?: number; + public readonly max?: number; + public readonly label?: string; + public readonly showUnits?: boolean; + + constructor(props: YAxisProps) { + this.min = props.min || 0; + this.max = props.max; + this.label = props.label; + this.showUnits = props.showUnits; + } +} diff --git a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts index 8a3073ffd0750..a248d2d6422d4 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts @@ -1,6 +1,6 @@ import { Stack } from '@aws-cdk/cdk'; import { Test } from 'nodeunit'; -import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib'; +import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget, YAxis } from '../lib'; export = { 'add metrics to graphs on either axis'(test: Test) { @@ -205,4 +205,49 @@ export = { test.done(); }, + + 'add yAxis to graph'(test: Test) { + // WHEN + const stack = new Stack(); + const widget = new GraphWidget({ + title: 'My fancy graph', + left: [ + new Metric({ namespace: 'CDK', metricName: 'Test' }) + ], + right: [ + new Metric({ namespace: 'CDK', metricName: 'Tast' }) + ], + leftYAxis: new YAxis({ + label: "Left yAxis", + max: 100 + }), + rightYAxis: new YAxis({ + label: "Right yAxis", + min: 10, + showUnits: false + }) + }); + + // THEN + test.deepEqual(stack.node.resolve(widget.toJson()), [{ + type: 'metric', + width: 6, + height: 6, + properties: { + view: 'timeSeries', + title: 'My fancy graph', + region: { Ref: 'AWS::Region' }, + metrics: [ + ['CDK', 'Test', { yAxis: 'left', period: 300, stat: 'Average' }], + ['CDK', 'Tast', { yAxis: 'right', period: 300, stat: 'Average' }] + ], + annotations: { horizontal: [] }, + yAxis: { + left: { label: "Left yAxis", min: 0, max: 100 }, + right: { label: "Right yAxis", min: 10, showUnits: false } } + } + }]); + + test.done(); + }, }; From 40e758986da6283a2d440da464562c7f585d892a Mon Sep 17 00:00:00 2001 From: kpiljoong Date: Tue, 14 May 2019 16:04:42 +0900 Subject: [PATCH 3/4] Merged YAxis class with YAxisProps and modified tests accordingly --- packages/@aws-cdk/aws-cloudwatch/lib/graph.ts | 46 ++++++++++++++--- packages/@aws-cdk/aws-cloudwatch/lib/index.ts | 1 - packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts | 49 ------------------- .../integ.alarm-and-dashboard.expected.json | 4 +- .../aws-cloudwatch/test/test.dashboard.ts | 4 +- .../aws-cloudwatch/test/test.graphs.ts | 20 ++++---- 6 files changed, 53 insertions(+), 71 deletions(-) delete mode 100644 packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts index a80db60c5f7b3..249d0c0a739ed 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/graph.ts @@ -3,7 +3,6 @@ import { Alarm } from "./alarm"; import { Metric } from "./metric"; import { parseStatistic } from './util.statistic'; import { ConcreteWidget } from "./widget"; -import { YAxis } from "./yaxis"; /** * Basic properties for widgets that display metrics @@ -36,6 +35,39 @@ export interface MetricWidgetProps { readonly height?: number; } +/** + * Properties for a Y-Axis + */ +export interface YAxisProps { + /** + * The min value + * + * @default 0 + */ + readonly min?: number; + + /** + * The max value + * + * @default No maximum value + */ + readonly max?: number; + + /** + * The label + * + * @default No label + */ + readonly label?: string; + + /** + * Whether to show units + * + * @default true + */ + readonly showUnits?: boolean; +} + /** * Properties for an AlarmWidget */ @@ -48,7 +80,7 @@ export interface AlarmWidgetProps extends MetricWidgetProps { /** * Left Y axis */ - readonly leftYAxis?: YAxis; + readonly leftYAxis?: YAxisProps; } /** @@ -77,7 +109,7 @@ export class AlarmWidget extends ConcreteWidget { alarms: [this.props.alarm.alarmArn] }, yAxis: { - left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : { min: 0 } + left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : undefined } } }]; @@ -116,12 +148,12 @@ export interface GraphWidgetProps extends MetricWidgetProps { /** * Left Y axis */ - readonly leftYAxis?: YAxis; + readonly leftYAxis?: YAxisProps; /** * Right Y axis */ - readonly rightYAxis?: YAxis; + readonly rightYAxis?: YAxisProps; } /** @@ -153,8 +185,8 @@ export class GraphWidget extends ConcreteWidget { (this.props.rightAnnotations || []).map(mapAnnotation('right'))) }, yAxis: { - left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : { min: 0 }, - right: this.props.rightYAxis !== undefined ? this.props.rightYAxis : { min: 0 }, + left: this.props.leftYAxis !== undefined ? this.props.leftYAxis : undefined, + right: this.props.rightYAxis !== undefined ? this.props.rightYAxis : undefined, } } }]; diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/index.ts b/packages/@aws-cdk/aws-cloudwatch/lib/index.ts index e015d833e3b3f..5940a823ca866 100644 --- a/packages/@aws-cdk/aws-cloudwatch/lib/index.ts +++ b/packages/@aws-cdk/aws-cloudwatch/lib/index.ts @@ -5,7 +5,6 @@ export * from './layout'; export * from './metric'; export * from './text'; export * from './widget'; -export * from './yaxis'; // AWS::CloudWatch CloudFormation Resources: export * from './cloudwatch.generated'; diff --git a/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts b/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts deleted file mode 100644 index 46a6539a46b03..0000000000000 --- a/packages/@aws-cdk/aws-cloudwatch/lib/yaxis.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Properties for a Y-Axis - */ -export interface YAxisProps { - /** - * The min value - * - * @default 0 - */ - readonly min?: number; - - /** - * The max value - * - * @default No maximum value - */ - readonly max?: number; - - /** - * The label - * - * @default No label - */ - readonly label?: string; - - /** - * Whether to show units - * - * @default None (means true) - */ - readonly showUnits?: boolean; -} - -/** - * An Y-Axis on a CloudWatch dashboard widget - */ -export class YAxis { - public readonly min?: number; - public readonly max?: number; - public readonly label?: string; - public readonly showUnits?: boolean; - - constructor(props: YAxisProps) { - this.min = props.min || 0; - this.max = props.max; - this.label = props.label; - this.showUnits = props.showUnits; - } -} diff --git a/packages/@aws-cdk/aws-cloudwatch/test/integ.alarm-and-dashboard.expected.json b/packages/@aws-cdk/aws-cloudwatch/test/integ.alarm-and-dashboard.expected.json index 23cffe3022390..884254139bb11 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/integ.alarm-and-dashboard.expected.json +++ b/packages/@aws-cdk/aws-cloudwatch/test/integ.alarm-and-dashboard.expected.json @@ -45,7 +45,7 @@ "Arn" ] }, - "\"]},\"yAxis\":{\"left\":{\"min\":0}}}},{\"type\":\"metric\",\"width\":6,\"height\":6,\"x\":0,\"y\":8,\"properties\":{\"view\":\"timeSeries\",\"title\":\"More messages in queue with alarm annotation\",\"region\":\"", + "\"]},\"yAxis\":{}}},{\"type\":\"metric\",\"width\":6,\"height\":6,\"x\":0,\"y\":8,\"properties\":{\"view\":\"timeSeries\",\"title\":\"More messages in queue with alarm annotation\",\"region\":\"", { "Ref": "AWS::Region" }, @@ -56,7 +56,7 @@ "QueueName" ] }, - "\",{\"yAxis\":\"left\",\"period\":300,\"stat\":\"Average\"}]],\"annotations\":{\"horizontal\":[{\"label\":\"ApproximateNumberOfMessagesVisible >= 100 for 3 datapoints within 15 minutes\",\"value\":100,\"yAxis\":\"left\"}]},\"yAxis\":{\"left\":{\"min\":0},\"right\":{\"min\":0}}}},{\"type\":\"metric\",\"width\":6,\"height\":3,\"x\":0,\"y\":14,\"properties\":{\"view\":\"singleValue\",\"title\":\"Current messages in queue\",\"region\":\"", + "\",{\"yAxis\":\"left\",\"period\":300,\"stat\":\"Average\"}]],\"annotations\":{\"horizontal\":[{\"label\":\"ApproximateNumberOfMessagesVisible >= 100 for 3 datapoints within 15 minutes\",\"value\":100,\"yAxis\":\"left\"}]},\"yAxis\":{}}},{\"type\":\"metric\",\"width\":6,\"height\":3,\"x\":0,\"y\":14,\"properties\":{\"view\":\"singleValue\",\"title\":\"Current messages in queue\",\"region\":\"", { "Ref": "AWS::Region" }, diff --git a/packages/@aws-cdk/aws-cloudwatch/test/test.dashboard.ts b/packages/@aws-cdk/aws-cloudwatch/test/test.dashboard.ts index 94c91e29955d4..ca2c46f0b018d 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/test.dashboard.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/test.dashboard.ts @@ -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" }, - "\",\"metrics\":[],\"annotations\":{\"horizontal\":[]},\"yAxis\":{\"left\":{\"min\":0},\"right\":{\"min\":0}}}}]}" + "\",\"metrics\":[],\"annotations\":{\"horizontal\":[]},\"yAxis\":{}}}]}" ]]} })); @@ -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" }, - "\",\"metrics\":[],\"annotations\":{\"horizontal\":[]},\"yAxis\":{\"left\":{\"min\":0},\"right\":{\"min\":0}}}}]}" + "\",\"metrics\":[],\"annotations\":{\"horizontal\":[]},\"yAxis\":{}}}]}" ]]} })); diff --git a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts index a248d2d6422d4..45534b3bc06a6 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts @@ -1,6 +1,6 @@ import { Stack } from '@aws-cdk/cdk'; import { Test } from 'nodeunit'; -import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget, YAxis } from '../lib'; +import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib'; export = { 'add metrics to graphs on either axis'(test: Test) { @@ -30,7 +30,7 @@ export = { ['CDK', 'Tast', { yAxis: 'right', period: 300, stat: 'Average' }] ], annotations: { horizontal: [] }, - yAxis: { left: { min: 0 }, right: { min: 0 } } + yAxis: {} } }]); @@ -56,7 +56,7 @@ export = { ['CDK', 'Test', { yAxis: 'left', period: 300, stat: 'Average', label: 'MyMetric', color: '000000' }], ], annotations: { horizontal: [] }, - yAxis: { left: { min: 0 }, right: { min: 0 } } + yAxis: {} } }]); @@ -83,7 +83,7 @@ export = { region: { Ref: 'AWS::Region' }, metrics: [ ['CDK', 'Test', { yAxis: 'left', period: 300, stat: 'Average' }], - ], + ] } }]); @@ -115,7 +115,7 @@ export = { annotations: { alarms: [{ 'Fn::GetAtt': [ 'Alarm7103F465', 'Arn' ] }] }, - yAxis: { left: { min: 0 } } + yAxis: {} } }]); @@ -157,7 +157,7 @@ export = { fill: 'below', label: 'this is the annotation', }] }, - yAxis: { left: { min: 0 }, right: { min: 0 } } + yAxis: {} } }]); @@ -199,7 +199,7 @@ export = { label: 'Test >= 1000 for 2 datapoints within 10 minutes', }] }, - yAxis: { left: { min: 0 }, right: { min: 0 } } + yAxis: {} } }]); @@ -217,11 +217,11 @@ export = { right: [ new Metric({ namespace: 'CDK', metricName: 'Tast' }) ], - leftYAxis: new YAxis({ + leftYAxis: ({ label: "Left yAxis", max: 100 }), - rightYAxis: new YAxis({ + rightYAxis: ({ label: "Right yAxis", min: 10, showUnits: false @@ -243,7 +243,7 @@ export = { ], annotations: { horizontal: [] }, yAxis: { - left: { label: "Left yAxis", min: 0, max: 100 }, + left: { label: "Left yAxis", max: 100 }, right: { label: "Right yAxis", min: 10, showUnits: false } } } }]); From 0306ea3ea3ba4943cc965cd2b1876552f039d231 Mon Sep 17 00:00:00 2001 From: kpiljoong Date: Fri, 24 May 2019 17:11:35 +0900 Subject: [PATCH 4/4] remove YAxis import statement --- packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts index 20522854a18a9..45534b3bc06a6 100644 --- a/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts +++ b/packages/@aws-cdk/aws-cloudwatch/test/test.graphs.ts @@ -1,6 +1,6 @@ import { Stack } from '@aws-cdk/cdk'; import { Test } from 'nodeunit'; -import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget, YAxis } from '../lib'; +import { AlarmWidget, GraphWidget, Metric, Shading, SingleValueWidget } from '../lib'; export = { 'add metrics to graphs on either axis'(test: Test) {