RadarSeries.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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) {
  59. var data = this.getData();
  60. var coordSys = this.coordinateSystem;
  61. var indicatorAxes = coordSys.getIndicatorAxes();
  62. var name = this.getData().getName(dataIndex);
  63. return encodeHTML(name === '' ? this.name : name) + '<br/>' + zrUtil.map(indicatorAxes, function (axis, idx) {
  64. var val = data.get(data.mapDimension(axis.dim), dataIndex);
  65. return encodeHTML(axis.name + ' : ' + val);
  66. }).join('<br />');
  67. },
  68. /**
  69. * @implement
  70. */
  71. getTooltipPosition: function (dataIndex) {
  72. if (dataIndex != null) {
  73. var data = this.getData();
  74. var coordSys = this.coordinateSystem;
  75. var values = data.getValues(zrUtil.map(coordSys.dimensions, function (dim) {
  76. return data.mapDimension(dim);
  77. }), dataIndex, true);
  78. for (var i = 0, len = values.length; i < len; i++) {
  79. if (!isNaN(values[i])) {
  80. var indicatorAxes = coordSys.getIndicatorAxes();
  81. return coordSys.coordToPoint(indicatorAxes[i].dataToCoord(values[i]), i);
  82. }
  83. }
  84. }
  85. },
  86. defaultOption: {
  87. zlevel: 0,
  88. z: 2,
  89. coordinateSystem: 'radar',
  90. legendHoverLink: true,
  91. radarIndex: 0,
  92. lineStyle: {
  93. width: 2,
  94. type: 'solid'
  95. },
  96. label: {
  97. position: 'top'
  98. },
  99. // areaStyle: {
  100. // },
  101. // itemStyle: {}
  102. symbol: 'emptyCircle',
  103. symbolSize: 4 // symbolRotate: null
  104. }
  105. });
  106. var _default = RadarSeries;
  107. module.exports = _default;