ParallelModel.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 Component = require("../../model/Component");
  21. require("./AxisModel");
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. var _default = Component.extend({
  41. type: 'parallel',
  42. dependencies: ['parallelAxis'],
  43. /**
  44. * @type {module:echarts/coord/parallel/Parallel}
  45. */
  46. coordinateSystem: null,
  47. /**
  48. * Each item like: 'dim0', 'dim1', 'dim2', ...
  49. * @type {Array.<string>}
  50. * @readOnly
  51. */
  52. dimensions: null,
  53. /**
  54. * Coresponding to dimensions.
  55. * @type {Array.<number>}
  56. * @readOnly
  57. */
  58. parallelAxisIndex: null,
  59. layoutMode: 'box',
  60. defaultOption: {
  61. zlevel: 0,
  62. z: 0,
  63. left: 80,
  64. top: 60,
  65. right: 80,
  66. bottom: 60,
  67. // width: {totalWidth} - left - right,
  68. // height: {totalHeight} - top - bottom,
  69. layout: 'horizontal',
  70. // 'horizontal' or 'vertical'
  71. // FIXME
  72. // naming?
  73. axisExpandable: false,
  74. axisExpandCenter: null,
  75. axisExpandCount: 0,
  76. axisExpandWidth: 50,
  77. // FIXME '10%' ?
  78. axisExpandRate: 17,
  79. axisExpandDebounce: 50,
  80. // [out, in, jumpTarget]. In percentage. If use [null, 0.05], null means full.
  81. // Do not doc to user until necessary.
  82. axisExpandSlideTriggerArea: [-0.15, 0.05, 0.4],
  83. axisExpandTriggerOn: 'click',
  84. // 'mousemove' or 'click'
  85. parallelAxisDefault: null
  86. },
  87. /**
  88. * @override
  89. */
  90. init: function () {
  91. Component.prototype.init.apply(this, arguments);
  92. this.mergeOption({});
  93. },
  94. /**
  95. * @override
  96. */
  97. mergeOption: function (newOption) {
  98. var thisOption = this.option;
  99. newOption && zrUtil.merge(thisOption, newOption, true);
  100. this._initDimensions();
  101. },
  102. /**
  103. * Whether series or axis is in this coordinate system.
  104. * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model
  105. * @param {module:echarts/model/Global} ecModel
  106. */
  107. contains: function (model, ecModel) {
  108. var parallelIndex = model.get('parallelIndex');
  109. return parallelIndex != null && ecModel.getComponent('parallel', parallelIndex) === this;
  110. },
  111. setAxisExpand: function (opt) {
  112. zrUtil.each(['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth', 'axisExpandWindow'], function (name) {
  113. if (opt.hasOwnProperty(name)) {
  114. this.option[name] = opt[name];
  115. }
  116. }, this);
  117. },
  118. /**
  119. * @private
  120. */
  121. _initDimensions: function () {
  122. var dimensions = this.dimensions = [];
  123. var parallelAxisIndex = this.parallelAxisIndex = [];
  124. var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) {
  125. // Can not use this.contains here, because
  126. // initialization has not been completed yet.
  127. return (axisModel.get('parallelIndex') || 0) === this.componentIndex;
  128. }, this);
  129. zrUtil.each(axisModels, function (axisModel) {
  130. dimensions.push('dim' + axisModel.get('dim'));
  131. parallelAxisIndex.push(axisModel.componentIndex);
  132. });
  133. }
  134. });
  135. module.exports = _default;