ParallelModel.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var zrUtil = require("zrender/lib/core/util");
  2. var Component = require("../../model/Component");
  3. require("./AxisModel");
  4. var _default = Component.extend({
  5. type: 'parallel',
  6. dependencies: ['parallelAxis'],
  7. /**
  8. * @type {module:echarts/coord/parallel/Parallel}
  9. */
  10. coordinateSystem: null,
  11. /**
  12. * Each item like: 'dim0', 'dim1', 'dim2', ...
  13. * @type {Array.<string>}
  14. * @readOnly
  15. */
  16. dimensions: null,
  17. /**
  18. * Coresponding to dimensions.
  19. * @type {Array.<number>}
  20. * @readOnly
  21. */
  22. parallelAxisIndex: null,
  23. layoutMode: 'box',
  24. defaultOption: {
  25. zlevel: 0,
  26. z: 0,
  27. left: 80,
  28. top: 60,
  29. right: 80,
  30. bottom: 60,
  31. // width: {totalWidth} - left - right,
  32. // height: {totalHeight} - top - bottom,
  33. layout: 'horizontal',
  34. // 'horizontal' or 'vertical'
  35. // FIXME
  36. // naming?
  37. axisExpandable: false,
  38. axisExpandCenter: null,
  39. axisExpandCount: 0,
  40. axisExpandWidth: 50,
  41. // FIXME '10%' ?
  42. axisExpandRate: 17,
  43. axisExpandDebounce: 50,
  44. // [out, in, jumpTarget]. In percentage. If use [null, 0.05], null means full.
  45. // Do not doc to user until necessary.
  46. axisExpandSlideTriggerArea: [-0.15, 0.05, 0.4],
  47. axisExpandTriggerOn: 'click',
  48. // 'mousemove' or 'click'
  49. parallelAxisDefault: null
  50. },
  51. /**
  52. * @override
  53. */
  54. init: function () {
  55. Component.prototype.init.apply(this, arguments);
  56. this.mergeOption({});
  57. },
  58. /**
  59. * @override
  60. */
  61. mergeOption: function (newOption) {
  62. var thisOption = this.option;
  63. newOption && zrUtil.merge(thisOption, newOption, true);
  64. this._initDimensions();
  65. },
  66. /**
  67. * Whether series or axis is in this coordinate system.
  68. * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model
  69. * @param {module:echarts/model/Global} ecModel
  70. */
  71. contains: function (model, ecModel) {
  72. var parallelIndex = model.get('parallelIndex');
  73. return parallelIndex != null && ecModel.getComponent('parallel', parallelIndex) === this;
  74. },
  75. setAxisExpand: function (opt) {
  76. zrUtil.each(['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth', 'axisExpandWindow'], function (name) {
  77. if (opt.hasOwnProperty(name)) {
  78. this.option[name] = opt[name];
  79. }
  80. }, this);
  81. },
  82. /**
  83. * @private
  84. */
  85. _initDimensions: function () {
  86. var dimensions = this.dimensions = [];
  87. var parallelAxisIndex = this.parallelAxisIndex = [];
  88. var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) {
  89. // Can not use this.contains here, because
  90. // initialization has not been completed yet.
  91. return (axisModel.get('parallelIndex') || 0) === this.componentIndex;
  92. }, this);
  93. zrUtil.each(axisModels, function (axisModel) {
  94. dimensions.push('dim' + axisModel.get('dim'));
  95. parallelAxisIndex.push(axisModel.componentIndex);
  96. });
  97. }
  98. });
  99. module.exports = _default;