Browse files

Use Donatello.Color.parse instead of Raphael.getRGB.

* This way we can always depend on calling the hex() function.
  • Loading branch information...
1 parent c8b1ddc commit e182c9c3d57f4f9f58b31dbd8422773c772a2a5c @postmodern committed Aug 12, 2010
Showing with 14 additions and 14 deletions.
  1. +8 −8 donatello.js
  2. +6 −6 donatello.min.js
View
16 donatello.js
@@ -266,13 +266,13 @@ Donatello.BarGraph = function(data,options) {
this.bar.gradient = new Donatello.Gradient(
angle,
- Raphael.getRGB(this.bar.gradient[0]),
- Raphael.getRGB(this.bar.gradient[1])
+ Donatello.Color.parse(this.bar.gradient[0]),
+ Donatello.Color.parse(this.bar.gradient[1])
);
}
else
{
- this.bar.color = Raphael.getRGB(this.bar.color || Donatello.defaultColor);
+ this.bar.color = Donatello.Color.parse(this.bar.color || Donatello.defaultColor);
}
if (this.type == null)
@@ -397,7 +397,7 @@ Donatello.BarGraph.prototype.addBar = function(i,value,options) {
}
else
{
- c = Raphael.getRGB(this.bar.color);
+ c = this.bar.color;
}
var new_bar = new Donatello.BarGraph.Bar(this, i, value, this.paper, x, y, w, h, c.hex());
@@ -764,15 +764,15 @@ Donatello.PieChart = function(data,options) {
if (this.piechart.colors)
{
this.piechart.colors = new Donatello.ColorRange(
- Raphael.getRGB(this.piechart.colors[0]),
- Raphael.getRGB(this.piechart.colors[1])
+ Donatello.Color.parse(this.piechart.colors[0]),
+ Donatello.Color.parse(this.piechart.colors[1])
);
}
else
{
this.piechart.colors = new Donatello.ColorRange(
- Raphael.getRGB('#f00000'),
- Raphael.getRGB('#050000')
+ Donatello.Color.parse('#f00000'),
+ Donatello.Color.parse('#050000')
);
}
View
12 donatello.min.js
@@ -1,5 +1,5 @@
-var Donatello={defaultColor:'blue'};Donatello.Color=function(r,g,b){this.r=r;this.g=g;this.b=b;};Donatello.Color.hex=function(r,g,b){function toHex(i)
+var Donatello={defaultColor:'blue'};Donatello.Color=function(r,g,b){this.r=r;this.g=g;this.b=b;};Donatello.Color.parse=function(color){var raphael_color=Raphael.getRGB(color);return new Donatello.Color(raphael_color.r,raphael_color.g,raphael_color.b);};Donatello.Color.hex=function(r,g,b){function toHex(i)
{var h=i.toString(16);if(i<16)
{h='0'+h;}
return h;}
@@ -28,9 +28,9 @@ if(this.bar.gradient)
{angle=90;}
else if(this.type=='horizontal')
{angle=0;}
-this.bar.gradient=new Donatello.Gradient(angle,Raphael.getRGB(this.bar.gradient[0]),Raphael.getRGB(this.bar.gradient[1]));}
+this.bar.gradient=new Donatello.Gradient(angle,Donatello.Color.parse(this.bar.gradient[0]),Donatello.Color.parse(this.bar.gradient[1]));}
else
-{this.bar.color=Raphael.getRGB(this.bar.color||Donatello.defaultColor);}
+{this.bar.color=Donatello.Color.parse(this.bar.color||Donatello.defaultColor);}
if(this.type==null)
{throw"Must specify the 'type' option";}
else if(this.type=='vertical')
@@ -72,7 +72,7 @@ else if(this.type=='horizontal')
var c;if(this.bar.gradient)
{c=this.bar.gradient.scale(ratio);}
else
-{c=Raphael.getRGB(this.bar.color);}
+{c=this.bar.color;}
var new_bar=new Donatello.BarGraph.Bar(this,i,value,this.paper,x,y,w,h,c.hex());this.elements.push(new_bar);return new_bar;};Donatello.BarGraph.Bar=function(graph,index,value,paper,x,y,width,height,color){Donatello.Element.call(this,graph,value);this.index=index;this.node=paper.rect(x,y,width,height);this.setColor(color);};Donatello.BarGraph.Bar.prototype=new Donatello.Element();Donatello.BarGraph.Bar.constructor=Donatello.BarGraph.Bar;Donatello.BarGraph.Bar.prototype.x=Donatello.Element.node_attr('x');Donatello.BarGraph.Bar.prototype.y=Donatello.Element.node_attr('y');Donatello.BarGraph.Bar.prototype.width=Donatello.Element.node_attr('width');Donatello.BarGraph.Bar.prototype.height=Donatello.Element.node_attr('height');Donatello.LineGraph=function(data,options){Donatello.Graph.call(this);if(options==null)
{options={};}
this.width=options.width;this.height=options.height;if(!(this.width))
@@ -142,9 +142,9 @@ if(this.piechart.y==null)
if(this.piechart.radius==null)
{this.piechart.radius=((this.width-this.piechart.x)/2);}
if(this.piechart.colors)
-{this.piechart.colors=new Donatello.ColorRange(Raphael.getRGB(this.piechart.colors[0]),Raphael.getRGB(this.piechart.colors[1]));}
+{this.piechart.colors=new Donatello.ColorRange(Donatello.Color.parse(this.piechart.colors[0]),Donatello.Color.parse(this.piechart.colors[1]));}
else
-{this.piechart.colors=new Donatello.ColorRange(Raphael.getRGB('#f00000'),Raphael.getRGB('#050000'));}
+{this.piechart.colors=new Donatello.ColorRange(Donatello.Color.parse('#f00000'),Donatello.Color.parse('#050000'));}
var sorted_data=data.sort(function(value1,value2){return value1-value2;});this.min=sorted_data[0];this.max=sorted_data[sorted_data.length-1];this.sum=0;for(var i=0;i<sorted_data.length;i++)
{this.sum+=sorted_data[i];}
this.init(options);this.node=this.paper.circle(this.piechart.x,this.piechart.y,this.piechart.radius);var start_angle=0;for(var i=0;i<sorted_data.length;i++)

0 comments on commit e182c9c

Please sign in to comment.