]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/charting/plot2d/ClusteredBars.js
Comment class stub
[eow] / static / dojo-release-1.1.1 / dojox / charting / plot2d / ClusteredBars.js
1 if(!dojo._hasResource["dojox.charting.plot2d.ClusteredBars"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting.plot2d.ClusteredBars"] = true;
3 dojo.provide("dojox.charting.plot2d.ClusteredBars");
4
5 dojo.require("dojox.charting.plot2d.common");
6 dojo.require("dojox.charting.plot2d.Bars");
7
8 dojo.require("dojox.lang.functional");
9 dojo.require("dojox.lang.functional.reversed");
10
11 (function(){
12         var df = dojox.lang.functional, dc = dojox.charting.plot2d.common,
13                 purgeGroup = df.lambda("item.purgeGroup()");
14
15         dojo.declare("dojox.charting.plot2d.ClusteredBars", dojox.charting.plot2d.Bars, {
16                 render: function(dim, offsets){
17                         if(this.dirty){
18                                 dojo.forEach(this.series, purgeGroup);
19                                 this.cleanGroup();
20                                 var s = this.group;
21                                 df.forEachRev(this.series, function(item){ item.cleanGroup(s); });
22                         }
23                         var t = this.chart.theme, color, stroke, fill, f,
24                                 gap = this.opt.gap < this._vScaler.scale / 3 ? this.opt.gap : 0,
25                                 thickness = (this._vScaler.scale - 2 * gap) / this.series.length;
26                         for(var i = this.series.length - 1; i >= 0; --i){
27                                 var run = this.series[i];
28                                 if(!this.dirty && !run.dirty){ continue; }
29                                 run.cleanGroup();
30                                 var s = run.group;
31                                 if(!run.fill || !run.stroke){
32                                         // need autogenerated color
33                                         color = run.dyn.color = new dojo.Color(t.next("color"));
34                                 }
35                                 stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
36                                 fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
37                                 var baseline = Math.max(0, this._hScaler.bounds.lower),
38                                         xoff = offsets.l + this._hScaler.scale * (baseline - this._hScaler.bounds.lower),
39                                         yoff = dim.height - offsets.b - this._vScaler.scale * (1.5 - this._vScaler.bounds.lower) + 
40                                                 gap + thickness * (this.series.length - i - 1);
41                                 for(var j = 0; j < run.data.length; ++j){
42                                         var v = run.data[j],
43                                                 width  = this._hScaler.scale * (v - baseline),
44                                                 height = thickness, w = Math.abs(width);
45                                         if(w >= 1 && height >= 1){
46                                                 var shape = s.createRect({
47                                                         x: xoff + (width < 0 ? width : 0),
48                                                         y: yoff - this._vScaler.scale * j,
49                                                         width: w, height: height
50                                                 }).setFill(fill).setStroke(stroke);
51                                                 run.dyn.fill   = shape.getFill();
52                                                 run.dyn.stroke = shape.getStroke();
53                                         }
54                                 }
55                                 run.dirty = false;
56                         }
57                         this.dirty = false;
58                         return this;
59                 }
60         });
61 })();
62
63 }