0

I am using RGraph version 5.00, trying to make a scatter plot that looks like this,

https://i.stack.imgur.com/lsPB8.png

This is my best effort, thus far,

https://i.stack.imgur.com/LKIYH.png

How can I move the Y-Axis from the left-hand side to the center of the plot?

I've tried setting the 'xaxisScaleMin' option to 'mirror', but that doesn't work. Here is my code,

            new RGraph.SVG.Scatter({
            id: 'chart-container',
            data: [],
            options: {
                backgroundGridHlinesCount: 10,
                backgroundGridVlinesCount: 10,
                colors: ['cyan', 'magenta', '#cc0', 'black', 'red', 'green', 'blue', 'brown'],
                linewidth: 3,
                gutterLeft: 50,
                gutterBottom: 50,
                xaxisLinewidth: 1.5,
                xaxisScale: true,
                xaxisScaleMax: 125,
                xaxisScaleMin: -125,
                yaxisLabelsCount: 10,
                yaxisLinewidth: 1.5,
                yaxisScale: true,
                yaxisScaleMax: 125,
                yaxisScaleMin: -125,
                title: 'solid ink colors'
            }
        }).draw();

2019-05-29: Looking at the source, RGraph.svg.common.core.js, there is no way to place the Y-axis at the origin, as with the X-axis. Placing the Y-axis on the origin, when it is in the range of the graph, seems like a proper default behavior, or should at least be a simple option. I will try changing the source.

1 Answers1

0

One of the examples in the download does just this:

demos/scatter-negative-x-axis.html

The trick is to add a large left margin and then use the drawing API X axis to add the extra axis (the left-hand-side X axis).

(incidentally - the lines that are shown on the chart are just trigonometry curves - sin/cos/tan)

You can get the RGraph download here:

https://www.rgraph.net/download.html#stable

Richard
  • 4,809
  • 3
  • 27
  • 46