Created
February 24, 2011 13:51
-
-
Save jfsiii/842175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("jsdom").env({ | |
html: "<html><body></body></html>", | |
scripts: [ | |
'http://code.jquery.com/jquery-1.5.min.js', | |
'http://jsno.de/javascripts/jquery.flot.svn.js', // please don't hotlink | |
'http://jsno.de/javascripts/jquery.flot.text.js' // please don't hotlink | |
], | |
done: function (errors, window) | |
{ | |
var i, d1 = [], d2 = [], d3 = []; | |
for (i = 10; --i;) d1.push([i, parseInt(Math.random() * 30)]); | |
for (i = 10; --i;) d2.push([i, parseInt(Math.random() * 30)]); | |
for (i = 10; --i;) d3.push([i, parseInt(Math.random() * 30)]); | |
var line_opts = { show: false, fill: true, steps: false }; | |
var bars_opts = { show: true, barWidth: 0.6 }; | |
var data = [ | |
{ label: "sweet", data: d1, lines: line_opts, bars: bars_opts }, | |
{ label: "bars", data: d2, lines: line_opts, bars: bars_opts }, | |
{ label: "bro", data: d3, lines: line_opts, bars: bars_opts } | |
], | |
options = { | |
width: 600, height: 300, | |
xaxis: { labelWidth: 50, labelHeight: 20 }, | |
yaxis: { labelWidth: 50, labelHeight: 20 }, | |
grid: { | |
backgroundColor: "#eee", | |
canvasText: { show: true, font: "sans 9px" }, // for text plugin | |
clickable: false, hoverable: false // non-interactive | |
} | |
}, | |
$ = window.$, | |
jQuery = window.jQuery, | |
$div = $('div'), | |
$plot = $.plot($div, data, options), | |
canvas = $plot.getCanvas(), | |
dir = '/home/jfsiii/webapps/node_flot/public/', | |
name = 'jsdom.png', | |
loc = dir + name, | |
fs = require('fs'), | |
out = fs.createWriteStream(loc); | |
canvas | |
.createPNGStream() | |
.on('data', function (chunk) { out.write(chunk); }) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@GoldenStake, @rlt can you take a look at this Flot on node-canvas gist and let me know if you're still having issues?
BTW, @GoldenStake, created a patch for Flot 0.7