vasturiano / timelines-chart

Timelines Chart
http://vasturiano.github.io/timelines-chart/example/categorical/
MIT License
556 stars 121 forks source link

Custom time scale confusion #82

Open unphased opened 4 years ago

unphased commented 4 years ago

Hi, I'm trying to use this via

<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script>
<script src="//unpkg.com/timelines-chart"></script>

and I have a hunch that this could already explain why setting a custom .zColorScale(d3.scaleLinear().domain([0, 1000]).range(["blue", "red"])) is not working. But I think that it should just work. But, it does not produce any change to the colors or legend to use this compared to leaving out the zColorScale call.

My use case is that my timing is in units of nanoseconds (I am using this tool to display GPU profiling output), I am already using .xTickFormat(n => +n).timeFormat('%Q') which helps a bit for sanity because my time units are not in epoch ms, but rather in ns since system boot (or something like this).

The main things I'm trying to improve right now are:

I'm a d3 newbie here too :(

unphased commented 4 years ago

I stumbled upon the fix by actually removing the call to .zQualitative(false). This made the color scale take.

vasturiano commented 4 years ago

@unphased, yes for your use case you should be using the continuous mode, that you can set with .zQualitative(false).

As for the time axis in nanoseconds, have you seen this example: http://vasturiano.github.io/timelines-chart/example/custom-time-format/