PieSeries.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 createSeriesDataSimply from '../helper/createSeriesDataSimply.js';
  42. import * as zrUtil from 'zrender/lib/core/util.js';
  43. import * as modelUtil from '../../util/model.js';
  44. import { getPercentSeats } from '../../util/number.js';
  45. import { makeSeriesEncodeForNameBased } from '../../data/helper/sourceHelper.js';
  46. import LegendVisualProvider from '../../visual/LegendVisualProvider.js';
  47. import SeriesModel from '../../model/Series.js';
  48. var innerData = modelUtil.makeInner();
  49. var PieSeriesModel = /** @class */function (_super) {
  50. __extends(PieSeriesModel, _super);
  51. function PieSeriesModel() {
  52. return _super !== null && _super.apply(this, arguments) || this;
  53. }
  54. /**
  55. * @overwrite
  56. */
  57. PieSeriesModel.prototype.init = function (option) {
  58. _super.prototype.init.apply(this, arguments);
  59. // Enable legend selection for each data item
  60. // Use a function instead of direct access because data reference may changed
  61. this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
  62. this._defaultLabelLine(option);
  63. };
  64. /**
  65. * @overwrite
  66. */
  67. PieSeriesModel.prototype.mergeOption = function () {
  68. _super.prototype.mergeOption.apply(this, arguments);
  69. };
  70. /**
  71. * @overwrite
  72. */
  73. PieSeriesModel.prototype.getInitialData = function () {
  74. return createSeriesDataSimply(this, {
  75. coordDimensions: ['value'],
  76. encodeDefaulter: zrUtil.curry(makeSeriesEncodeForNameBased, this)
  77. });
  78. };
  79. /**
  80. * @overwrite
  81. */
  82. PieSeriesModel.prototype.getDataParams = function (dataIndex) {
  83. var data = this.getData();
  84. // update seats when data is changed
  85. var dataInner = innerData(data);
  86. var seats = dataInner.seats;
  87. if (!seats) {
  88. var valueList_1 = [];
  89. data.each(data.mapDimension('value'), function (value) {
  90. valueList_1.push(value);
  91. });
  92. seats = dataInner.seats = getPercentSeats(valueList_1, data.hostModel.get('percentPrecision'));
  93. }
  94. var params = _super.prototype.getDataParams.call(this, dataIndex);
  95. // seats may be empty when sum is 0
  96. params.percent = seats[dataIndex] || 0;
  97. params.$vars.push('percent');
  98. return params;
  99. };
  100. PieSeriesModel.prototype._defaultLabelLine = function (option) {
  101. // Extend labelLine emphasis
  102. modelUtil.defaultEmphasis(option, 'labelLine', ['show']);
  103. var labelLineNormalOpt = option.labelLine;
  104. var labelLineEmphasisOpt = option.emphasis.labelLine;
  105. // Not show label line if `label.normal.show = false`
  106. labelLineNormalOpt.show = labelLineNormalOpt.show && option.label.show;
  107. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show && option.emphasis.label.show;
  108. };
  109. PieSeriesModel.type = 'series.pie';
  110. PieSeriesModel.defaultOption = {
  111. // zlevel: 0,
  112. z: 2,
  113. legendHoverLink: true,
  114. colorBy: 'data',
  115. // 默认全局居中
  116. center: ['50%', '50%'],
  117. radius: [0, '75%'],
  118. // 默认顺时针
  119. clockwise: true,
  120. startAngle: 90,
  121. endAngle: 'auto',
  122. padAngle: 0,
  123. // 最小角度改为0
  124. minAngle: 0,
  125. // If the angle of a sector less than `minShowLabelAngle`,
  126. // the label will not be displayed.
  127. minShowLabelAngle: 0,
  128. // 选中时扇区偏移量
  129. selectedOffset: 10,
  130. // 选择模式,默认关闭,可选single,multiple
  131. // selectedMode: false,
  132. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  133. // roseType: null,
  134. percentPrecision: 2,
  135. // If still show when all data zero.
  136. stillShowZeroSum: true,
  137. // cursor: null,
  138. left: 0,
  139. top: 0,
  140. right: 0,
  141. bottom: 0,
  142. width: null,
  143. height: null,
  144. label: {
  145. // color: 'inherit',
  146. // If rotate around circle
  147. rotate: 0,
  148. show: true,
  149. overflow: 'truncate',
  150. // 'outer', 'inside', 'center'
  151. position: 'outer',
  152. // 'none', 'labelLine', 'edge'. Works only when position is 'outer'
  153. alignTo: 'none',
  154. // Closest distance between label and chart edge.
  155. // Works only position is 'outer' and alignTo is 'edge'.
  156. edgeDistance: '25%',
  157. // Works only position is 'outer' and alignTo is not 'edge'.
  158. bleedMargin: 10,
  159. // Distance between text and label line.
  160. distanceToLabelLine: 5
  161. // formatter: 标签文本格式器,同 tooltip.formatter,不支持异步回调
  162. // 默认使用全局文本样式,详见 textStyle
  163. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  164. },
  165. // Enabled when label.normal.position is 'outer'
  166. labelLine: {
  167. show: true,
  168. // 引导线两段中的第一段长度
  169. length: 15,
  170. // 引导线两段中的第二段长度
  171. length2: 15,
  172. smooth: false,
  173. minTurnAngle: 90,
  174. maxSurfaceAngle: 90,
  175. lineStyle: {
  176. // color: 各异,
  177. width: 1,
  178. type: 'solid'
  179. }
  180. },
  181. itemStyle: {
  182. borderWidth: 1,
  183. borderJoin: 'round'
  184. },
  185. showEmptyCircle: true,
  186. emptyCircleStyle: {
  187. color: 'lightgray',
  188. opacity: 1
  189. },
  190. labelLayout: {
  191. // Hide the overlapped label.
  192. hideOverlap: true
  193. },
  194. emphasis: {
  195. scale: true,
  196. scaleSize: 5
  197. },
  198. // If use strategy to avoid label overlapping
  199. avoidLabelOverlap: true,
  200. // Animation type. Valid values: expansion, scale
  201. animationType: 'expansion',
  202. animationDuration: 1000,
  203. // Animation type when update. Valid values: transition, expansion
  204. animationTypeUpdate: 'transition',
  205. animationEasingUpdate: 'cubicInOut',
  206. animationDurationUpdate: 500,
  207. animationEasing: 'cubicInOut'
  208. };
  209. return PieSeriesModel;
  210. }(SeriesModel);
  211. export default PieSeriesModel;