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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
/*
PlotKit SVG
===========
SVG Renderer for PlotKit
Copyright
---------
Copyright 2005,2006 (c) Alastair Tse <alastair^liquidx.net>
For use under the BSD license. <http://www.liquidx.net/plotkit>
*/
// -------------------------------------------------------------------------
// NOTES: - If you use XHTML1.1 strict, then you must include each MochiKit
// file individuall.
// - For IE support, you must include the AdobeSVG object hack.
// See tests/svg.html for details.
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Check required components
// -------------------------------------------------------------------------
try {
if (typeof(PlotKit.Layout) == 'undefined')
{
throw "";
}
}
catch (e) {
throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Layout"
}
// ---------------------------------------------------------------------------
// SVG Renderer
// ---------------------------------------------------------------------------
PlotKit.SVGRenderer = function(element, layout, options) {
if (arguments.length > 0)
this.__init__(element, layout, options);
};
PlotKit.SVGRenderer.NAME = "PlotKit.SVGRenderer";
PlotKit.SVGRenderer.VERSION = PlotKit.VERSION;
PlotKit.SVGRenderer.__repr__ = function() {
return "[" + this.NAME + " " + this.VERSION + "]";
};
PlotKit.SVGRenderer.toString = function() {
return this.__repr__();
}
PlotKit.SVGRenderer.SVGNS = 'http://www.w3.org/2000/svg';
PlotKit.SVGRenderer.prototype.__init__ = function(element, layout, options) {
var isNil = MochiKit.Base.isUndefinedOrNull;
// default options
this.options = {
"drawBackground": true,
"backgroundColor": Color.whiteColor(),
"padding": {left: 30, right: 30, top: 5, bottom: 10},
"colorScheme": PlotKit.Base.palette(PlotKit.Base.baseColors()[1]),
"strokeColor": Color.whiteColor(),
"strokeColorTransform": "asStrokeColor",
"strokeWidth": 0.5,
"shouldFill": true,
"shouldStroke": true,
"drawXAxis": true,
"drawYAxis": true,
"axisLineColor": Color.blackColor(),
"axisLineWidth": 0.5,
"axisTickSize": 3,
"axisLabelColor": Color.blackColor(),
"axisLabelFont": "Arial",
"axisLabelFontSize": 9,
"axisLabelWidth": 50,
"axisLabelUseDiv": true,
"pieRadius": 0.4,
"enableEvents": true
};
MochiKit.Base.update(this.options, options ? options : {});
this.layout = layout;
this.element = MochiKit.DOM.getElement(element);
this.container = this.element.parentNode;
this.height = parseInt(this.element.getAttribute("height"));
this.width = parseInt(this.element.getAttribute("width"));
this.document = document;
this.root = this.element;
// Adobe SVG Support:
// - if an exception is thrown, then no Adobe SVG Plugin support.
try {
this.document = this.element.getSVGDocument();
this.root = isNil(this.document.documentElement) ? this.element : this.document.documentElement;
}
catch (e) {
}
this.element.style.zIndex = 1;
if (isNil(this.element))
throw "SVGRenderer() - passed SVG object is not found";
if (isNil(this.container) || this.container.nodeName.toLowerCase() != "div")
throw "SVGRenderer() - No DIV's around the SVG.";
// internal state
this.xlabels = new Array();
this.ylabels = new Array();
// initialise some meta structures in SVG
this.defs = this.createSVGElement("defs");
this.area = {
x: this.options.padding.left,
y: this.options.padding.top,
w: this.width - this.options.padding.left - this.options.padding.right,
h: this.height - this.options.padding.top - this.options.padding.bottom
};
MochiKit.DOM.updateNodeAttributes(this.container,
{"style":{ "position": "relative", "width": this.width + "px"}});
};
PlotKit.SVGRenderer.prototype.render = function() {
if (this.options.drawBackground)
this._renderBackground();
if (this.layout.style == "bar") {
this._renderBarChart();
this._renderBarAxis();
}
else if (this.layout.style == "pie") {
this._renderPieChart();
this._renderPieAxis();
}
else if (this.layout.style == "line") {
this._renderLineChart();
this._renderLineAxis();
}
};
PlotKit.SVGRenderer.prototype._renderBarOrLine = function(data, plotFunc, startFunc, endFunc) {
var colorCount = this.options.colorScheme.length;
var colorScheme = this.options.colorScheme;
var setNames = MochiKit.Base.keys(this.layout.datasets);
var setCount = setNames.length;
for (var i = 0; i < setCount; i++) {
var setName = setNames[i];
var attrs = new Array();
var color = colorScheme[i%colorCount];
if (this.options.shouldFill)
attrs["fill"] = color.toRGBString();
else
attrs["fill"] = "none";
if (this.options.shouldStroke &&
(this.options.strokeColor || this.options.strokeColorTransform)) {
if (this.options.strokeColor)
attrs["stroke"] = this.options.strokeColor.toRGBString();
else if (this.options.strokeColorTransform)
attrs["stroke"] = color[this.options.strokeColorTransform]().toRGBString();
attrs["strokeWidth"] = this.options.strokeWidth;
}
if (startFunc)
startFunc(attrs);
var forEachFunc = function(obj) {
if (obj.name == setName)
plotFunc(attrs, obj);
};
MochiKit.Iter.forEach(data, bind(forEachFunc, this));
if (endFunc)
endFunc(attrs);
}
};
PlotKit.SVGRenderer.prototype._renderBarChart = function() {
var bind = MochiKit.Base.bind;
var drawRect = function(attrs, bar) {
var x = this.area.w * bar.x + this.area.x;
var y = this.area.h * bar.y + this.area.y;
var w = this.area.w * bar.w;
var h = this.area.h * bar.h;
this._drawRect(x, y, w, h, attrs);
};
this._renderBarOrLine(this.layout.bars, bind(drawRect, this));
};
PlotKit.SVGRenderer.prototype._renderLineChart = function() {
var bind = MochiKit.Base.bind;
var addPoint = function(attrs, point) {
this._tempPointsBuffer += (this.area.w * point.x + this.area.x) + "," +
(this.area.h * point.y + this.area.y) + " ";
};
var startLine = function(attrs) {
this._tempPointsBuffer = "";
this._tempPointsBuffer += (this.area.x) + "," + (this.area.y+this.area.h) + " ";
};
var endLine = function(attrs) {
this._tempPointsBuffer += (this.area.w + this.area.x) + "," +(this.area.h + this.area.y);
attrs["points"] = this._tempPointsBuffer;
var elem = this.createSVGElement("polygon", attrs);
this.root.appendChild(elem);
};
this._renderBarOrLine(this.layout.points,
bind(addPoint, this),
bind(startLine, this),
bind(endLine, this));
};
PlotKit.SVGRenderer.prototype._renderPieChart = function() {
var colorCount = this.options.colorScheme.length;
var slices = this.layout.slices;
var centerx = this.area.x + this.area.w * 0.5;
var centery = this.area.y + this.area.h * 0.5;
var radius = Math.min(this.area.w * this.options.pieRadius,
this.area.h * this.options.pieRadius);
// NOTE NOTE!! Canvas Tag draws the circle clockwise from the y = 0, x = 1
// so we have to subtract 90 degrees to make it start at y = 1, x = 0
// workaround if we only have 1 slice of 100%
if (slices.length == 1 && (Math.abs(slices[0].startAngle) - Math.abs(slices[0].endAngle) < 0.1)) {
var attrs = {"cx": centerx , "cy": centery , "r": radius };
var color = this.options.colorScheme[0];
if (this.options.shouldFill)
attrs["fill"] = color.toRGBString();
else
attrs["fill"] = "none";
if (this.options.shouldStroke &&
(this.options.strokeColor || this.options.strokeColorTransform)) {
if (this.options.strokeColor)
attrs["stroke"] = this.options.strokeColor.toRGBString();
else if (this.options.strokeColorTransform)
attrs["stroke"] = color[this.options.strokeColorTransform]().toRGBString();
attrs["style"] = "stroke-width: " + this.options.strokeWidth;
}
this.root.appendChild(this.createSVGElement("circle", attrs));
return;
}
for (var i = 0; i < slices.length; i++) {
var attrs = new Array();
var color = this.options.colorScheme[i%colorCount];
if (this.options.shouldFill)
attrs["fill"] = color.toRGBString();
else
attrs["fill"] = "none";
if (this.options.shouldStroke &&
(this.options.strokeColor || this.options.strokeColorTransform)) {
if (this.options.strokeColor)
attrs["stroke"] = this.options.strokeColor.toRGBString();
else if (this.options.strokeColorTransform)
attrs["stroke"] = color[this.options.strokeColorTransform]().toRGBString();
attrs["style"] = "stroke-width:" + this.options.strokeWidth;
}
var largearc = 0;
if (Math.abs(slices[i].endAngle - slices[i].startAngle) > Math.PI)
largearc = 1;
var x1 = Math.cos(slices[i].startAngle - Math.PI/2) * radius;
var y1 = Math.sin(slices[i].startAngle - Math.PI/2) * radius;
var x2 = Math.cos(slices[i].endAngle - Math.PI/2) * radius;
var y2 = Math.sin(slices[i].endAngle - Math.PI/2) * radius;
var rx = x2 - x1;
var ry = y2 - y1;
var pathString = "M" + centerx + "," + centery + " ";
pathString += "l" + x1 + "," + y1 + " ";
pathString += "a" + radius + "," + radius + " 0 " + largearc + ",1 " + rx + "," + ry + " z";
attrs["d"] = pathString;
var elem = this.createSVGElement("path", attrs);
this.root.appendChild(elem);
}
};
PlotKit.SVGRenderer.prototype._renderBarAxis = function() {
this._renderAxis();
}
PlotKit.SVGRenderer.prototype._renderLineAxis = function() {
this._renderAxis();
};
PlotKit.SVGRenderer.prototype._renderAxis = function() {
if (!this.options.drawXAxis && !this.options.drawYAxis)
return;
var labelStyle = {"style":
{"position": "absolute",
"textAlign": "center",
"fontSize": this.options.axisLabelFontSize + "px",
"zIndex": 10,
"color": this.options.axisLabelColor.toRGBString(),
"width": this.options.axisLabelWidth + "px",
"overflow": "hidden"
}
};
// axis lines
var lineAttrs = {
"stroke": this.options.axisLineColor.toRGBString(),
"strokeWidth": this.options.axisLineWidth
};
if (this.options.drawYAxis) {
if (this.layout.yticks) {
var drawTick = function(tick) {
var x = this.area.x;
var y = this.area.y + tick[0] * this.area.h;
this._drawLine(x, y, x - 3, y, lineAttrs);
if (this.options.axisLabelUseDiv) {
var label = DIV(labelStyle, tick[1]);
label.style.top = (y - this.options.axisLabelFontSize) + "px";
label.style.left = (x - this.options.padding.left + this.options.axisTickSize) + "px";
label.style.textAlign = "left";
label.style.width = (this.options.padding.left - 3) + "px";
MochiKit.DOM.appendChildNodes(this.container, label);
this.ylabels.push(label);
}
else {
var attrs = {
y: y + 3,
x: (x - this.options.padding.left + 3),
width: (this.options.padding.left - this.options.axisTickSize) + "px",
height: (this.options.axisLabelFontSize + 3) + "px",
fontFamily: "Arial",
fontSize: this.options.axisLabelFontSize + "px",
fill: this.options.axisLabelColor.toRGBString()
};
/* we can do clipping just like DIVs
http://www.xml.com/pub/a/2004/06/02/svgtype.html */
/*
var mask = this.createSVGElement("mask", {id: "mask" + tick[0]});
var maskShape = this.createSVGElement("rect",
{y: y + 3,
x: (x - this.options.padding.left + 3),
width: (this.options.padding.left - this.options.axisTickSize) + "px",
height: (this.options.axisLabelFontSize + 3) + "px",
style: {"fill": "#ffffff", "stroke": "#000000"}});
mask.appendChild(maskShape);
this.defs.appendChild(mask);
attrs["filter"] = "url(#mask" + tick[0] + ")";
*/
var label = this.createSVGElement("text", attrs);
label.appendChild(this.document.createTextNode(tick[1]));
this.root.appendChild(label);
}
};
MochiKit.Iter.forEach(this.layout.yticks, bind(drawTick, this));
}
this._drawLine(this.area.x, this.area.y, this.area.x, this.area.y + this.area.h, lineAttrs);
}
if (this.options.drawXAxis) {
if (this.layout.xticks) {
var drawTick = function(tick) {
var x = this.area.x + tick[0] * this.area.w;
var y = this.area.y + this.area.h;
this._drawLine(x, y, x, y + this.options.axisTickSize, lineAttrs);
if (this.options.axisLabelUseDiv) {
var label = DIV(labelStyle, tick[1]);
label.style.top = (y + this.options.axisTickSize) + "px";
label.style.left = (x - this.options.axisLabelWidth/2) + "px";
label.style.textAlign = "center";
label.style.width = this.options.axisLabelWidth + "px";
MochiKit.DOM.appendChildNodes(this.container, label);
this.xlabels.push(label);
}
else {
var attrs = {
y: (y + this.options.axisTickSize + this.options.axisLabelFontSize),
x: x - 3,
width: this.options.axisLabelWidth + "px",
height: (this.options.axisLabelFontSize + 3) + "px",
fontFamily: "Arial",
fontSize: this.options.axisLabelFontSize + "px",
fill: this.options.axisLabelColor.toRGBString(),
textAnchor: "middle"
};
var label = this.createSVGElement("text", attrs);
label.appendChild(this.document.createTextNode(tick[1]));
this.root.appendChild(label);
}
};
MochiKit.Iter.forEach(this.layout.xticks, bind(drawTick, this));
}
this._drawLine(this.area.x, this.area.y + this.area.h, this.area.x + this.area.w, this.area.y + this.area.h, lineAttrs)
}
};
PlotKit.SVGRenderer.prototype._renderPieAxis = function() {
if (this.layout.xticks) {
// make a lookup dict for x->slice values
var lookup = new Array();
for (var i = 0; i < this.layout.slices.length; i++) {
lookup[this.layout.slices[i].xval] = this.layout.slices[i];
}
var centerx = this.area.x + this.area.w * 0.5;
var centery = this.area.y + this.area.h * 0.5;
var radius = Math.min(this.area.w * this.options.pieRadius + 10,
this.area.h * this.options.pieRadius + 10);
var labelWidth = this.options.axisLabelWidth;
for (var i = 0; i < this.layout.xticks.length; i++) {
var slice = lookup[this.layout.xticks[i][0]];
if (MochiKit.Base.isUndefinedOrNull(slice))
continue;
var angle = (slice.startAngle + slice.endAngle)/2;
// normalize the angle
var normalisedAngle = angle;
if (normalisedAngle > Math.PI * 2)
normalisedAngle = normalisedAngle - Math.PI * 2;
else if (normalisedAngle < 0)
normalisedAngle = normalisedAngle + Math.PI * 2;
var labelx = centerx + Math.sin(normalisedAngle) * (radius + 10);
var labely = centery - Math.cos(normalisedAngle) * (radius + 10);
var attrib = {
"position": "absolute",
"zIndex": 11,
"width": labelWidth + "px",
"fontSize": this.options.axisLabelFontSize + "px",
"overflow": "hidden",
"color": this.options.axisLabelColor.toHexString()
};
var svgattrib = {
"width": labelWidth + "px",
"fontSize": this.options.axisLabelFontSize + "px",
"height": (this.options.axisLabelFontSize + 3) + "px",
"fill": this.options.axisLabelColor.toRGBString()
};
if (normalisedAngle <= Math.PI * 0.5) {
// text on top and align left
MochiKit.Base.update(attrib, {
'textAlign': 'left', 'verticalAlign': 'top',
'left': labelx + 'px',
'top': (labely - this.options.axisLabelFontSize) + "px"
});
MochiKit.Base.update(svgattrib, {
"x": labelx,
"y" :(labely - this.options.axisLabelFontSize),
"textAnchor": "left"
});
}
else if ((normalisedAngle > Math.PI * 0.5) && (normalisedAngle <= Math.PI)) {
// text on bottom and align left
MochiKit.Base.update(attrib, {
'textAlign': 'left', 'verticalAlign': 'bottom',
'left': labelx + 'px',
'top': labely + "px"
});
MochiKit.Base.update(svgattrib, {
'textAnchor': 'left',
'x': labelx,
'y': labely
});
}
else if ((normalisedAngle > Math.PI) && (normalisedAngle <= Math.PI*1.5)) {
// text on bottom and align right
MochiKit.Base.update(attrib, {
'textAlign': 'right', 'verticalAlign': 'bottom',
'left': labelx + 'px',
'top': labely + "px"
});
MochiKit.Base.update(svgattrib, {
'textAnchor': 'right',
'x': labelx - labelWidth,
'y': labely
});
}
else {
// text on top and align right
MochiKit.Base.update(attrib, {
'textAlign': 'left', 'verticalAlign': 'bottom',
'left': labelx + 'px',
'top': labely + "px"
});
MochiKit.Base.update(svgattrib, {
'textAnchor': 'left',
'x': labelx - labelWidth,
'y': labely - this.options.axisLabelFontSize
});
}
if (this.options.axisLabelUseDiv) {
var label = DIV({'style': attrib}, this.layout.xticks[i][1]);
this.xlabels.push(label);
MochiKit.DOM.appendChildNodes(this.container, label);
}
else {
var label = this.createSVGElement("text", svgattrib);
label.appendChild(this.document.createTextNode(this.layout.xticks[i][1]))
this.root.appendChild(label);
}
}
}
};
PlotKit.SVGRenderer.prototype._renderBackground = function() {
var opts = {"stroke": "none",
"fill": this.options.backgroundColor.toRGBString()
};
this._drawRect(0, 0, this.width, this.height, opts);
};
PlotKit.SVGRenderer.prototype._drawRect = function(x, y, w, h, moreattrs) {
var attrs = {x: x + "px", y: y + "px", width: w + "px", height: h + "px"};
if (moreattrs)
MochiKit.Base.update(attrs, moreattrs);
var elem = this.createSVGElement("rect", attrs);
this.root.appendChild(elem);
};
PlotKit.SVGRenderer.prototype._drawLine = function(x1, y1, x2, y2, moreattrs) {
var attrs = {x1: x1 + "px", y1: y1 + "px", x2: x2 + "px", y2: y2 + "px"};
if (moreattrs)
MochiKit.Base.update(attrs, moreattrs);
var elem = this.createSVGElement("line", attrs);
this.root.appendChild(elem);
}
PlotKit.SVGRenderer.prototype.clear = function() {
while(this.element.firstChild) {
this.element.removeChild(this.element.firstChild);
}
if (this.options.axisLabelUseDiv) {
for (var i = 0; i < this.xlabels.length; i++) {
MochiKit.DOM.removeElement(this.xlabels[i]);
}
for (var i = 0; i < this.ylabels.length; i++) {
MochiKit.DOM.removeElement(this.ylabels[i]);
}
}
this.xlabels = new Array();
this.ylabels = new Array();
};
PlotKit.SVGRenderer.prototype.createSVGElement = function(name, attrs) {
var isNil = MochiKit.Base.isUndefinedOrNull;
var elem;
var doc = isNil(this.document) ? document : this.document;
try {
elem = doc.createElementNS(PlotKit.SVGRenderer.SVGNS, name);
}
catch (e) {
elem = doc.createElement(name);
elem.setAttribute("xmlns", PlotKit.SVGRenderer.SVGNS);
}
if (attrs)
MochiKit.DOM.updateNodeAttributes(elem, attrs);
// TODO: we don't completely emulate the MochiKit.DOM.createElement
// as we don't care about nodes contained. We really should though.
return elem;
};
PlotKit.SVGRenderer.SVG = function(attrs) {
// we have to do things differently for IE+AdobeSVG.
// My guess this works (via trial and error) is that we need to
// have an SVG object in order to use SVGDocument.createElementNS
// but IE doesn't allow us to that.
var ie = navigator.appVersion.match(/MSIE (\d\.\d)/);
var opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
if (ie && (ie[1] >= 6) && (!opera)) {
var width = attrs["width"] ? attrs["width"] : "100";
var height = attrs["height"] ? attrs["height"] : "100";
var eid = attrs["id"] ? attrs["id"] : "notunique";
var html = '<svg:svg width="' + width + '" height="' + height + '" ';
html += 'id="' + eid + '" version="1.1" baseProfile="full" />';
var canvas = document.createElement(html);
// create embedded SVG inside SVG.
var group = canvas.getSVGDocument().createElementNS(PlotKit.SVGRenderer.SVGNS, "svg");
group.setAttribute("width", width);
group.setAttribute("height", height);
canvas.getSVGDocument().appendChild(group);
return canvas;
}
else {
return PlotKit.SVGRenderer.prototype.createSVGElement("svg", attrs);
}
};
PlotKit.SVGRenderer.isSupported = function() {
var isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
var ieVersion = navigator.appVersion.match(/MSIE (\d\.\d)/);
var safariVersion = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
var operaVersion = navigator.userAgent.match(/Opera\/(\d*\.\d*)/);
var mozillaVersion = navigator.userAgent.match(/rv:(\d*\.\d*).*Gecko/);
var svgFeature = "http://www.w3.org/TR/SVG11/feature#SVG";
if (ieVersion && (ieVersion[1] >= 6) && !isOpera) {
return document.implementation.hasFeature(svgFeature,"1.1");
/*
var dummysvg = document.createElement('<svg:svg width="1" height="1" baseProfile="full" version="1.1" id="dummy">');
try {
dummysvg.getSVGDocument();
dummysvg = null;
return true;
}
catch (e) {
return false;
}
*/
}
/* support not really there yet. no text and paths are buggy
if (safariVersion && (safariVersion[1] > 419))
return true;
*/
if (operaVersion && (operaVersion[1] > 8.9))
return true
if (mozillaVersion && (mozillaVersion > 1.7))
return true;
return false;
};
// Namespace Iniitialisation
PlotKit.SVG = {}
PlotKit.SVG.SVGRenderer = PlotKit.SVGRenderer;
PlotKit.SVG.EXPORT = [
"SVGRenderer"
];
PlotKit.SVG.EXPORT_OK = [
"SVGRenderer"
];
PlotKit.SVG.__new__ = function() {
var m = MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": m.concat(this.EXPORT, this.EXPORT_OK)
};
};
PlotKit.SVG.__new__();
MochiKit.Base._exportSymbols(this, PlotKit.SVG);
|