ParallelSeries.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 _util = require("zrender/lib/core/util");
  20. var each = _util.each;
  21. var createHashMap = _util.createHashMap;
  22. var SeriesModel = require("../../model/Series");
  23. var createListFromArray = require("../helper/createListFromArray");
  24. /*
  25. * Licensed to the Apache Software Foundation (ASF) under one
  26. * or more contributor license agreements. See the NOTICE file
  27. * distributed with this work for additional information
  28. * regarding copyright ownership. The ASF licenses this file
  29. * to you under the Apache License, Version 2.0 (the
  30. * "License"); you may not use this file except in compliance
  31. * with the License. You may obtain a copy of the License at
  32. *
  33. * http://www.apache.org/licenses/LICENSE-2.0
  34. *
  35. * Unless required by applicable law or agreed to in writing,
  36. * software distributed under the License is distributed on an
  37. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38. * KIND, either express or implied. See the License for the
  39. * specific language governing permissions and limitations
  40. * under the License.
  41. */
  42. var _default = SeriesModel.extend({
  43. type: 'series.parallel',
  44. dependencies: ['parallel'],
  45. visualColorAccessPath: 'lineStyle.color',
  46. getInitialData: function (option, ecModel) {
  47. var source = this.getSource();
  48. setEncodeAndDimensions(source, this);
  49. return createListFromArray(source, this);
  50. },
  51. /**
  52. * User can get data raw indices on 'axisAreaSelected' event received.
  53. *
  54. * @public
  55. * @param {string} activeState 'active' or 'inactive' or 'normal'
  56. * @return {Array.<number>} Raw indices
  57. */
  58. getRawIndicesByActiveState: function (activeState) {
  59. var coordSys = this.coordinateSystem;
  60. var data = this.getData();
  61. var indices = [];
  62. coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
  63. if (activeState === theActiveState) {
  64. indices.push(data.getRawIndex(dataIndex));
  65. }
  66. });
  67. return indices;
  68. },
  69. defaultOption: {
  70. zlevel: 0,
  71. // 一级层叠
  72. z: 2,
  73. // 二级层叠
  74. coordinateSystem: 'parallel',
  75. parallelIndex: 0,
  76. label: {
  77. show: false
  78. },
  79. inactiveOpacity: 0.05,
  80. activeOpacity: 1,
  81. lineStyle: {
  82. width: 1,
  83. opacity: 0.45,
  84. type: 'solid'
  85. },
  86. emphasis: {
  87. label: {
  88. show: false
  89. }
  90. },
  91. progressive: 500,
  92. smooth: false,
  93. // true | false | number
  94. animationEasing: 'linear'
  95. }
  96. });
  97. function setEncodeAndDimensions(source, seriesModel) {
  98. // The mapping of parallelAxis dimension to data dimension can
  99. // be specified in parallelAxis.option.dim. For example, if
  100. // parallelAxis.option.dim is 'dim3', it mapping to the third
  101. // dimension of data. But `data.encode` has higher priority.
  102. // Moreover, parallelModel.dimension should not be regarded as data
  103. // dimensions. Consider dimensions = ['dim4', 'dim2', 'dim6'];
  104. if (source.encodeDefine) {
  105. return;
  106. }
  107. var parallelModel = seriesModel.ecModel.getComponent('parallel', seriesModel.get('parallelIndex'));
  108. if (!parallelModel) {
  109. return;
  110. }
  111. var encodeDefine = source.encodeDefine = createHashMap();
  112. each(parallelModel.dimensions, function (axisDim) {
  113. var dataDimIndex = convertDimNameToNumber(axisDim);
  114. encodeDefine.set(axisDim, dataDimIndex);
  115. });
  116. }
  117. function convertDimNameToNumber(dimName) {
  118. return +dimName.replace('dim', '');
  119. }
  120. module.exports = _default;