Hi Pratham,
Check this Mendix for any chart documentation for structuring the data and for the logic
https://docs.mendix.com/howto7/extensibility/charts-any-usage/
Then make use of Database retrieve and aggregate list operations to find count and populate the X label and y Values in the NP create to structure the data.