RadarSeries.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. var SeriesModel = require("../../model/Series");
  20. var createListSimply = require("../helper/createListSimply");
  21. var zrUtil = require("zrender/lib/core/util");
  22. var _format = require("../../util/format");
  23. var encodeHTML = _format.encodeHTML;
  24. var LegendVisualProvider = require("../../visual/LegendVisualProvider");
  25. /*
  26. * Licensed to the Apache Software Foundation (ASF) under one
  27. * or more contributor license agreements. See the NOTICE file
  28. * distributed with this work for additional information
  29. * regarding copyright ownership. The ASF licenses this file
  30. * to you under the Apache License, Version 2.0 (the
  31. * "License"); you may not use this file except in compliance
  32. * with the License. You may obtain a copy of the License at
  33. *
  34. * http://www.apache.org/licenses/LICENSE-2.0
  35. *
  36. * Unless required by applicable law or agreed to in writing,
  37. * software distributed under the License is distributed on an
  38. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39. * KIND, either express or implied. See the License for the
  40. * specific language governing permissions and limitations
  41. * under the License.
  42. */
  43. var RadarSeries = SeriesModel.extend({
  44. type: 'series.radar',
  45. dependencies: ['radar'],
  46. // Overwrite
  47. init: function (option) {
  48. RadarSeries.superApply(this, 'init', arguments); // Enable legend selection for each data item
  49. // Use a function instead of direct access because data reference may changed
  50. this.legendVisualProvider = new LegendVisualProvider(zrUtil.bind(this.getData, this), zrUtil.bind(this.getRawData, this));
  51. },
  52. getInitialData: function (option, ecModel) {
  53. return createListSimply(this, {
  54. generateCoord: 'indicator_',
  55. generateCoordCount: Infinity
  56. });
  57. },
  58. formatTooltip: function (dataIndex, multipleSeries, dataType, renderMode) {
  59. var data = this.getData();
  60. var coordSys = this.coordinateSystem;
  61. var indicatorAxes = coordSys.getIndicatorAxes();
  62. var name = this.getData().getName(dataIndex);
  63. var newLine = renderMode === 'html' ? '<br/>' : '\n';
  64. return encodeHTML(name === '' ? this.name : name) + newLine + zrUtil.map(indicatorAxes, function (axis, idx) {
  65. var val = data.get(data.mapDimension(axis.dim), dataIndex);
  66. return encodeHTML(axis.name + ' : ' + val);
  67. }).join(newLine);
  68. },
  69. /**
  70. * @implement
  71. */
  72. getTooltipPosition: function (dataIndex) {
  73. if (dataIndex != null) {
  74. var data = this.getData();
  75. var coordSys = this.coordinateSystem;
  76. var values = data.getValues(zrUtil.map(coordSys.dimensions, function (dim) {
  77. return data.mapDimension(dim);
  78. }), dataIndex, true);
  79. for (var i = 0, len = values.length; i < len; i++) {
  80. if (!isNaN(values[i])) {
  81. var indicatorAxes = coordSys.getIndicatorAxes();
  82. return coordSys.coordToPoint(indicatorAxes[i].dataToCoord(values[i]), i);
  83. }
  84. }
  85. }
  86. },
  87. defaultOption: {
  88. zlevel: 0,
  89. z: 2,
  90. coordinateSystem: 'radar',
  91. legendHoverLink: true,
  92. radarIndex: 0,
  93. lineStyle: {
  94. width: 2,
  95. type: 'solid'
  96. },
  97. label: {
  98. position: 'top'
  99. },
  100. // areaStyle: {
  101. // },
  102. // itemStyle: {}
  103. symbol: 'emptyCircle',
  104. symbolSize: 4 // symbolRotate: null
  105. }
  106. });
  107. var _default = RadarSeries;
  108. module.exports = _default;