Click here to Skip to main content
15,905,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone know how jgPlot ( version: 1.0.8 * revision: 1250 ) jqplotToImageElemStr, jqplotToImageStr, jqplotToImageElem works?
The ultimate goal is that I'm trying to get the image (graph) from the clients machine to the server.

I've tried.........
JavaScript
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

But it doesn't work. The debug always tells me that there is an illegal character, and it points to a bloody space.

I've also tried....
JavaScript
string zzzz = "var imgData = $('MainContent_ctl02_ctl20_pnlPlaceHolderForExtraControl').jqplotToImageElemStr({})"; 

and ..
JavaScript
string zzzz = "var imgData = $('MainContent_ctl02_ctl20_pnlPlaceHolderForExtraControl').jqplotToImageElemStr({}); $('#imgChart1').append(imgElem)";

..but they both state that a space is an illegal character (from the above java mentioned script), which I also have removed.

Any ideas or even better, if any one has a working example as the jqPlot and google is no help so far.

Or alternatively, is there a way to force jqPlot onto a html5 canvas? (Cause I know how to get the image from there using html5)

Here is the actual (working code) I use to create the graph.
JavaScript
var vtPie719247 = [ ['Foreign',3],['Mixed:_Public_and_Private',0],['NGO/CBO',0],['Private',1],['Public',0] ];
$.jqplot('MainContent_ctl02_ctl24_pnlPlaceHolderForExtraControl', [vtPie719247], { grid: { drawBorder: false, drawGridlines: false, background: '#ffffff', shadow:false }, axesDefaults: {  }, seriesDefaults:{ renderer:$.jqplot.PieRenderer, rendererOptions: { showDataLabels: true } }, legend: { show: true, rendererOptions: { numberRows: 1 }, location: 's' } }); 
......
Posted
Updated 2-Sep-13 20:25pm
v4
Comments
Prasad Khandekar 3-Sep-13 2:25am    
Which version of JQPlot library are you using? The latest library doesn't seem to have the mentioned methods.
Serenity1 3-Sep-13 2:31am    
version: 1.0.8 * revision: 1250. From there site directly, I downloaded it a few days ago for the first time.

Its found in..
jquery.jqplot.js
line 9264
Prasad Khandekar 3-Sep-13 2:46am    
It's based on HTML5 canvas and hence will be available in all those browsers which supports it. IE9+. Firefox, Chreome etc.
Serenity1 3-Sep-13 2:49am    
I tried placing the script onto a canvas but it just bombs out?
It only seems to work on something that is a div block.
Serenity1 3-Sep-13 2:55am    
I've change the code to...
"var imgData = $.jqplot('MainContent_ctl02_ctl20_pnlPlaceHolderForExtraControl').jqplotToImageStr({});";

but now I get a different error....
Error: No data specified
[Break On This Error]
...f(az===null){az=-aA;au=ai;if(au==="multiply"){az+=2}}if(aA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900