0

我想捕获画布 R Graph 图像并将该图像保存到我自己的文件夹中。

我正在使用以下代码绘制 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();
    });

请任何人帮助我。谢谢

4

1 回答 1

0

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

var base64Img = canvas.toDataURL();

完成此步骤后,您将获得 base64 编码图像。只需将其发布到您的服务器并在将其写入文件之前对其进行解码(base64)。

于 2016-12-06T09:10:59.350 回答