JqPlot As Image

后端 未结 5 907
梦谈多话
梦谈多话 2020-12-14 04:44

In the latest JqPlot examples (see here, there are buttons underneath some charts that you can click, and a div slides down with the chart as an image, allowing you to right

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 05:12

    When you got problems with the image output you have to change the jquery.jqplot.js. On some browsers the script stops of infinte loop (Chrome and Firefox).

    change this code:

    for (var i=0; i tagwidth) {
            breaks.push(i);
            w = '';
            i--;
        }   
    }
    

    to this:

    for (var i=0; i tagwidth && w.length > words[i].length) {
            breaks.push(i);
            w = '';
            i--;
        }   
    }
    

    add this to your html:

    and this to jquery after your jqplot-code:

    $(document).ready(function(){
        //after creating your plot do
        var imgData = $('#chart').jqplotToImageStr({}); // given the div id of your plot, get the img data
        var imgElem = $('').attr('src',imgData); // create an img and add the data to it
        $('#imgChart').append(imgElem);​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ //
    });
    

    See a demo here

提交回复
热议问题