Fixes for Safari:

* Apple added Canvas for Dashboard (Tiger) and backported to Panther  
(as Safari 1.3), in the Mac world that's virtually everyone.  
Therefore, I added an explicit pass through for Safari because I  
can't find documentation for proper object detection. :(

* The correct usage of stroking is to define the start point  
(moveTo), followed by your other commands (lineTo, etc).[2]

* I back tested against FireFox 1.5 (OS X), don't have anything else  
handy at the moment. Sorry.

Corey
1. http://developer.apple.com/documentation/AppleApplications/ 
Reference/SafariJSRef/Classes/Canvas.html#//apple_ref/doc/uid/ 
30001240-53879
2. http://developer.apple.com/documentation/AppleApplications/ 
Reference/SafariJSRef/Classes/Canvas.html#//apple_ref/doc/uid/ 
30001240-54100


--- sparkline.js        2006-10-09 13:53:09.000000000 -0700
+++ sparkline.safari.js 2006-10-09 13:54:53.000000000 -0700
@@ -62,7 +62,7 @@
                 jQuery('#x_x_x').remove();
                 // Use a canvas element
-               if (options.useCanvas &&  
window.CanvasRenderingContext2D) {
+               if (options.useCanvas &&  
(window.CanvasRenderingContext2D || jQuery.browser.safari)) {
                         var id = '__' + (new Date).getTime();
                         w = options.width * data.length;
@@ -84,7 +84,12 @@
                                         c.beginPath();
                                         for (var i = 0; i <  
data.length; ++i) {
                                                 var v = Math.floor 
(((data[i] - min) / (max - min)) * h);
-                                               c.lineTo(w * i /  
(data.length - 1), h - v);
+
+                                               if (i == 0) {
+                                                 c.moveTo(w * i /  
(data.length - 1), h - v);
+                                               } else {
+                                                 c.lineTo(w * i /  
(data.length - 1), h - v);
+                                               }
                                         }
                                         c.stroke();
                                 }



On Oct 7, 2006, at 3:56 AM, Franck Marcia wrote:

> Hi all,
>
> I've released a new plugin: sparkline. A sparkline is an inline
> graphic (http://www.edwardtufte.com/bboard/q-and-a-fetch-msg? 
> msg_id=0001OR&topic_id=1).
>
> I borrowed the idea (and most of the code) from the TiddlyWiki
> project, a very good one-page wiki (http://www.tiddlywiki.com). Thanks
> to Jeremy Ruston for his work and his permission.
>
> Here is the link to the test page:
> http://fmarcia.info/jquery/sparkline/sparkline.html
>
> It's tested successfully on Windows XP with FF1.5.07, IE5.5, IE6,
> IE7RC1 and Opera 9.02. However, even if it works fine with FF on
> Linux, it doesn't behave correctly with Konqueror. I assume it's the
> same with Safari...
>
> As usual, any comment appreciated.
>
> Cheers,
>
> Franck.
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to