RadarModel.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 axisDefault from '../axisDefault.js';
  43. import Model from '../../model/Model.js';
  44. import { AxisModelCommonMixin } from '../axisModelCommonMixin.js';
  45. import ComponentModel from '../../model/Component.js';
  46. var valueAxisDefault = axisDefault.value;
  47. function defaultsShow(opt, show) {
  48. return zrUtil.defaults({
  49. show: show
  50. }, opt);
  51. }
  52. var RadarModel = /** @class */function (_super) {
  53. __extends(RadarModel, _super);
  54. function RadarModel() {
  55. var _this = _super !== null && _super.apply(this, arguments) || this;
  56. _this.type = RadarModel.type;
  57. return _this;
  58. }
  59. RadarModel.prototype.optionUpdated = function () {
  60. var boundaryGap = this.get('boundaryGap');
  61. var splitNumber = this.get('splitNumber');
  62. var scale = this.get('scale');
  63. var axisLine = this.get('axisLine');
  64. var axisTick = this.get('axisTick');
  65. // let axisType = this.get('axisType');
  66. var axisLabel = this.get('axisLabel');
  67. var nameTextStyle = this.get('axisName');
  68. var showName = this.get(['axisName', 'show']);
  69. var nameFormatter = this.get(['axisName', 'formatter']);
  70. var nameGap = this.get('axisNameGap');
  71. var triggerEvent = this.get('triggerEvent');
  72. var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) {
  73. // PENDING
  74. if (indicatorOpt.max != null && indicatorOpt.max > 0 && !indicatorOpt.min) {
  75. indicatorOpt.min = 0;
  76. } else if (indicatorOpt.min != null && indicatorOpt.min < 0 && !indicatorOpt.max) {
  77. indicatorOpt.max = 0;
  78. }
  79. var iNameTextStyle = nameTextStyle;
  80. if (indicatorOpt.color != null) {
  81. iNameTextStyle = zrUtil.defaults({
  82. color: indicatorOpt.color
  83. }, nameTextStyle);
  84. }
  85. // Use same configuration
  86. var innerIndicatorOpt = zrUtil.merge(zrUtil.clone(indicatorOpt), {
  87. boundaryGap: boundaryGap,
  88. splitNumber: splitNumber,
  89. scale: scale,
  90. axisLine: axisLine,
  91. axisTick: axisTick,
  92. // axisType: axisType,
  93. axisLabel: axisLabel,
  94. // Compatible with 2 and use text
  95. name: indicatorOpt.text,
  96. showName: showName,
  97. nameLocation: 'end',
  98. nameGap: nameGap,
  99. // min: 0,
  100. nameTextStyle: iNameTextStyle,
  101. triggerEvent: triggerEvent
  102. }, false);
  103. if (zrUtil.isString(nameFormatter)) {
  104. var indName = innerIndicatorOpt.name;
  105. innerIndicatorOpt.name = nameFormatter.replace('{value}', indName != null ? indName : '');
  106. } else if (zrUtil.isFunction(nameFormatter)) {
  107. innerIndicatorOpt.name = nameFormatter(innerIndicatorOpt.name, innerIndicatorOpt);
  108. }
  109. var model = new Model(innerIndicatorOpt, null, this.ecModel);
  110. zrUtil.mixin(model, AxisModelCommonMixin.prototype);
  111. // For triggerEvent.
  112. model.mainType = 'radar';
  113. model.componentIndex = this.componentIndex;
  114. return model;
  115. }, this);
  116. this._indicatorModels = indicatorModels;
  117. };
  118. RadarModel.prototype.getIndicatorModels = function () {
  119. return this._indicatorModels;
  120. };
  121. RadarModel.type = 'radar';
  122. RadarModel.defaultOption = {
  123. // zlevel: 0,
  124. z: 0,
  125. center: ['50%', '50%'],
  126. radius: '75%',
  127. startAngle: 90,
  128. axisName: {
  129. show: true
  130. // formatter: null
  131. // textStyle: {}
  132. },
  133. boundaryGap: [0, 0],
  134. splitNumber: 5,
  135. axisNameGap: 15,
  136. scale: false,
  137. // Polygon or circle
  138. shape: 'polygon',
  139. axisLine: zrUtil.merge({
  140. lineStyle: {
  141. color: '#bbb'
  142. }
  143. }, valueAxisDefault.axisLine),
  144. axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
  145. axisTick: defaultsShow(valueAxisDefault.axisTick, false),
  146. // axisType: 'value',
  147. splitLine: defaultsShow(valueAxisDefault.splitLine, true),
  148. splitArea: defaultsShow(valueAxisDefault.splitArea, true),
  149. // {text, min, max}
  150. indicator: []
  151. };
  152. return RadarModel;
  153. }(ComponentModel);
  154. export default RadarModel;