axisPointer.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 echarts = require("../echarts");
  20. var zrUtil = require("zrender/lib/core/util");
  21. var axisPointerModelHelper = require("./axisPointer/modelHelper");
  22. var axisTrigger = require("./axisPointer/axisTrigger");
  23. require("./axisPointer/AxisPointerModel");
  24. require("./axisPointer/AxisPointerView");
  25. require("./axisPointer/CartesianAxisPointer");
  26. /*
  27. * Licensed to the Apache Software Foundation (ASF) under one
  28. * or more contributor license agreements. See the NOTICE file
  29. * distributed with this work for additional information
  30. * regarding copyright ownership. The ASF licenses this file
  31. * to you under the Apache License, Version 2.0 (the
  32. * "License"); you may not use this file except in compliance
  33. * with the License. You may obtain a copy of the License at
  34. *
  35. * http://www.apache.org/licenses/LICENSE-2.0
  36. *
  37. * Unless required by applicable law or agreed to in writing,
  38. * software distributed under the License is distributed on an
  39. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40. * KIND, either express or implied. See the License for the
  41. * specific language governing permissions and limitations
  42. * under the License.
  43. */
  44. // CartesianAxisPointer is not supposed to be required here. But consider
  45. // echarts.simple.js and online build tooltip, which only require gridSimple,
  46. // CartesianAxisPointer should be able to required somewhere.
  47. echarts.registerPreprocessor(function (option) {
  48. // Always has a global axisPointerModel for default setting.
  49. if (option) {
  50. (!option.axisPointer || option.axisPointer.length === 0) && (option.axisPointer = {});
  51. var link = option.axisPointer.link; // Normalize to array to avoid object mergin. But if link
  52. // is not set, remain null/undefined, otherwise it will
  53. // override existent link setting.
  54. if (link && !zrUtil.isArray(link)) {
  55. option.axisPointer.link = [link];
  56. }
  57. }
  58. }); // This process should proformed after coordinate systems created
  59. // and series data processed. So put it on statistic processing stage.
  60. echarts.registerProcessor(echarts.PRIORITY.PROCESSOR.STATISTIC, function (ecModel, api) {
  61. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  62. // allAxesInfo should be updated when setOption performed.
  63. ecModel.getComponent('axisPointer').coordSysAxesInfo = axisPointerModelHelper.collect(ecModel, api);
  64. }); // Broadcast to all views.
  65. echarts.registerAction({
  66. type: 'updateAxisPointer',
  67. event: 'updateAxisPointer',
  68. update: ':updateAxisPointer'
  69. }, axisTrigger);