RadarSeries.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. defaultOption: {
  69. zlevel: 0,
  70. z: 2,
  71. coordinateSystem: 'radar',
  72. legendHoverLink: true,
  73. radarIndex: 0,
  74. lineStyle: {
  75. width: 2,
  76. type: 'solid'
  77. },
  78. label: {
  79. position: 'top'
  80. },
  81. // areaStyle: {
  82. // },
  83. // itemStyle: {}
  84. symbol: 'emptyCircle',
  85. symbolSize: 4 // symbolRotate: null
  86. }
  87. });
  88. var _default = RadarSeries;
  89. module.exports = _default;