Changeset 13713
- Timestamp:
- 05/13/08 00:54:33 (6 months ago)
- Location:
- dojox/trunk/charting
- Files:
-
- 2 modified
-
axis2d/Default.js (modified) (5 diffs)
-
scaler/linear.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojox/trunk/charting/axis2d/Default.js
r13563 r13713 6 6 7 7 dojo.require("dojo.colors"); 8 dojo.require("dojo.string"); 8 9 dojo.require("dojox.gfx"); 9 10 dojo.require("dojox.lang.functional"); … … 34 35 }, 35 36 optionalParams: { 36 "min": 0, // minimal value on this axis 37 "max": 1, // maximal value on this axis 38 "majorTickStep": 4, // major tick step 39 "minorTickStep": 2, // minor tick step 40 "microTickStep": 1, // micro tick step 41 "labels": [], // array of labels for major ticks 42 // with corresponding numeric values 43 // ordered by values 37 min: 0, // minimal value on this axis 38 max: 1, // maximal value on this axis 39 from: 0, // visible from this value 40 to: 1, // visible to this value 41 majorTickStep: 4, // major tick step 42 minorTickStep: 2, // minor tick step 43 microTickStep: 1, // micro tick step 44 labels: [], // array of labels for major ticks 45 // with corresponding numeric values 46 // ordered by values 44 47 // theme components 45 "stroke": {}, // stroke for an axis46 "majorTick": {}, // stroke + length for a tick47 "minorTick": {}, // stroke + length for a tick48 "font": "", // font for labels49 "fontColor": ""// color for labels as a string48 stroke: {}, // stroke for an axis 49 majorTick: {}, // stroke + length for a tick 50 minorTick: {}, // stroke + length for a tick 51 font: "", // font for labels 52 fontColor: "" // color for labels as a string 50 53 }, 51 54 … … 70 73 if(this.initialized()){ return this; } 71 74 this.labels = "labels" in this.opt ? this.opt.labels : labels; 72 if("min" in this.opt){ min = this.opt.min; } 73 if("max" in this.opt){ max = this.opt.max; } 74 if(this.opt.includeZero){ 75 if(min > 0){ min = 0; } 76 if(max < 0){ max = 0; } 77 } 75 this.scaler = lin.buildScaler(min, max, span, this.opt); 78 76 var minMinorStep = 0, ta = this.chart.theme.axis, 79 77 taFont = "font" in this.opt ? this.opt.font : ta.font, … … 91 89 }), "Math.max(a, b)", 0); 92 90 }else{ 93 var labelLength = Math.ceil(Math.log(Math.max(Math.abs(min), Math.abs(max))) / Math.LN10), t = []; 94 if(min < 0 || max < 0){ t.push("-"); } 95 for(i = 0; i < labelLength; ++i){ t.push("9"); } 96 var precision = Math.floor(Math.log(max - min) / Math.LN10); 91 var labelLength = Math.ceil(Math.log(Math.max(Math.abs(this.scaler.min), 92 Math.abs(this.scaler.max))) / Math.LN10), 93 t = []; 94 if(this.scaler.min < 0 || this.scaler.max < 0){ t.push("-"); } 95 t.push(dojo.string.rep("9", labelLength)); 96 var precision = Math.floor(Math.log(this.scaler.max - this.scaler.min) / Math.LN10); 97 97 if(precision > 0){ 98 98 t.push("."); … … 104 104 } 105 105 } 106 this.scaler = lin.buildScaler(min, max, span, this.opt);107 106 this.scaler.minMinorStep = minMinorStep; 108 107 this.ticks = lin.buildTicks(this.scaler, this.opt); -
dojox/trunk/charting/scaler/linear.js
r13563 r13713 81 81 microPerMinor: microPerMinor, 82 82 scale: scale, 83 span: span 83 span: span, 84 min: min, 85 max: max 84 86 }; 85 87 }; … … 94 96 } 95 97 98 // update bounds, if needed 99 var includeZeroFlag = false; 100 if("from" in kwArgs){ 101 min = kwArgs.from; 102 h.fixLower = "none"; 103 h.natural = false; 104 }else{ 105 if("min" in kwArgs){ min = kwArgs.min; } 106 includeZeroFlag = true; 107 } 108 if("to" in kwArgs){ 109 max = kwArgs.from; 110 h.fixUpper = "none"; 111 h.natural = false; 112 }else{ 113 if("max" in kwArgs){ max = kwArgs.max; } 114 includeZeroFlag = true; 115 } 116 if(includeZeroFlag && kwArgs.includeZero){ 117 if(min > 0){ min = 0; } 118 if(max < 0){ max = 0; } 119 } 120 121 // check for erroneous condition 96 122 if(max <= min){ 97 123 return calcTicks(min, max, h, 0, 0, 0, span); // Object