PieSeries.js 7.0 KB

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