Creating histogram for sensor with defined set of values (eg. select)

I have sensor wich can be in few predefined states, Like “state1”, “state2” or “state3”. Please see below logbook.


I want to create card in Lovelace that shows histogram for that sensor - how many times specifc state occurs. Please see example histogram for above logbook.
Zrzut ekranu z 2023-02-03 13-45-02
How can I do that?

Trying to do the same thing, but using time in each state - we need something like a histogram chart :face_with_monocle: following

I am also seeking for a solution for such topic in the moment I am working with integration for each state and show the integrated values but these creates a lot of entities