In MongoDB Charts I created an Circular Donut to view the average of my property score
. This score ranges from 0 to 100 (including) as it is score based on percentage.
I want the scores to be aggregated up to steps of 10%, except the first and last 10%. To clearify, I want the donut to show these aggregations:
0-9%, 10-19%, up to 80-89%, 90-99%, 100%
If I use the BINNING ON with BIN SIZE 10 in MongoDB Charts, I get the following:
0-10%, 10-20%, up to 80-90% 90-100%, 100-110%
If something is exacly 100%, it will be added to the 100-110%, this could mean that the calculation is already good but the naming of the ranges is bad.
How do I set this custom data binning?
What I would do is treat your data as categories. You can map each data point to a new label value based on their interval.
Are you able to write a map query to do this conversion?https://docs.mongodb.com/manual/reference/operator/aggregation/map/
For example:
all data points from 0 to 9 -> "0-9"
all data points from 10 to 19 -> "10-19"
...
all data points == 100 -> "100"
After the binning is going to be easy and you can probably remap the labels to be more readable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With