Question

I am trying to write a real time graph based on dummy data for now. My problem is that the resolution for my graph is too big for me. My timeUnit is an hour, but I get a range of 16 hours which I don't need to see right now in the same graph. For example the graph starts at 00:00 and ends at 16:00. I would like to have a resolution like that: 00:00, 00:05, 00:10, 00:15, and so on....(tick every five minute). I tried to work with timeunit=minute, but I still get the same range which is now divided to a more points.

This is my code for x-axis :

var time = new Rickshaw.Fixtures.Time();
var hours = time.unit('hour');
var xAxis = new Rickshaw.Graph.Axis.Time( {
  graph: graph,
  ticksTreatment: ticksTreatment,
  timeUnit: hours,
  timeFixture: new Rickshaw.Fixtures.Time()
} );
Was it helpful?

Solution

You could try this:

var unit = {}
unit.formatTime = function(d) {
  return d.toUTCString().match(/(\d+:\d+):/)[1];
};
unit.formatter = function(d) { return this.formatTime(d)};
unit.name = "5 minute";
unit.seconds = 300;
var xAxis = new Rickshaw.Graph.Axis.Time({
  graph: graph,
  timeUnit:unit,
  ticksTreatment: ticksTreatment,
  timeFixture: new Rickshaw.Fixtures.Time.Local()
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top