Skip to content

Cloudwatch GraphWidget missing legendΒ #3625

@mitchlloyd

Description

@mitchlloyd
  • I'm submitting a ...

    • πŸͺ² bug report
    • πŸš€ feature request
    • πŸ“š construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the expected behavior (or behavior of feature suggested)?

cloudwatch.GraphWidget should accept a legend or legendPosition property that sets the appropriate values in the toJson output.

My current workaround looks like this:

export class ExtendedGraphWidget extends GraphWidget {
  private legendPosition: LegendPosition;
  constructor(props: ExtendedGraphWidgetProps) {
    super(props);
    this.legendPosition = props.legendPosition || LegendPosition.Bottom;
  }

  toJson(): any[] {
    const widgetConfig = super.toJson();

    return widgetConfig.map(obj => ({
      ...obj,
      properties: {
        ...obj.properties,
        legend: {
          position: this.legendPosition,
        }
      }
    }));
  }
}
  • What is the motivation / use case for changing the behavior or adding this feature?
    This legend config allows users to change the position of the legend or hide the legend by passing "hidden".

  • Please tell us about your environment:

    • CDK CLI Version: 1.3.0 (build bba9914)
    • Module Version: aws-cloudwatch 1.3.0
    • OS: OSX
    • Language: TypeScript

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-cloudwatchRelated to Amazon CloudWatcheffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.good first issueRelated to contributions. See CONTRIBUTING.mdin-progressThis issue is being actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions