CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

JQPlot to Image

by tonyzhou » 05 Sep 2015 04:20

I am using jqPlot to display some charts also with a button to enable the chart to be saved to an image.
Ask: How such functionality can be achieved with IWCGJQPlot?
jqplot2png.jpg

javascript code
if (!$.jqplot.use_excanvas) {
$('div.jqplot-target').each(function(){
var outerDiv = $(document.createElement('div'));
var header = $(document.createElement('div'));
var div = $(document.createElement('div'));

outerDiv.append(header);
outerDiv.append(div);

outerDiv.addClass('jqplot-image-container');
header.addClass('jqplot-image-container-header');
div.addClass('jqplot-image-container-content');

header.html('Right Click to Save Image As...');

var close = $(document.createElement('a'));
close.addClass('jqplot-image-container-close');
close.html('Close');
close.attr('href', '#');
close.click(function() {
$(this).parents('div.jqplot-image-container').hide(500);
})
header.append(close);

$(this).after(outerDiv);
outerDiv.hide();

outerDiv = header = div = close = null;

if (!$.jqplot._noToImageButton) {
var btn = $(document.createElement('button'));
btn.text('View Plot Image');
btn.addClass('jqplot-image-button');
btn.bind('click', {chart: $(this)}, function(evt) {
var imgelem = evt.data.chart.jqplotToImageElem();
var div = $(this).nextAll('div.jqplot-image-container').first();
div.children('div.jqplot-image-container-content').empty();
div.children('div.jqplot-image-container-content').append(imgelem);
div.show(500);
div = null;
});

$(this).after(btn);
btn.after('<br />');
btn = null;
}
});
}
You do not have the required permissions to view the files attached to this post.
tonyzhou
 
Posts: 112
Joined: 28 Jun 2015 13:02

by tonyzhou » 06 Sep 2015 04:21

I 've got methods from CHM
tonyzhou
 
Posts: 112
Joined: 28 Jun 2015 13:02


Return to JQPlot

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.