Skip to content

Commit 060ffb3

Browse files
authored
feat(custom): add graphWidgetLegend property to CustomMetricGroup (#226)
Fixes #225 --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent 40224ba commit 060ffb3

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

API.md

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/monitoring/custom/CustomMonitoring.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
HorizontalAnnotation,
77
IMetric,
88
IWidget,
9+
LegendPosition,
910
Row,
1011
TextWidget,
1112
YAxisProps,
@@ -15,18 +16,18 @@ import {
1516
AnomalyDetectingAlarmFactory,
1617
AnomalyDetectionThreshold,
1718
BaseMonitoringProps,
19+
createGraphWidget,
1820
CustomAlarmFactory,
1921
CustomThreshold,
2022
DefaultGraphWidgetHeight,
2123
DefaultSummaryWidgetHeight,
2224
FullWidth,
25+
getHashForMetricExpressionId,
2326
GraphWidgetType,
2427
MetricStatistic,
2528
MetricWithAlarmSupport,
2629
Monitoring,
2730
MonitoringScope,
28-
createGraphWidget,
29-
getHashForMetricExpressionId,
3031
recommendedWidgetWidth,
3132
} from "../../common";
3233
import {
@@ -150,22 +151,27 @@ export interface CustomMetricGroup {
150151
readonly title: string;
151152
/**
152153
* type of the widget
153-
* @default - line
154+
* @default line
154155
*/
155156
readonly graphWidgetType?: GraphWidgetType;
156157
/**
157158
* optional axis
158-
* @default - undefined
159+
* @default undefined
159160
*/
160161
readonly graphWidgetAxis?: YAxisProps;
161162
/**
162163
* optional right axis
163-
* default: undefined
164+
* @default undefined
164165
*/
165166
readonly graphWidgetRightAxis?: YAxisProps;
167+
/**
168+
* graph widget legend
169+
* @default BOTTOM
170+
*/
171+
readonly graphWidgetLegend?: LegendPosition;
166172
/**
167173
* Flag indicating, whether this is an important metric group that should be included in the summary as well.
168-
* @default - false
174+
* @default false
169175
*/
170176
readonly important?: boolean;
171177
/**
@@ -368,6 +374,7 @@ export class CustomMonitoring extends Monitoring {
368374
rightAnnotations: annotatedGroup.rightAnnotations,
369375
leftYAxis: annotatedGroup.metricGroup.graphWidgetAxis,
370376
rightYAxis: annotatedGroup.metricGroup.graphWidgetRightAxis,
377+
legendPosition: annotatedGroup.metricGroup.graphWidgetLegend,
371378
};
372379

373380
const widget = useAnomalyDetectionWidget

test/monitoring/custom/CustomMonitoring.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Stack } from "aws-cdk-lib";
22
import { Template } from "aws-cdk-lib/assertions";
33
import {
44
ComparisonOperator,
5+
LegendPosition,
56
MathExpression,
67
Metric,
78
Shading,
@@ -148,6 +149,7 @@ test("snapshot test", () => {
148149
horizontalRightAnnotations: [
149150
{ label: "DummyAnnotation3", value: 20, fill: Shading.BELOW },
150151
],
152+
graphWidgetLegend: LegendPosition.RIGHT,
151153
},
152154
{
153155
title: "DummyGroup4",

test/monitoring/custom/__snapshots__/CustomMonitoring.test.ts.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)