whiskerBoxCommon.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  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. import createSeriesDataSimply from './createSeriesDataSimply.js';
  41. import * as zrUtil from 'zrender/lib/core/util.js';
  42. import { getDimensionTypeByAxis } from '../../data/helper/dimensionHelper.js';
  43. import { makeSeriesEncodeForAxisCoordSys } from '../../data/helper/sourceHelper.js';
  44. var WhiskerBoxCommonMixin =
  45. /** @class */
  46. function () {
  47. function WhiskerBoxCommonMixin() {}
  48. /**
  49. * @override
  50. */
  51. WhiskerBoxCommonMixin.prototype.getInitialData = function (option, ecModel) {
  52. // When both types of xAxis and yAxis are 'value', layout is
  53. // needed to be specified by user. Otherwise, layout can be
  54. // judged by which axis is category.
  55. var ordinalMeta;
  56. var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
  57. var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
  58. var xAxisType = xAxisModel.get('type');
  59. var yAxisType = yAxisModel.get('type');
  60. var addOrdinal; // FIXME
  61. // Consider time axis.
  62. if (xAxisType === 'category') {
  63. option.layout = 'horizontal';
  64. ordinalMeta = xAxisModel.getOrdinalMeta();
  65. addOrdinal = true;
  66. } else if (yAxisType === 'category') {
  67. option.layout = 'vertical';
  68. ordinalMeta = yAxisModel.getOrdinalMeta();
  69. addOrdinal = true;
  70. } else {
  71. option.layout = option.layout || 'horizontal';
  72. }
  73. var coordDims = ['x', 'y'];
  74. var baseAxisDimIndex = option.layout === 'horizontal' ? 0 : 1;
  75. var baseAxisDim = this._baseAxisDim = coordDims[baseAxisDimIndex];
  76. var otherAxisDim = coordDims[1 - baseAxisDimIndex];
  77. var axisModels = [xAxisModel, yAxisModel];
  78. var baseAxisType = axisModels[baseAxisDimIndex].get('type');
  79. var otherAxisType = axisModels[1 - baseAxisDimIndex].get('type');
  80. var data = option.data; // Clone a new data for next setOption({}) usage.
  81. // Avoid modifying current data will affect further update.
  82. if (data && addOrdinal) {
  83. var newOptionData_1 = [];
  84. zrUtil.each(data, function (item, index) {
  85. var newItem;
  86. if (zrUtil.isArray(item)) {
  87. newItem = item.slice(); // Modify current using data.
  88. item.unshift(index);
  89. } else if (zrUtil.isArray(item.value)) {
  90. newItem = zrUtil.extend({}, item);
  91. newItem.value = newItem.value.slice(); // Modify current using data.
  92. item.value.unshift(index);
  93. } else {
  94. newItem = item;
  95. }
  96. newOptionData_1.push(newItem);
  97. });
  98. option.data = newOptionData_1;
  99. }
  100. var defaultValueDimensions = this.defaultValueDimensions;
  101. var coordDimensions = [{
  102. name: baseAxisDim,
  103. type: getDimensionTypeByAxis(baseAxisType),
  104. ordinalMeta: ordinalMeta,
  105. otherDims: {
  106. tooltip: false,
  107. itemName: 0
  108. },
  109. dimsDef: ['base']
  110. }, {
  111. name: otherAxisDim,
  112. type: getDimensionTypeByAxis(otherAxisType),
  113. dimsDef: defaultValueDimensions.slice()
  114. }];
  115. return createSeriesDataSimply(this, {
  116. coordDimensions: coordDimensions,
  117. dimensionsCount: defaultValueDimensions.length + 1,
  118. encodeDefaulter: zrUtil.curry(makeSeriesEncodeForAxisCoordSys, coordDimensions, this)
  119. });
  120. };
  121. /**
  122. * If horizontal, base axis is x, otherwise y.
  123. * @override
  124. */
  125. WhiskerBoxCommonMixin.prototype.getBaseAxis = function () {
  126. var dim = this._baseAxisDim;
  127. return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
  128. };
  129. return WhiskerBoxCommonMixin;
  130. }();
  131. ;
  132. export { WhiskerBoxCommonMixin };