SingleAxis.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. var zrUtil = require("zrender/lib/core/util");
  20. var Axis = require("../Axis");
  21. /*
  22. * Licensed to the Apache Software Foundation (ASF) under one
  23. * or more contributor license agreements. See the NOTICE file
  24. * distributed with this work for additional information
  25. * regarding copyright ownership. The ASF licenses this file
  26. * to you under the Apache License, Version 2.0 (the
  27. * "License"); you may not use this file except in compliance
  28. * with the License. You may obtain a copy of the License at
  29. *
  30. * http://www.apache.org/licenses/LICENSE-2.0
  31. *
  32. * Unless required by applicable law or agreed to in writing,
  33. * software distributed under the License is distributed on an
  34. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35. * KIND, either express or implied. See the License for the
  36. * specific language governing permissions and limitations
  37. * under the License.
  38. */
  39. /**
  40. * @constructor module:echarts/coord/single/SingleAxis
  41. * @extends {module:echarts/coord/Axis}
  42. * @param {string} dim
  43. * @param {*} scale
  44. * @param {Array.<number>} coordExtent
  45. * @param {string} axisType
  46. * @param {string} position
  47. */
  48. var SingleAxis = function (dim, scale, coordExtent, axisType, position) {
  49. Axis.call(this, dim, scale, coordExtent);
  50. /**
  51. * Axis type
  52. * - 'category'
  53. * - 'value'
  54. * - 'time'
  55. * - 'log'
  56. * @type {string}
  57. */
  58. this.type = axisType || 'value';
  59. /**
  60. * Axis position
  61. * - 'top'
  62. * - 'bottom'
  63. * - 'left'
  64. * - 'right'
  65. * @type {string}
  66. */
  67. this.position = position || 'bottom';
  68. /**
  69. * Axis orient
  70. * - 'horizontal'
  71. * - 'vertical'
  72. * @type {[type]}
  73. */
  74. this.orient = null;
  75. };
  76. SingleAxis.prototype = {
  77. constructor: SingleAxis,
  78. /**
  79. * Axis model
  80. * @type {module:echarts/coord/single/AxisModel}
  81. */
  82. model: null,
  83. /**
  84. * Judge the orient of the axis.
  85. * @return {boolean}
  86. */
  87. isHorizontal: function () {
  88. var position = this.position;
  89. return position === 'top' || position === 'bottom';
  90. },
  91. /**
  92. * @override
  93. */
  94. pointToData: function (point, clamp) {
  95. return this.coordinateSystem.pointToData(point, clamp)[0];
  96. },
  97. /**
  98. * Convert the local coord(processed by dataToCoord())
  99. * to global coord(concrete pixel coord).
  100. * designated by module:echarts/coord/single/Single.
  101. * @type {Function}
  102. */
  103. toGlobalCoord: null,
  104. /**
  105. * Convert the global coord to local coord.
  106. * designated by module:echarts/coord/single/Single.
  107. * @type {Function}
  108. */
  109. toLocalCoord: null
  110. };
  111. zrUtil.inherits(SingleAxis, Axis);
  112. var _default = SingleAxis;
  113. module.exports = _default;