FunnelSeries.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 { __extends } from "tslib";
  41. import * as zrUtil from 'zrender/lib/core/util.js';
  42. import createSeriesDataSimply from '../helper/createSeriesDataSimply.js';
  43. import { defaultEmphasis } from '../../util/model.js';
  44. import { makeSeriesEncodeForNameBased } from '../../data/helper/sourceHelper.js';
  45. import LegendVisualProvider from '../../visual/LegendVisualProvider.js';
  46. import SeriesModel from '../../model/Series.js';
  47. var FunnelSeriesModel = /** @class */function (_super) {
  48. __extends(FunnelSeriesModel, _super);
  49. function FunnelSeriesModel() {
  50. var _this = _super !== null && _super.apply(this, arguments) || this;
  51. _this.type = FunnelSeriesModel.type;
  52. return _this;
  53. }
  54. FunnelSeriesModel.prototype.init = function (option) {
  55. _super.prototype.init.apply(this, arguments);
  56. // Enable legend selection for each data item
  57. // Use a function instead of direct access because data reference may changed
  58. this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
  59. // Extend labelLine emphasis
  60. this._defaultLabelLine(option);
  61. };
  62. FunnelSeriesModel.prototype.getInitialData = function (option, ecModel) {
  63. return createSeriesDataSimply(this, {
  64. coordDimensions: ['value'],
  65. encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
  66. });
  67. };
  68. FunnelSeriesModel.prototype._defaultLabelLine = function (option) {
  69. // Extend labelLine emphasis
  70. defaultEmphasis(option, 'labelLine', ['show']);
  71. var labelLineNormalOpt = option.labelLine;
  72. var labelLineEmphasisOpt = option.emphasis.labelLine;
  73. // Not show label line if `label.normal.show = false`
  74. labelLineNormalOpt.show = labelLineNormalOpt.show && option.label.show;
  75. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show && option.emphasis.label.show;
  76. };
  77. // Overwrite
  78. FunnelSeriesModel.prototype.getDataParams = function (dataIndex) {
  79. var data = this.getData();
  80. var params = _super.prototype.getDataParams.call(this, dataIndex);
  81. var valueDim = data.mapDimension('value');
  82. var sum = data.getSum(valueDim);
  83. // Percent is 0 if sum is 0
  84. params.percent = !sum ? 0 : +(data.get(valueDim, dataIndex) / sum * 100).toFixed(2);
  85. params.$vars.push('percent');
  86. return params;
  87. };
  88. FunnelSeriesModel.type = 'series.funnel';
  89. FunnelSeriesModel.defaultOption = {
  90. // zlevel: 0, // 一级层叠
  91. z: 2,
  92. legendHoverLink: true,
  93. colorBy: 'data',
  94. left: 80,
  95. top: 60,
  96. right: 80,
  97. bottom: 60,
  98. // width: {totalWidth} - left - right,
  99. // height: {totalHeight} - top - bottom,
  100. // 默认取数据最小最大值
  101. // min: 0,
  102. // max: 100,
  103. minSize: '0%',
  104. maxSize: '100%',
  105. sort: 'descending',
  106. orient: 'vertical',
  107. gap: 0,
  108. funnelAlign: 'center',
  109. label: {
  110. show: true,
  111. position: 'outer'
  112. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  113. },
  114. labelLine: {
  115. show: true,
  116. length: 20,
  117. lineStyle: {
  118. // color: 各异,
  119. width: 1
  120. }
  121. },
  122. itemStyle: {
  123. // color: 各异,
  124. borderColor: '#fff',
  125. borderWidth: 1
  126. },
  127. emphasis: {
  128. label: {
  129. show: true
  130. }
  131. },
  132. select: {
  133. itemStyle: {
  134. borderColor: '#212121'
  135. }
  136. }
  137. };
  138. return FunnelSeriesModel;
  139. }(SeriesModel);
  140. export default FunnelSeriesModel;