FunnelSeries.js 5.1 KB

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