JQPlot ( view plot image ) breaks in Firefox

杀马特。学长 韩版系。学妹 提交于 2019-12-11 08:23:23

问题


For some reason jqplot can't render images in firefox.

It just crashes on line 182 of the image script with no plausible problem I can see.

When I run the exact same function in chrome it works perfectly.

Never had this problem before.

I recently switched to OSX, think it might have something to do with firefox on this os.

If anyone knows of a solution please let me know.

I will post an update if I figure it out myself.


回答1:


The issue is likely with this piece of code in writeWrappedText() function:

for (var i=0; i<wl; i++) {
    w += words[i];
    if (context.measureText(w).width > tagwidth) {
        breaks.push(i);
        w = '';
        i--;
    }  
}

Commenting out i-- solves the issue for me.




回答2:


This issue was discovered and fixed last year by the jqplot team in this bug report. The fix they recommend is to change:

if (context.measureText(w).width > tagwidth) {

to

if (context.measureText(w).width > tagwidth && w.length > words[i].length) {

Looks like the fix should be in recent versions of jqplot. If you run into this, updating your library may help.




回答3:


I render images from graphs without any problem...

    var imgData = $('#chart').jqplotToImageStr({});

Then I send to a php page the imgData var (that contains the base64 image) to let it be downloaded directly. I you want just to show that image, you just have to add that var to the src attr of a image tag (or opening it as a popup passing the var as the href attr of the window)

    window.open(imgData,"_blank","scrollbars=0");


来源:https://stackoverflow.com/questions/20836075/jqplot-view-plot-image-breaks-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!