将jqPlot图保存到图像文件

use*_*359 2 javascript image save mouseclick-event jqplot

我正在使用jqPlot在一些网页上显示许多图表.我希望能够将这些图表保存到图像文件中.

做这个的最好方式是什么?是否可以在图表上使用右键菜单选项,以便将图表保存到图像文件中?

以下是我的一个图表的一些代码:

var plotCogsLineGraph = $.jqplot('FinancialsLineGraph', [[30,31,34,40,45], [34,38,31,42,38]], 
{ 
            axes:
            {
                xaxis:
                {
                      ticks: ['5','4','3','2','1']
                },
                yaxis:
                {
                    label:'%',
                    pad: 1.05,
                    ticks: ['0','15','30','45','60']
                }
            },

            width: 480, height: 270,
            legend:{show:true, location: 's', placement: 'insideGrid', renderer: $.jqplot.EnhancedLegendRenderer},
    seriesDefaults: 
    {
                rendererOptions: {smooth: true}
    },
    series:[ 
                {
                    lineWidth:1, 
                    label:'COGS',
                    markerOptions: { size:1, style:'dimaond' }
                }, 
                {
                    lineWidth:1, 
                    label:'Wages',
                    markerOptions: { size: 1, style:"dimaond" }
                }
                ]
    }
); 
Run Code Online (Sandbox Code Playgroud)

需要在上面的代码中添加什么才能将图形保存到图像文件中?

Lia*_*ang 8

试试这个:

$('#FinancialsLineGraph').jqplotSaveImage()
Run Code Online (Sandbox Code Playgroud)