Search code examples
dygraphs

dygraphs: How to move the primary y-axis to right side


This the graph that I am looking for range-selector dygraph but instead of having the primary y-axis on left I want it on right side. Is it possible in dygraphs? Thanks for help.


Solution

  • You can do this by moving all your series to a secondary y-axis (which is always rendered on the right side) and then hiding the primary y-axis.

    Example at this fiddle:

    g = new Dygraph(document.getElementById("graph"), data,
                   {
                     series: {
                         A: { axis: 'y2' },
                         B: { axis: 'y2' },
                         ...
                     },
                     axes: {
                         y: {
                             drawGrid: false,
                             independentTicks: false
                         },
                         y2: {
                             drawGrid: true,
                             independentTicks: true
                         }
                     }
                 });
    

    You'll still get a primary y-axis, which you currently have to hide via CSS (at least until this issue is resolved):

    .dygraph-axis-label-y1 { display: none; }