]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/charting/plot2d/Grid.js
Comment class stub
[eow] / static / dojo-release-1.1.1 / dojox / charting / plot2d / Grid.js
1 if(!dojo._hasResource["dojox.charting.plot2d.Grid"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting.plot2d.Grid"] = true;
3 dojo.provide("dojox.charting.plot2d.Grid");
4
5 dojo.require("dojox.charting.Element");
6 dojo.require("dojox.charting.plot2d.common");
7 dojo.require("dojox.lang.functional");
8
9 (function(){
10         var du = dojox.lang.utils;
11
12         dojo.declare("dojox.charting.plot2d.Grid", dojox.charting.Element, {
13                 defaultParams: {
14                         hAxis: "x",                     // use a horizontal axis named "x"
15                         vAxis: "y",                     // use a vertical axis named "y"
16                         hMajorLines: true,      // draw horizontal major lines
17                         hMinorLines: false,     // draw horizontal minor lines
18                         vMajorLines: true,      // draw vertical major lines
19                         vMinorLines: false,     // draw vertical minor lines
20                         hStripes: "none",       // TBD
21                         vStripes: "none"        // TBD
22                 },
23                 optionalParams: {},     // no optional parameters
24                 
25                 constructor: function(chart, kwArgs){
26                         this.opt = dojo.clone(this.defaultParams);
27                         du.updateWithObject(this.opt, kwArgs);
28                         this.hAxis = this.opt.hAxis;
29                         this.vAxis = this.opt.vAxis;
30                 },
31                 clear: function(){
32                         this._hAxis = null;
33                         this._vAxis = null;
34                         this.dirty = true;
35                         return this;
36                 },
37                 setAxis: function(axis){
38                         if(axis){
39                                 this[axis.vertical ? "_vAxis" : "_hAxis"] = axis;
40                         }
41                         return this;
42                 },
43                 addSeries: function(run){
44                         // nothing
45                         return this;
46                 },
47                 calculateAxes: function(dim){
48                         // nothing
49                         return this;
50                 },
51                 getRequiredColors: function(){
52                         return 0;
53                 },
54                 render: function(dim, offsets){
55                         // draw horizontal stripes and lines
56                         if(!this.dirty){ return this; }
57                         this.cleanGroup();
58                         var s = this.group, ta = this.chart.theme.axis,
59                                 scaler = this._vAxis.getScaler();
60                         if(this.opt.hMinorLines && scaler.minor.tick){
61                                 for(var i = 0; i < scaler.minor.count; ++i){
62                                         var y = dim.height - offsets.b - scaler.scale * 
63                                                         (scaler.minor.start - scaler.bounds.lower + i * scaler.minor.tick);
64                                         s.createLine({
65                                                 x1: offsets.l,
66                                                 y1: y,
67                                                 x2: dim.width - offsets.r,
68                                                 y2: y
69                                         }).setStroke(ta.minorTick);
70                                 }
71                         }
72                         if(this.opt.hMajorLines && scaler.major.tick){
73                                 for(var i = 0; i < scaler.major.count; ++i){
74                                         var y = dim.height - offsets.b - scaler.scale * 
75                                                         (scaler.major.start - scaler.bounds.lower + i * scaler.major.tick);
76                                         s.createLine({
77                                                 x1: offsets.l,
78                                                 y1: y,
79                                                 x2: dim.width - offsets.r,
80                                                 y2: y
81                                         }).setStroke(ta.majorTick);
82                                 }
83                         }
84                         // draw vertical stripes and lines
85                         scaler = this._hAxis.getScaler();
86                         if(this.opt.vMinorLines && scaler.minor.tick){
87                                 for(var i = 0; i < scaler.minor.count; ++i){
88                                         var x = offsets.l + scaler.scale * 
89                                                         (scaler.minor.start - scaler.bounds.lower + i * scaler.minor.tick);
90                                         s.createLine({
91                                                 x1: x,
92                                                 y1: offsets.t,
93                                                 x2: x,
94                                                 y2: dim.height - offsets.b
95                                         }).setStroke(ta.minorTick);
96                                 }
97                         }
98                         if(this.opt.vMajorLines && scaler.major.tick){
99                                 for(var i = 0; i < scaler.major.count; ++i){
100                                         var x = offsets.l + scaler.scale * 
101                                                         (scaler.major.start - scaler.bounds.lower + i * scaler.major.tick);
102                                         s.createLine({
103                                                 x1: x,
104                                                 y1: offsets.t,
105                                                 x2: x,
106                                                 y2: dim.height - offsets.b
107                                         }).setStroke(ta.majorTick);
108                                 }
109                         }
110                         this.dirty = false;
111                         return this;
112                 }
113         });
114 })();
115
116 }