SingleAxis.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. var zrUtil = require("zrender/lib/core/util");
  2. var Axis = require("../Axis");
  3. /**
  4. * @constructor module:echarts/coord/single/SingleAxis
  5. * @extends {module:echarts/coord/Axis}
  6. * @param {string} dim
  7. * @param {*} scale
  8. * @param {Array.<number>} coordExtent
  9. * @param {string} axisType
  10. * @param {string} position
  11. */
  12. var SingleAxis = function (dim, scale, coordExtent, axisType, position) {
  13. Axis.call(this, dim, scale, coordExtent);
  14. /**
  15. * Axis type
  16. * - 'category'
  17. * - 'value'
  18. * - 'time'
  19. * - 'log'
  20. * @type {string}
  21. */
  22. this.type = axisType || 'value';
  23. /**
  24. * Axis position
  25. * - 'top'
  26. * - 'bottom'
  27. * - 'left'
  28. * - 'right'
  29. * @type {string}
  30. */
  31. this.position = position || 'bottom';
  32. /**
  33. * Axis orient
  34. * - 'horizontal'
  35. * - 'vertical'
  36. * @type {[type]}
  37. */
  38. this.orient = null;
  39. /**
  40. * @type {number}
  41. */
  42. this._labelInterval = null;
  43. };
  44. SingleAxis.prototype = {
  45. constructor: SingleAxis,
  46. /**
  47. * Axis model
  48. * @type {module:echarts/coord/single/AxisModel}
  49. */
  50. model: null,
  51. /**
  52. * Judge the orient of the axis.
  53. * @return {boolean}
  54. */
  55. isHorizontal: function () {
  56. var position = this.position;
  57. return position === 'top' || position === 'bottom';
  58. },
  59. /**
  60. * @override
  61. */
  62. pointToData: function (point, clamp) {
  63. return this.coordinateSystem.pointToData(point, clamp)[0];
  64. },
  65. /**
  66. * Convert the local coord(processed by dataToCoord())
  67. * to global coord(concrete pixel coord).
  68. * designated by module:echarts/coord/single/Single.
  69. * @type {Function}
  70. */
  71. toGlobalCoord: null,
  72. /**
  73. * Convert the global coord to local coord.
  74. * designated by module:echarts/coord/single/Single.
  75. * @type {Function}
  76. */
  77. toLocalCoord: null
  78. };
  79. zrUtil.inherits(SingleAxis, Axis);
  80. var _default = SingleAxis;
  81. module.exports = _default;