PieSeries.js 7.0 KB

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