-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph_paper_generator.js
27 lines (24 loc) · 1004 Bytes
/
graph_paper_generator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*global jQuery*/
// http://en.wikipedia.org/wiki/Scalable_Vector_Graphics
var GRAPH_PAPER_GENERATOR = (function ($) {
var app = {};
/** @param graphSpec a graph specification with certain properties:
* width - the width of the paper
* height - the height of the paper
* drawGraph - a function that draws the graph lines.
*/
app.openGraph = function (graphSpec) {
var newWindow = window.open('', 'Graph');
var svgDoc = newWindow.document;
svgDoc.write('<svg width="' + graphSpec.width
+ '" height="' + graphSpec.height
+ '" xmlns="http://www.w3.org/2000/svg">');
svgDoc.write('</svg>');
svgDoc.close();
var svg = $(newWindow.document).find('svg');
//graphSpec.drawGraph(svg);
svg.append($('<line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />'));
return newWindow;
};
return app;
}(jQuery));