helper.js 4.7 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. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. /**
  41. * This module exposes helper functions for developing extensions.
  42. */
  43. import * as zrUtil from 'zrender/lib/core/util.js';
  44. import createSeriesData from '../../chart/helper/createSeriesData.js'; // import createGraphFromNodeEdge from './chart/helper/createGraphFromNodeEdge.js';
  45. import * as axisHelper from '../../coord/axisHelper.js';
  46. import { AxisModelCommonMixin } from '../../coord/axisModelCommonMixin.js';
  47. import Model from '../../model/Model.js';
  48. import { getLayoutRect } from '../../util/layout.js';
  49. import { enableDataStack, isDimensionStacked, getStackedDimension } from '../../data/helper/dataStackHelper.js';
  50. import { getECData } from '../../util/innerStore.js';
  51. import { createTextStyle as innerCreateTextStyle } from '../../label/labelStyle.js';
  52. /**
  53. * Create a multi dimension List structure from seriesModel.
  54. */
  55. export function createList(seriesModel) {
  56. return createSeriesData(null, seriesModel);
  57. } // export function createGraph(seriesModel) {
  58. // let nodes = seriesModel.get('data');
  59. // let links = seriesModel.get('links');
  60. // return createGraphFromNodeEdge(nodes, links, seriesModel);
  61. // }
  62. export { getLayoutRect };
  63. export { createDimensions } from '../../data/helper/createDimensions.js';
  64. export var dataStack = {
  65. isDimensionStacked: isDimensionStacked,
  66. enableDataStack: enableDataStack,
  67. getStackedDimension: getStackedDimension
  68. };
  69. /**
  70. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  71. * @param {string} symbolDesc
  72. * @param {number} x
  73. * @param {number} y
  74. * @param {number} w
  75. * @param {number} h
  76. * @param {string} color
  77. */
  78. export { createSymbol } from '../../util/symbol.js';
  79. /**
  80. * Create scale
  81. * @param {Array.<number>} dataExtent
  82. * @param {Object|module:echarts/Model} option If `optoin.type`
  83. * is secified, it can only be `'value'` currently.
  84. */
  85. export function createScale(dataExtent, option) {
  86. var axisModel = option;
  87. if (!(option instanceof Model)) {
  88. axisModel = new Model(option); // FIXME
  89. // Currently AxisModelCommonMixin has nothing to do with the
  90. // the requirements of `axisHelper.createScaleByModel`. For
  91. // example the methods `getCategories` and `getOrdinalMeta`
  92. // are required for `'category'` axis, and ecModel is required
  93. // for `'time'` axis. But occasionally echarts-gl happened
  94. // to only use `'value'` axis.
  95. // zrUtil.mixin(axisModel, AxisModelCommonMixin);
  96. }
  97. var scale = axisHelper.createScaleByModel(axisModel);
  98. scale.setExtent(dataExtent[0], dataExtent[1]);
  99. axisHelper.niceScaleExtent(scale, axisModel);
  100. return scale;
  101. }
  102. /**
  103. * Mixin common methods to axis model,
  104. *
  105. * Include methods
  106. * `getFormattedLabels() => Array.<string>`
  107. * `getCategories() => Array.<string>`
  108. * `getMin(origin: boolean) => number`
  109. * `getMax(origin: boolean) => number`
  110. * `getNeedCrossZero() => boolean`
  111. */
  112. export function mixinAxisModelCommonMethods(Model) {
  113. zrUtil.mixin(Model, AxisModelCommonMixin);
  114. }
  115. export { getECData };
  116. export { enableHoverEmphasis } from '../../util/states.js';
  117. export function createTextStyle(textStyleModel, opts) {
  118. opts = opts || {};
  119. return innerCreateTextStyle(textStyleModel, null, null, opts.state !== 'normal');
  120. }