GlossyHorizontalGaugeMarker.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. define("dojox/gauges/GlossyHorizontalGaugeMarker", ["dojo/_base/declare","dojo/_base/Color","./BarLineIndicator"],
  2. function(declare, Color, BarLineIndicator) {
  3. /*=====
  4. BarLineIndicator = dojox.gauges.BarLineIndicator;
  5. =====*/
  6. return declare("dojox.gauges.GlossyHorizontalGaugeMarker", [BarLineIndicator], {
  7. // summary:
  8. // The marker for the dojox.gauges.GlossyHorizontalGauge.
  9. //
  10. // description:
  11. // This object defines the marker for the dojox.gauges.GlossyHorizontalGauge.
  12. // Since the needle is created by the gauges class, you do not have to use this class directly.
  13. // interactionMode : String
  14. // The interactionMode can have two values : "indicator" (the default) or "gauge".
  15. // When the value is "indicator", the user must click on the indicator to change the value.
  16. // When the value is "gauge", the user can click on the gauge to change the indicator value.
  17. // If a gauge contains several indicators with the indicatorMode property set to "gauge", then
  18. // only the first indicator will be moved when clicking the gauge.
  19. interactionMode: "gauge",
  20. // color: String
  21. // The color of the indicator.
  22. color: 'black',
  23. _getShapes: function(group){
  24. // summary:
  25. // Overrides BarLineIndicator._getShapes
  26. if (!this._gauge){
  27. return null;
  28. }
  29. var v = this.value;
  30. if (v < this._gauge.min){
  31. v = this._gauge.min;
  32. }
  33. if (v > this._gauge.max){
  34. v = this._gauge.max;
  35. }
  36. var pos = this._gauge._getPosition(v);
  37. var shapes = [];
  38. var color = new Color(this.color);
  39. color.a = .67;
  40. var lighterColor = Color.blendColors(color, new Color('white'), 0.4);
  41. var top = shapes[0] = group.createGroup();
  42. var scale = this._gauge.height / 100;
  43. scale = Math.max(scale, .5);
  44. scale = Math.min(scale, 1);
  45. top.setTransform({
  46. xx: 1,
  47. xy: 0,
  48. yx: 0,
  49. yy: 1,
  50. dx: pos,
  51. dy: 0
  52. });
  53. var marker = top.createGroup().setTransform({
  54. xx: 1,
  55. xy: 0,
  56. yx: 0,
  57. yy: 1,
  58. dx: -scale * 10,
  59. dy: this._gauge.dataY + this.offset
  60. });
  61. var rescale = marker.createGroup().setTransform({
  62. xx: scale,
  63. xy: 0,
  64. yx: 0,
  65. yy: scale,
  66. dx: 0,
  67. dy: 0
  68. });
  69. rescale.createRect({
  70. x: .5,
  71. y: .0,
  72. width: 20,
  73. height: 47,
  74. r: 6
  75. }).setFill(color).setStroke(lighterColor);
  76. rescale.createPath({
  77. path: 'M 10.106 41 L 10.106 6 C 10.106 2.687 7.419 0 4.106 0 L 0.372 0 C -0.738 6.567 1.022 15.113 1.022 23.917 C 1.022 32.721 2.022 40.667 0.372 47 L 4.106 47 C 7.419 47 10.106 44.314 10.106 41 Z'
  78. }).setFill(lighterColor).setTransform({
  79. xx: 1,
  80. xy: 0,
  81. yx: 0,
  82. yy: 1,
  83. dx: 10.306,
  84. dy: 0.009
  85. });
  86. rescale.createRect({
  87. x: 9.5,
  88. y: 1.5,
  89. width: 2,
  90. height: 34,
  91. r: 0.833717
  92. }).setFill(color).setStroke(this.color);
  93. rescale.createRect({
  94. x: 9,
  95. y: 0,
  96. width: 3,
  97. height: 34,
  98. r: 6
  99. }).setFill({
  100. type: "linear",
  101. x1: 9,
  102. y1: 0,
  103. x2: 9,
  104. y2: 34,
  105. colors: [{
  106. offset: 0,
  107. color: 'white'
  108. }, {
  109. offset: 1,
  110. color: this.color
  111. }]
  112. });
  113. return shapes;
  114. }
  115. });
  116. });