parallelCreator.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 Parallel = require("./Parallel");
  20. var CoordinateSystem = require("../../CoordinateSystem");
  21. /*
  22. * Licensed to the Apache Software Foundation (ASF) under one
  23. * or more contributor license agreements. See the NOTICE file
  24. * distributed with this work for additional information
  25. * regarding copyright ownership. The ASF licenses this file
  26. * to you under the Apache License, Version 2.0 (the
  27. * "License"); you may not use this file except in compliance
  28. * with the License. You may obtain a copy of the License at
  29. *
  30. * http://www.apache.org/licenses/LICENSE-2.0
  31. *
  32. * Unless required by applicable law or agreed to in writing,
  33. * software distributed under the License is distributed on an
  34. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35. * KIND, either express or implied. See the License for the
  36. * specific language governing permissions and limitations
  37. * under the License.
  38. */
  39. /**
  40. * Parallel coordinate system creater.
  41. */
  42. function create(ecModel, api) {
  43. var coordSysList = [];
  44. ecModel.eachComponent('parallel', function (parallelModel, idx) {
  45. var coordSys = new Parallel(parallelModel, ecModel, api);
  46. coordSys.name = 'parallel_' + idx;
  47. coordSys.resize(parallelModel, api);
  48. parallelModel.coordinateSystem = coordSys;
  49. coordSys.model = parallelModel;
  50. coordSysList.push(coordSys);
  51. }); // Inject the coordinateSystems into seriesModel
  52. ecModel.eachSeries(function (seriesModel) {
  53. if (seriesModel.get('coordinateSystem') === 'parallel') {
  54. var parallelModel = ecModel.queryComponents({
  55. mainType: 'parallel',
  56. index: seriesModel.get('parallelIndex'),
  57. id: seriesModel.get('parallelId')
  58. })[0];
  59. seriesModel.coordinateSystem = parallelModel.coordinateSystem;
  60. }
  61. });
  62. return coordSysList;
  63. }
  64. CoordinateSystem.register('parallel', {
  65. create: create
  66. });