| 1 | define(["dojo/_base/declare", "dojox/dgauges/RectangularGauge", "dojox/dgauges/LinearScaler", |
| 2 | "dojox/dgauges/RectangularScale", "dojox/dgauges/RectangularValueIndicator", |
| 3 | "dojox/dgauges/RectangularRangeIndicator", "dojox/color"], |
| 4 | function(declare, RectangularGauge, LinearScaler, RectangularScale, RectangularValueIndicator, |
| 5 | RectangularRangeIndicator, color){ |
| 6 | return declare("dojox.dgauges.tests.gauges.BulletGraph", RectangularGauge, { |
| 7 | target: 50, |
| 8 | high: 100, |
| 9 | value: 50, |
| 10 | medium: 75, |
| 11 | low: 50, |
| 12 | |
| 13 | constructor: function(){ |
| 14 | var scaler = new LinearScaler({ |
| 15 | maximum: this.high |
| 16 | }); |
| 17 | this._scale = new RectangularScale({ |
| 18 | scaler: scaler, |
| 19 | labelPosition: "trailing", |
| 20 | paddingTop: 30, |
| 21 | paddingBottom: 23 |
| 22 | }); |
| 23 | this.addElement("scale", this._scale); |
| 24 | |
| 25 | var high = new RectangularRangeIndicator({ |
| 26 | start: 0, |
| 27 | value: this.high, |
| 28 | interactionMode: "none", |
| 29 | fill: color.fromHsv(0, 0, 90), |
| 30 | stroke: null, |
| 31 | paddingTop: 0, |
| 32 | startThickness: 30, |
| 33 | endThickness: 30 |
| 34 | }); |
| 35 | this._scale.addIndicator("high", high); |
| 36 | |
| 37 | var medium = new RectangularRangeIndicator({ |
| 38 | start: 0, |
| 39 | value: this.medium, |
| 40 | interactionMode: "none", |
| 41 | fill: color.fromHsv(0, 0, 60), |
| 42 | stroke: null, |
| 43 | paddingTop: 0, |
| 44 | startThickness: 30, |
| 45 | endThickness: 30 |
| 46 | }); |
| 47 | this._scale.addIndicator("medium", medium); |
| 48 | |
| 49 | var low = new RectangularRangeIndicator({ |
| 50 | start: 0, |
| 51 | value: this.low, |
| 52 | interactionMode: "none", |
| 53 | fill: color.fromHsv(0, 0, 40), |
| 54 | stroke: null, |
| 55 | paddingTop: 0, |
| 56 | startThickness: 30, |
| 57 | endThickness: 30 |
| 58 | }); |
| 59 | this._scale.addIndicator("low", low); |
| 60 | |
| 61 | var measure = new RectangularRangeIndicator({ |
| 62 | start: 0, |
| 63 | value: this.value, |
| 64 | interactionMode: "none", |
| 65 | fill: [0, 0, 0], |
| 66 | stroke: null, |
| 67 | paddingTop: 10, |
| 68 | startThickness: 10, |
| 69 | endThickness: 10 |
| 70 | }); |
| 71 | this._scale.addIndicator("measure", measure); |
| 72 | |
| 73 | var target = new RectangularValueIndicator({ |
| 74 | paddingTop: 7, |
| 75 | interactionMode: "none", |
| 76 | value: this.target |
| 77 | }); |
| 78 | |
| 79 | target.indicatorShapeFunc = function(group){ |
| 80 | return group.createLine({ |
| 81 | x1: 0, |
| 82 | y1: 0, |
| 83 | x2: 0, |
| 84 | y2: 16 |
| 85 | }).setStroke({ |
| 86 | color: "black", |
| 87 | width: 3 |
| 88 | }).setFill([250, 0, 0]); |
| 89 | }; |
| 90 | |
| 91 | this._scale.addIndicator("target", target); |
| 92 | |
| 93 | this.addInvalidatingProperties(["target", "value", "low", "medium", "high"]); |
| 94 | }, |
| 95 | |
| 96 | refreshRendering: function(){ |
| 97 | this.inherited(arguments); |
| 98 | |
| 99 | this._scale.scaler.set("maximum", this.high); |
| 100 | this._scale.getIndicator("target").set("value", this.target); |
| 101 | this._scale.getIndicator("measure").set("value", this.value); |
| 102 | this._scale.getIndicator("low").set("value", this.low); |
| 103 | this._scale.getIndicator("medium").set("value", this.medium); |
| 104 | this._scale.getIndicator("high").set("value", this.high); |
| 105 | } |
| 106 | }); |
| 107 | }); |