Any way to create a simple timeline with Google Ch

2019-05-28 21:27发布

问题:

Is there any way to create a simple timeline of events with Google Charts? (I don't mean an annotated timeline.)

In my case, I'd like to display a series of event times (not time intervals) in milliseconds, with labels, a bit like this:

| eventFoo
  | eventBar
        | eventFooBar

'            '            '
0           500         1000

I think think of ways to hack this, for example:

http://www.designinginteractive.com/code/how-to-build-a-gantt-chart-with-the-google-charts-api/

...but it would be nice to be able to code something like this 'natively'.

回答1:

OK -- FWIW, I wound up building a JavaScript timeline implementation myself.

You can see it in action in an article I wrote about the Navigation Timing API (at the bottom of the page).

The x-axis in this case displays milliseconds, but the timeline could easily be adapted for dates. Adding tick marks to the x-axis would be somewhat complex algorithmically, but not difficult to code.