epezent / implot

Immediate Mode Plotting
MIT License
4.55k stars 503 forks source link

Timeline plot (similar to horizontal bar plot with several bars on the same line) #464

Open mat-r opened 1 year ago

mat-r commented 1 year ago

Before to start to do it from scratch, I would like to know if ImPlot already provides something like a timeline.

Let us say we have a list of events A, B, C... which have a start timestamp and a stop timestamp. Several of the same events can exist with different timestamps in the list. E.g.: A: 1, 3 B: 1, 5 C: 2, 7 B: 6, 9 A: 12, 20 ...

On Y will be one line per event (A, B, C...). X will be the time axis. I expect something like:

(Events)
    |            CCCCCCCCCCC                    CCCC         CCCC
    |   BBBBBBBBBB           BBBB          BBB            BBBBBBBBB
    |                AAAAAAAAAAAAAA           AAA          AAAAA
    _____________________________________________________________   (time)

Is there something already available to do this? If not, could you tell me which direction you recommend to do it (tweaking ImPlot::PlotBars or ImPlot::Digital)?

kdxq commented 1 year ago

I think ImPlot:: PlotDigital can achieve the functions you need