RadarSeries.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 SeriesModel from '../../model/Series.js';
  42. import createSeriesDataSimply from '../helper/createSeriesDataSimply.js';
  43. import * as zrUtil from 'zrender/lib/core/util.js';
  44. import LegendVisualProvider from '../../visual/LegendVisualProvider.js';
  45. import { createTooltipMarkup, retrieveVisualColorForTooltipMarker } from '../../component/tooltip/tooltipMarkup.js';
  46. export var SERIES_TYPE_RADAR = 'radar';
  47. var RadarSeriesModel = /** @class */function (_super) {
  48. __extends(RadarSeriesModel, _super);
  49. function RadarSeriesModel() {
  50. var _this = _super !== null && _super.apply(this, arguments) || this;
  51. _this.type = RadarSeriesModel.type;
  52. _this.hasSymbolVisual = true;
  53. return _this;
  54. }
  55. // Overwrite
  56. RadarSeriesModel.prototype.init = function (option) {
  57. _super.prototype.init.apply(this, arguments);
  58. // Enable legend selection for each data item
  59. // Use a function instead of direct access because data reference may changed
  60. this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
  61. };
  62. RadarSeriesModel.prototype.getInitialData = function (option, ecModel) {
  63. return createSeriesDataSimply(this, {
  64. generateCoord: 'indicator_',
  65. generateCoordCount: Infinity
  66. });
  67. };
  68. RadarSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  69. var data = this.getData();
  70. var coordSys = this.coordinateSystem;
  71. var indicatorAxes = coordSys.getIndicatorAxes();
  72. var name = this.getData().getName(dataIndex);
  73. var nameToDisplay = name === '' ? this.name : name;
  74. var markerColor = retrieveVisualColorForTooltipMarker(this, dataIndex);
  75. return createTooltipMarkup('section', {
  76. header: nameToDisplay,
  77. sortBlocks: true,
  78. blocks: zrUtil.map(indicatorAxes, function (axis) {
  79. var val = data.get(data.mapDimension(axis.dim), dataIndex);
  80. return createTooltipMarkup('nameValue', {
  81. markerType: 'subItem',
  82. markerColor: markerColor,
  83. name: axis.name,
  84. value: val,
  85. sortParam: val
  86. });
  87. })
  88. });
  89. };
  90. RadarSeriesModel.prototype.getTooltipPosition = function (dataIndex) {
  91. if (dataIndex != null) {
  92. var data_1 = this.getData();
  93. var coordSys = this.coordinateSystem;
  94. var values = data_1.getValues(zrUtil.map(coordSys.dimensions, function (dim) {
  95. return data_1.mapDimension(dim);
  96. }), dataIndex);
  97. for (var i = 0, len = values.length; i < len; i++) {
  98. if (!isNaN(values[i])) {
  99. var indicatorAxes = coordSys.getIndicatorAxes();
  100. return coordSys.coordToPoint(indicatorAxes[i].dataToCoord(values[i]), i);
  101. }
  102. }
  103. }
  104. };
  105. RadarSeriesModel.type = 'series.' + SERIES_TYPE_RADAR;
  106. RadarSeriesModel.dependencies = ['radar'];
  107. RadarSeriesModel.defaultOption = {
  108. // zlevel: 0,
  109. z: 2,
  110. colorBy: 'data',
  111. coordinateSystem: 'radar',
  112. legendHoverLink: true,
  113. radarIndex: 0,
  114. lineStyle: {
  115. width: 2,
  116. type: 'solid',
  117. join: 'round'
  118. },
  119. label: {
  120. position: 'top'
  121. },
  122. // areaStyle: {
  123. // },
  124. // itemStyle: {}
  125. symbolSize: 8
  126. // symbolRotate: null
  127. };
  128. return RadarSeriesModel;
  129. }(SeriesModel);
  130. export default RadarSeriesModel;