createListSimply.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 createDimensions = require("../../data/helper/createDimensions");
  20. var List = require("../../data/List");
  21. var _util = require("zrender/lib/core/util");
  22. var extend = _util.extend;
  23. var isArray = _util.isArray;
  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. /**
  43. * [Usage]:
  44. * (1)
  45. * createListSimply(seriesModel, ['value']);
  46. * (2)
  47. * createListSimply(seriesModel, {
  48. * coordDimensions: ['value'],
  49. * dimensionsCount: 5
  50. * });
  51. *
  52. * @param {module:echarts/model/Series} seriesModel
  53. * @param {Object|Array.<string|Object>} opt opt or coordDimensions
  54. * The options in opt, see `echarts/data/helper/createDimensions`
  55. * @param {Array.<string>} [nameList]
  56. * @return {module:echarts/data/List}
  57. */
  58. function _default(seriesModel, opt, nameList) {
  59. opt = isArray(opt) && {
  60. coordDimensions: opt
  61. } || extend({}, opt);
  62. var source = seriesModel.getSource();
  63. var dimensionsInfo = createDimensions(source, opt);
  64. var list = new List(dimensionsInfo, seriesModel);
  65. list.initData(source, nameList);
  66. return list;
  67. }
  68. module.exports = _default;