abhogu abhogu - 9 months ago 71
Javascript Question

Major Ticks and Minor Ticks using Dygraphs

I am working with Dygraphs. I need to have a graph with a background of a grid that has major ticks in dark blue color and minor ticks in light blue color. There should be 1 major tick after every 4 minor ticks. I am looking for an effect similar to the picture shown below.

enter image description here

Picture courtsey :Stack overflow

I have spent a lot of time but have not been able to understand how to do it. Any lead in this direction is appreciated.


You could try using an underlayCallback. Something like:

var g = new Dygraph(div, data,
      underlayCallback: function(canvas, area, g) {
        for (const tick of majorTicks) {
          const x = g.toDomCoordsX(tick);
          canvas.fillRect(x, area.y, x, area.h);