aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/charting/plot2d/Columns.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/charting/plot2d/Columns.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/charting/plot2d/Columns.js')
-rw-r--r--includes/js/dojox/charting/plot2d/Columns.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/includes/js/dojox/charting/plot2d/Columns.js b/includes/js/dojox/charting/plot2d/Columns.js
new file mode 100644
index 0000000..ff97393
--- /dev/null
+++ b/includes/js/dojox/charting/plot2d/Columns.js
@@ -0,0 +1,88 @@
+if(!dojo._hasResource["dojox.charting.plot2d.Columns"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.charting.plot2d.Columns"] = true;
+dojo.provide("dojox.charting.plot2d.Columns");
+
+dojo.require("dojox.charting.plot2d.common");
+dojo.require("dojox.charting.plot2d.Base");
+
+dojo.require("dojox.lang.utils");
+dojo.require("dojox.lang.functional");
+dojo.require("dojox.lang.functional.reversed");
+
+(function(){
+ var df = dojox.lang.functional, du = dojox.lang.utils,
+ dc = dojox.charting.plot2d.common,
+ purgeGroup = df.lambda("item.purgeGroup()");
+
+ dojo.declare("dojox.charting.plot2d.Columns", dojox.charting.plot2d.Base, {
+ defaultParams: {
+ hAxis: "x", // use a horizontal axis named "x"
+ vAxis: "y", // use a vertical axis named "y"
+ gap: 0, // gap between columns in pixels
+ shadows: null // draw shadows
+ },
+ optionalParams: {}, // no optional parameters
+
+ constructor: function(chart, kwArgs){
+ this.opt = dojo.clone(this.defaultParams);
+ du.updateWithObject(this.opt, kwArgs);
+ this.series = [];
+ this.hAxis = this.opt.hAxis;
+ this.vAxis = this.opt.vAxis;
+ },
+
+ calculateAxes: function(dim){
+ var stats = dc.collectSimpleStats(this.series);
+ stats.hmin -= 0.5;
+ stats.hmax += 0.5;
+ this._calc(dim, stats);
+ return this;
+ },
+ render: function(dim, offsets){
+ if(this.dirty){
+ dojo.forEach(this.series, purgeGroup);
+ this.cleanGroup();
+ var s = this.group;
+ df.forEachRev(this.series, function(item){ item.cleanGroup(s); });
+ }
+ var t = this.chart.theme, color, stroke, fill, f,
+ gap = this.opt.gap < this._hScaler.scale / 3 ? this.opt.gap : 0;
+ for(var i = this.series.length - 1; i >= 0; --i){
+ var run = this.series[i];
+ if(!this.dirty && !run.dirty){ continue; }
+ run.cleanGroup();
+ var s = run.group;
+ if(!run.fill || !run.stroke){
+ // need autogenerated color
+ color = run.dyn.color = new dojo.Color(t.next("color"));
+ }
+ stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
+ fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
+ var baseline = Math.max(0, this._vScaler.bounds.lower),
+ xoff = offsets.l + this._hScaler.scale * (0.5 - this._hScaler.bounds.lower) + gap,
+ yoff = dim.height - offsets.b - this._vScaler.scale * (baseline - this._vScaler.bounds.lower);
+ for(var j = 0; j < run.data.length; ++j){
+ var v = run.data[j],
+ width = this._hScaler.scale - 2 * gap,
+ height = this._vScaler.scale * (v - baseline),
+ h = Math.abs(height);
+ if(width >= 1 && h >= 1){
+ var rect = {
+ x: xoff + this._hScaler.scale * j,
+ y: yoff - (height < 0 ? 0 : height),
+ width: width, height: h
+ },
+ shape = s.createRect(rect).setFill(fill).setStroke(stroke);
+ run.dyn.fill = shape.getFill();
+ run.dyn.stroke = shape.getStroke();
+ }
+ }
+ run.dirty = false;
+ }
+ this.dirty = false;
+ return this;
+ }
+ });
+})();
+
+}