Location: A review of cardiac cellular electrophysiology models @ 1c3a018574af / dojo-presentation / js / dojo / dojox / charting / plot2d / Grid.js

Author:
David Nickerson <david.nickerson@gmail.com>
Date:
2023-04-27 23:14:49-07:00
Desc:
Updates to get things working with OpenCOR 0.7.1
Permanent Source URI:
http://models.cellml.org/workspace/a1/rawfile/1c3a018574af68610e2b95973f32fa831ea3096f/dojo-presentation/js/dojo/dojox/charting/plot2d/Grid.js

dojo.provide("dojox.charting.plot2d.Grid");

dojo.require("dojox.charting.Element");
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.lang.functional");

(function(){
	var du = dojox.lang.utils;

	dojo.declare("dojox.charting.plot2d.Grid", dojox.charting.Element, {
		defaultParams: {
			hAxis: "x",			// use a horizontal axis named "x"
			vAxis: "y",			// use a vertical axis named "y"
			hMajorLines: true,	// draw horizontal major lines
			hMinorLines: false,	// draw horizontal minor lines
			vMajorLines: true,	// draw vertical major lines
			vMinorLines: false,	// draw vertical minor lines
			hStripes: "none",	// TBD
			vStripes: "none"	// TBD
		},
		optionalParams: {},	// no optional parameters
		
		constructor: function(chart, kwArgs){
			this.opt = dojo.clone(this.defaultParams);
			du.updateWithObject(this.opt, kwArgs);
			this.hAxis = this.opt.hAxis;
			this.vAxis = this.opt.vAxis;
			this.dirty = true;
		},
		clear: function(){
			this._hAxis = null;
			this._vAxis = null;
			this.dirty = true;
			return this;
		},
		setAxis: function(axis){
			if(axis){
				this[axis.vertical ? "_vAxis" : "_hAxis"] = axis;
			}
			return this;
		},
		addSeries: function(run){
			// nothing
			return this;
		},
		calculateAxes: function(dim){
			// nothing
			return this;
		},
		isDirty: function(){
			return this.dirty || this._hAxis && this._hAxis.dirty || this._vAxis && this._vAxis.dirty;
		},
		getRequiredColors: function(){
			return 0;
		},
		render: function(dim, offsets){
			// draw horizontal stripes and lines
			this.dirty = this.isDirty();
			if(!this.dirty){ return this; }
			this.cleanGroup();
			var s = this.group, ta = this.chart.theme.axis, ticks = this._vAxis.getTicks(),
				hScaler = this._hAxis.getScaler(), vScaler = this._vAxis.getScaler(),
				ht = hScaler.scaler.getTransformerFromModel(hScaler),
				vt = vScaler.scaler.getTransformerFromModel(vScaler);
			if(this.opt.hMinorLines){
				dojo.forEach(ticks.minor, function(tick){
					var y = dim.height - offsets.b - vt(tick.value);
					s.createLine({
						x1: offsets.l,
						y1: y,
						x2: dim.width - offsets.r,
						y2: y
					}).setStroke(ta.minorTick);
				});
			}
			if(this.opt.hMajorLines){
				dojo.forEach(ticks.major, function(tick){
					var y = dim.height - offsets.b - vt(tick.value);
					s.createLine({
						x1: offsets.l,
						y1: y,
						x2: dim.width - offsets.r,
						y2: y
					}).setStroke(ta.majorTick);
				});
			}
			// draw vertical stripes and lines
			ticks = this._hAxis.getTicks();
			if(this.opt.vMinorLines){
				dojo.forEach(ticks.minor, function(tick){
					var x = offsets.l + ht(tick.value);
					s.createLine({
						x1: x,
						y1: offsets.t,
						x2: x,
						y2: dim.height - offsets.b
					}).setStroke(ta.minorTick);
				});
			}
			if(this.opt.vMajorLines){
				dojo.forEach(ticks.major, function(tick){
					var x = offsets.l + ht(tick.value);
					s.createLine({
						x1: x,
						y1: offsets.t,
						x2: x,
						y2: dim.height - offsets.b
					}).setStroke(ta.majorTick);
				});
			}
			this.dirty = false;
			return this;
		}
	});
})();