$(document).ready(function(){
var line_01_data = [[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]];
var line_02_data = [[4,6],[3,45],[23,91],[18,71],[92,70],[46,15]];
var lines_data = [line_01_data,line_02_data];
var plot = $.jqplot('chartdiv', lines_data);
var imgData = $("#chartdiv").jqplotToImageStr({}); // given the div id of your plot, get the img data
var imgElem = $("<img/>").attr("src",imgData); // create an img and add the data to it
$("#chartImgDiv").append(imgElem); // append the img to the DOM
var line_01_data = [[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]];
var line_02_data = [[4,6],[3,45],[23,91],[18,71],[92,70],[46,15]];
var lines_data = [line_01_data,line_02_data];
var plot = $.jqplot('chartdiv', lines_data);
var imgData = $("#chartdiv").jqplotToImageStr({}); // given the div id of your plot, get the img data
var imgElem = $("<img/>").attr("src",imgData); // create an img and add the data to it
$("#chartImgDiv").append(imgElem); // append the img to the DOM
});
jsp代码:
<body>
<div id="chartdiv" style="width: 500px; height: 500px;"></div>
<div id="chartImgDiv"></div>
</body>
感谢Stack Overflow上的一位网友:http://stackoverflow.com/questions/12182598/jqplot-as-image
//after creating your plot do
var imgData = $('#chart1').jqplotToImageStr({}); // given the div id of your plot, get the img data
var imgElem = $('<img/>').attr('src',imgData); // create an img and add the data to it
$('#imgChart1').append(imgElem); // append the img to the DOM