2

I have a line graph that I would like to have two different Y-axes (this is usually accomplished by having one set of labels on the left, and one on the right). So I can have two different types of related data on the same graph, but with different scales. Is this possible with RGraph?

Bobb Fwed
  • 317
  • 3
  • 6

1 Answers1

2
<canvas id="cvs" width="750" height="250" style="border: 1px solid #ccc">[No canvas support]</canvas>

<script>
    data  = [4,8,6,8,6,3,5];
    data2 = [15,18,14,24,35,22,31];

    new RGraph.Line({
        id: 'cvs',
        data: data,
        options: {
            spline: true,
            marginInner: 10,
            xaxis: false,
            yaxis: false,
            colors:['blue']
        }
    }).draw();

    new RGraph.Line({
        id: 'cvs',
        data: data2,
        options: {
            spline: true,
            marginInner: 10,
            xaxis: false,
            yaxis: false,
            backgroundGrid: false,
            yaxisPosition: 'right'
        }
    }).draw();
</script>

Richard (the developer) helped me out. To achieve this, you combine two graphs, giving each graph the same ID target. The second graph will be written over the first. Which means, if everything lines up, there will be (what looks like) a single graph, just be sure everything lines up between the two (margins, labels, etc.).

The code is the example Richard gave me.

Bobb Fwed
  • 317
  • 3
  • 6