helper.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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';
  45. // import createGraphFromNodeEdge from './chart/helper/createGraphFromNodeEdge.js';
  46. import * as axisHelper from '../../coord/axisHelper.js';
  47. import { AxisModelCommonMixin } from '../../coord/axisModelCommonMixin.js';
  48. import Model from '../../model/Model.js';
  49. import { getLayoutRect } from '../../util/layout.js';
  50. import { enableDataStack, isDimensionStacked, getStackedDimension } from '../../data/helper/dataStackHelper.js';
  51. import { getECData } from '../../util/innerStore.js';
  52. import { createTextStyle as innerCreateTextStyle } from '../../label/labelStyle.js';
  53. /**
  54. * Create a multi dimension List structure from seriesModel.
  55. */
  56. export function createList(seriesModel) {
  57. return createSeriesData(null, seriesModel);
  58. }
  59. // export function createGraph(seriesModel) {
  60. // let nodes = seriesModel.get('data');
  61. // let links = seriesModel.get('links');
  62. // return createGraphFromNodeEdge(nodes, links, seriesModel);
  63. // }
  64. export { getLayoutRect };
  65. export { createDimensions } from '../../data/helper/createDimensions.js';
  66. export var dataStack = {
  67. isDimensionStacked: isDimensionStacked,
  68. enableDataStack: enableDataStack,
  69. getStackedDimension: getStackedDimension
  70. };
  71. /**
  72. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  73. * @param {string} symbolDesc
  74. * @param {number} x
  75. * @param {number} y
  76. * @param {number} w
  77. * @param {number} h
  78. * @param {string} color
  79. */
  80. export { createSymbol } from '../../util/symbol.js';
  81. /**
  82. * Create scale
  83. * @param {Array.<number>} dataExtent
  84. * @param {Object|module:echarts/Model} option If `optoin.type`
  85. * is secified, it can only be `'value'` currently.
  86. */
  87. export function createScale(dataExtent, option) {
  88. var axisModel = option;
  89. if (!(option instanceof Model)) {
  90. axisModel = new Model(option);
  91. // FIXME
  92. // Currently AxisModelCommonMixin has nothing to do with the
  93. // the requirements of `axisHelper.createScaleByModel`. For
  94. // example the methods `getCategories` and `getOrdinalMeta`
  95. // are required for `'category'` axis, and ecModel is required
  96. // for `'time'` axis. But occasionally echarts-gl happened
  97. // to only use `'value'` axis.
  98. // zrUtil.mixin(axisModel, AxisModelCommonMixin);
  99. }
  100. var scale = axisHelper.createScaleByModel(axisModel);
  101. scale.setExtent(dataExtent[0], dataExtent[1]);
  102. axisHelper.niceScaleExtent(scale, axisModel);
  103. return scale;
  104. }
  105. /**
  106. * Mixin common methods to axis model,
  107. *
  108. * Include methods
  109. * `getFormattedLabels() => Array.<string>`
  110. * `getCategories() => Array.<string>`
  111. * `getMin(origin: boolean) => number`
  112. * `getMax(origin: boolean) => number`
  113. * `getNeedCrossZero() => boolean`
  114. */
  115. export function mixinAxisModelCommonMethods(Model) {
  116. zrUtil.mixin(Model, AxisModelCommonMixin);
  117. }
  118. export { getECData };
  119. export { enableHoverEmphasis } from '../../util/states.js';
  120. export function createTextStyle(textStyleModel, opts) {
  121. opts = opts || {};
  122. return innerCreateTextStyle(textStyleModel, null, null, opts.state !== 'normal');
  123. }