RadarModel.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 =
  53. /** @class */
  54. function (_super) {
  55. __extends(RadarModel, _super);
  56. function RadarModel() {
  57. var _this = _super !== null && _super.apply(this, arguments) || this;
  58. _this.type = RadarModel.type;
  59. return _this;
  60. }
  61. RadarModel.prototype.optionUpdated = function () {
  62. var boundaryGap = this.get('boundaryGap');
  63. var splitNumber = this.get('splitNumber');
  64. var scale = this.get('scale');
  65. var axisLine = this.get('axisLine');
  66. var axisTick = this.get('axisTick'); // let axisType = this.get('axisType');
  67. var axisLabel = this.get('axisLabel');
  68. var nameTextStyle = this.get('axisName');
  69. var showName = this.get(['axisName', 'show']);
  70. var nameFormatter = this.get(['axisName', 'formatter']);
  71. var nameGap = this.get('axisNameGap');
  72. var triggerEvent = this.get('triggerEvent');
  73. var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) {
  74. // PENDING
  75. if (indicatorOpt.max != null && indicatorOpt.max > 0 && !indicatorOpt.min) {
  76. indicatorOpt.min = 0;
  77. } else if (indicatorOpt.min != null && indicatorOpt.min < 0 && !indicatorOpt.max) {
  78. indicatorOpt.max = 0;
  79. }
  80. var iNameTextStyle = nameTextStyle;
  81. if (indicatorOpt.color != null) {
  82. iNameTextStyle = zrUtil.defaults({
  83. color: indicatorOpt.color
  84. }, nameTextStyle);
  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); // For triggerEvent.
  111. model.mainType = 'radar';
  112. model.componentIndex = this.componentIndex;
  113. return model;
  114. }, this);
  115. this._indicatorModels = indicatorModels;
  116. };
  117. RadarModel.prototype.getIndicatorModels = function () {
  118. return this._indicatorModels;
  119. };
  120. RadarModel.type = 'radar';
  121. RadarModel.defaultOption = {
  122. // zlevel: 0,
  123. z: 0,
  124. center: ['50%', '50%'],
  125. radius: '75%',
  126. startAngle: 90,
  127. axisName: {
  128. show: true // formatter: null
  129. // textStyle: {}
  130. },
  131. boundaryGap: [0, 0],
  132. splitNumber: 5,
  133. axisNameGap: 15,
  134. scale: false,
  135. // Polygon or circle
  136. shape: 'polygon',
  137. axisLine: zrUtil.merge({
  138. lineStyle: {
  139. color: '#bbb'
  140. }
  141. }, valueAxisDefault.axisLine),
  142. axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
  143. axisTick: defaultsShow(valueAxisDefault.axisTick, false),
  144. // axisType: 'value',
  145. splitLine: defaultsShow(valueAxisDefault.splitLine, true),
  146. splitArea: defaultsShow(valueAxisDefault.splitArea, true),
  147. // {text, min, max}
  148. indicator: []
  149. };
  150. return RadarModel;
  151. }(ComponentModel);
  152. export default RadarModel;