feat(aws-cloudwatch): support labels on pie charts
Describe the feature
From the Cloudwatch console an option is provided to display labels on a pie chart which is implemented in the source with the property below.
"labels": {
"visible": true
}
This is missing in the CDK library which makes it impossible to create dashboards with labels on pie charts.
Use Case
Without the labels on the dashboard, a user must explicitly hover their cursor on the dashboard widget for a specific segment. For teams projecting live dashboards on external display this is impractical since you cannot get a single view with labels for all the segments.
Proposed Solution
Include the missing property in the generated graph widget output following the steps below.
- Add a new
LabelPropsinterface to theaws-cloudwatch/lib/graph.tsmodule. - Expose this as an optional property called
labels, consistent with name from the console, in theGraphWidgetProps. - Add the
labelsproperty to the final output of thetoJson()method of theGraphWidget.
Other Information
No response
Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
CDK version used
2.124.0
Environment details (OS name and version, etc.)
MacOS, Sonama 14.3
Thank you for your feedback. Yes we should add this support in a pull request.
I will submit a PR
For those looking for a workaround, this very basic implementation worked well enough for me
class LabeledPieWidget extends GraphWidget {
override toJson(): any[] {
const json = super.toJson();
json[0].properties.labels = { visible: true };
return json;
}
}
usage:
new LabeledPieWidget({
view: GraphWidgetView.PIE,
// ...
})
@kofrasa I could potentially submit a PR for this if you are no longer working on it
@Kasra-G Please go ahead. I already used the workaround. The PR stalled due to some issues in the testing environment that I never got to resolving.
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.