FunnelSeries.js 5.1 KB

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