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