Changeset 18
- Timestamp:
- 01/05/06 00:33:11 (2 years ago)
- Files:
-
- plotkit/trunk/PlotKit/Base.js (modified) (2 diffs)
- plotkit/trunk/PlotKit/Canvas.js (modified) (4 diffs)
- plotkit/trunk/PlotKit/excanvas.js (added)
- plotkit/trunk/PlotKit/iecanvas.htc (deleted)
- plotkit/trunk/doc/SVGCanvasCompat.html (modified) (3 diffs)
- plotkit/trunk/doc/SVGCanvasCompat.txt (modified) (3 diffs)
- plotkit/trunk/tests/basic.html (modified) (1 diff)
- plotkit/trunk/tests/basic.js (modified) (1 diff)
- plotkit/trunk/tests/sweet.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plotkit/trunk/PlotKit/Base.js
r12 r18 179 179 }, 180 180 181 182 183 184 // The follow functions are from quirksmode.org 181 excanvasSupported: function() { 182 if (/MSIE/.test(navigator.userAgent) && !window.opera) { 183 return true; 184 } 185 return false; 186 }, 187 188 // The following functions are from quirksmode.org 185 189 // http://www.quirksmode.org/js/findpos.html 186 190 … … 313 317 "roundInterval", 314 318 "uniq", 319 "excanvasSupported" 315 320 ]; 316 321 plotkit/trunk/PlotKit/Canvas.js
r12 r18 11 11 12 12 It uses DIVs for labels. 13 14 Notes About IE Support15 ----------------------16 17 This class relies on iecanvas.htc for Canvas Emulation under IE[1].18 iecanvas.htc is included in the distribution of PlotKit for convenience. In order to enable IE support, you must set the following option when initialising the renderer:19 20 var renderOptions = {21 "IECanvasHTC": "contrib/iecanvas.htc"22 };23 var engine = new CanvasRenderer(canvasElement, layout, renderOptions);24 25 Where "contrib/iecanvas.htc" is the path to the htc behavior relative26 to where your HTML is.27 28 This is only needed for IE support.29 13 30 14 Copyright … … 98 82 "axisLabelWidth": 50, 99 83 "pieRadius": 0.4, 100 "enableEvents": true, 101 "IECanvasHTC": "PlotKit/iecanvas.htc" 84 "enableEvents": true 102 85 }; 103 86 MochiKit.Base.update(this.options, options ? options : {}); 104 87 105 // we need to refetch the element because of this horrible Canvas on IE106 // crap107 this.element_id = element.id ? element.id : element;108 109 // Stuff relating to Canvas on IE support110 var self = PlotKit.CanvasRenderer;111 this.isIE = self.IECanvasEmulationIfNeeded(this.options.IECanvasHTC);112 this.IEDelay = 0.5;113 this.maxTries = 5;114 this.renderDelay = null;115 this.clearDelay = null;116 117 88 this.layout = layout; 118 89 this.style = layout.style; 119 this.element = MochiKit.DOM.getElement(this.element_id); 120 //this.element = element; 90 this.element = element; 121 91 this.container = this.element.parentNode; 92 93 // Stuff relating to Canvas on IE support 94 this.isIE = PlotKit.Base.excanvasSupported(); 95 96 if (this.isIE) { 97 this.IEDelay = 0.5; 98 this.maxTries = 5; 99 this.renderDelay = null; 100 this.clearDelay = null; 101 this.element = G_vmlCanvasManager.initElement(this.element); 102 } 103 122 104 this.height = this.element.height; 123 105 this.width = this.element.width; … … 159 141 // still experimental 160 142 } 161 };162 163 PlotKit.CanvasRenderer.IECanvasEmulationIfNeeded = function(htc) {164 var ie = navigator.appVersion.match(/MSIE (\d\.\d)/);165 var opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);166 if ((!ie) || (ie[1] < 6) || (opera))167 return false;168 169 if (isUndefinedOrNull(MochiKit.DOM.getElement('VMLRender'))) {170 // before we add VMLRender, we need to recreate all canvas tags171 // programmatically otherwise IE will not recognise it172 173 var nodes = document.getElementsByTagName('canvas');174 for (var i = 0; i < nodes.length; i++) {175 var node = nodes[i];176 if (node.getContext) { return; } // Other implementation, abort177 var newNode = MochiKit.DOM.CANVAS(178 {id: node.id,179 width: "" + parseInt(node.width),180 height: "" + parseInt(node.height)}, "");181 newNode.style.width = parseInt(node.width) + "px";182 newNode.style.height = parseInt(node.height) + "px";183 node.id = node.id + "_old";184 MochiKit.DOM.swapDOM(node, newNode);185 }186 187 document.namespaces.add("v");188 var vmlopts = {'id':'VMLRender',189 'codebase':'vgx.dll',190 'classid':'CLSID:10072CEC-8CC1-11D1-986E-00A0C955B42E'};191 var vml = MochiKit.DOM.createDOM('object', vmlopts);192 document.body.appendChild(vml);193 var vmlStyle = document.createStyleSheet();194 vmlStyle.addRule("canvas", "behavior: url('" + htc + "');");195 vmlStyle.addRule("v\\:*", "behavior: url(#VMLRender);");196 }197 return true;198 143 }; 199 144 … … 594 539 context.clearRect(0, 0, this.width, this.height); 595 540 596 597 for (var i = 0; i < this.xlabels.length; i++) { 598 MochiKit.DOM.removeElement(this.xlabels[i]); 599 } 600 for (var i = 0; i < this.ylabels.length; i++) { 601 MochiKit.DOM.removeElement(this.ylabels[i]); 602 } 541 MochiKit.Iter.forEach(this.xlabels, MochiKit.DOM.removeElement); 542 MochiKit.Iter.forEach(this.ylabels, MochiKit.DOM.removeElement); 603 543 this.xlabels = new Array(); 604 544 this.ylabels = new Array(); 605 606 }; 545 }; 546 547 // ---------------------------------------------------------------- 548 // Everything below here is experimental and undocumented. 549 // ---------------------------------------------------------------- 607 550 608 551 PlotKit.CanvasRenderer.prototype._initialiseEvents = function() { plotkit/trunk/doc/SVGCanvasCompat.html
r16 r18 36 36 37 37 <h1> State of SVG and Canvas in Modern Browsers</h1> 38 <p> <strong>By: Alastair Tse - Last Updated: 15 March2006</strong>38 <p> <strong>By: Alastair Tse - Last Updated: 27 April 2006</strong> 39 39 </p> 40 40 <p>My friends, just like HTML and CSS, different browsers support … … 106 106 <h2> Quirks</h2> 107 107 <ul> 108 <li> 109 <strong>Safari</strong> will forget a path after <code>fill()</code> or <code>stroke()</code> has 110 been called. Therefore, if you need to fill and stroke the same 111 path, you must draw the path out twice. 112 </li> 113 </ul> 114 <p> path, you must draw the path out twice. 115 </p> 116 <ul> 108 <li><p> <strong>Safari</strong> will forget a path after <code>fill()</code> or <code>stroke()</code> has 109 been called. Therefore, if you need to fill and stroke the same 110 path, you must draw the path out twice. 111 </p> 112 113 </li> 114 117 115 <li><p> <strong>Opera</strong> will not obey <code>stroke()</code> for arc paths. 118 116 </p> … … 203 201 204 202 <li><p> <strong>Opera 9</strong> will refuse to draw an element if attribute <code>filter</code> 205 is defined. 206 </p> 207 208 </li> 209 210 <li><p> <strong>Internet Explorer 7b2p + ASV</strong> will not work with the Adobe SVG 211 Viewer. 212 </p> 213 214 </li> 215 </ul> 216 <p> Viewer. 217 </p> 203 is defined. 204 </p> 205 206 </li> 207 </ul> 208 <p> is defined. 209 </p> 210 <ul> 211 <li> 212 <strong>Internet Explorer 7b2p + ASV</strong> will not work with the Adobe SVG Viewer. 213 </li> 214 </ul> 218 215 219 216 <h1> Disclaimer</h1> plotkit/trunk/doc/SVGCanvasCompat.txt
r16 r18 14 14 ========================================== 15 15 16 __By: Alastair Tse - Last Updated: 15 March2006__16 __By: Alastair Tse - Last Updated: 27 April 2006__ 17 17 18 18 … … 66 66 67 67 * __Safari__ will forget a path after ``fill()`` or ``stroke()`` has 68 been called. Therefore, if you need to fill and stroke the same69 path, you must draw the path out twice.68 been called. Therefore, if you need to fill and stroke the same 69 path, you must draw the path out twice. 70 70 71 71 * __Opera__ will not obey ``stroke()`` for arc paths. … … 120 120 121 121 * __Opera 9__ will refuse to draw an element if attribute ``filter`` 122 is defined.122 is defined. 123 123 124 * __Internet Explorer 7b2p + ASV__ will not work with the Adobe SVG 125 Viewer. 124 * __Internet Explorer 7b2p + ASV__ will not work with the Adobe SVG Viewer. 126 125 127 126 plotkit/trunk/tests/basic.html
r16 r18 9 9 type="text/css" /> 10 10 <script src="/js/mochi/MochiKit.js" type="text/javascript"></script> 11 <script src="/js/plotkit/Base.js" type="text/javascript"></script> 12 <script src="/js/plotkit/Layout.js" type="text/javascript"></script> 13 <script src="/js/plotkit/Canvas.js" type="text/javascript"></script> 11 <script src="/js/plotkit-svn/excanvas.js" type="text/javascript"></script> 12 <script src="/js/plotkit-svn/Base.js" type="text/javascript"></script> 13 <script src="/js/plotkit-svn/Layout.js" type="text/javascript"></script> 14 <script src="/js/plotkit-svn/Canvas.js" type="text/javascript"></script> 14 15 <script src="/js/plotkit-tests/basic.js" type="text/javascript"></script> 16 15 17 </head> 16 18 plotkit/trunk/tests/basic.js
r7 r18 94 94 tests.appendChild(generateUnitTest(1, genericTest, simpleData1, 95 95 "bar", "")); 96 96 97 tests.appendChild(generateUnitTest(2, genericTest, simpleData1, 97 98 "line", "")); plotkit/trunk/tests/sweet.html
r7 r18 8 8 <link href="tests.css" media="screen" rel="Stylesheet" type="text/css" /> 9 9 <script src="/js/mochi/MochiKit.js" type="text/javascript"></script> 10 <script src="/js/plotkit/Base.js" type="text/javascript"></script> 11 <script src="/js/plotkit/Layout.js" type="text/javascript"></script> 12 <script src="/js/plotkit/Canvas.js" type="text/javascript"></script> 13 <script src="/js/plotkit/SweetCanvas.js" type="text/javascript"></script> 10 <script src="/js/plotkit-svn/excanvas.js" type="text/javascript"></script> 11 <script src="/js/plotkit-svn/Base.js" type="text/javascript"></script> 12 <script src="/js/plotkit-svn/Layout.js" type="text/javascript"></script> 13 <script src="/js/plotkit-svn/Canvas.js" type="text/javascript"></script> 14 <script src="/js/plotkit-svn/SweetCanvas.js" type="text/javascript"></script> 14 15 <script src="/js/plotkit-tests/sweet.js" type="text/javascript"></script> 15 16 </head>




Atom Feed for the Blog Entries