0

I want to capture canvas R Graph image and save that image into my own folder.

I am using following code for plotting R Graph:

var drawXChartGraph = function () {

        var line1 = new RGraph.Line({
            id: 'cvs',
            data: [
            [15, 15, 15, 15, 15, 15, 15, 15, 15, 15]
        ],
            options: {
                linewidth: 1,
                gutterLeft: 40,
                backgroundGrid: false,
                title: 'X-CHART',
                colors: ['red'],
                fillstyle: 'rgba(255,0,0,0.2)',
                ymin: 0,
                ymax: 16,
                labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                scaleDecimals: 2,
                key: ['UCL', 'LCL', 'XBar', 'AVG'],
                keyPosition: 'gutter',
                keyColorShape: 'circle',
                keyColors: ['red', 'red', 'green', 'black'],
                textSize: 10,
                textAccessible: true
            }
        }).draw();

    };

    $(document).ready(function () {
        drawXChartGraph();
    });

Please anyone help me. Thanks

1 Answers1

0

var canvas = document.getElementById('cvs');

var base64Img = canvas.toDataURL();

After this step you have the base64 encoded image. Just POST it to your server and decode(base64) it before writing it into a file.

ravi kanth
  • 36
  • 2