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); }) | |
} | |
}); |
When running this I receive the error TypeError: Cannot call method 'replace' of undefined
Using node-inspector I found that $.plot
is undefined. I'm using jsdom 0.2.0 & node 0.4.9.
Any ideas what might be causing this?
@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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I hope this project isn't too depreciated, but I'm having trouble finding the to the flot files.
I found a diff of yours but it seems to be old. I was wondering if you had any advice to modifying the flot files, and other modules to work with node.js
or still follow the diff from https://gist.github.com/708172
Thanks, It seems like you are the only person to have created a working server-side Flot.