axisPointer.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. import * as echarts from '../echarts';
  20. import * as zrUtil from 'zrender/src/core/util';
  21. import * as axisPointerModelHelper from './axisPointer/modelHelper';
  22. import axisTrigger from './axisPointer/axisTrigger';
  23. import './axisPointer/AxisPointerModel';
  24. import './axisPointer/AxisPointerView';
  25. // CartesianAxisPointer is not supposed to be required here. But consider
  26. // echarts.simple.js and online build tooltip, which only require gridSimple,
  27. // CartesianAxisPointer should be able to required somewhere.
  28. import './axisPointer/CartesianAxisPointer';
  29. echarts.registerPreprocessor(function (option) {
  30. // Always has a global axisPointerModel for default setting.
  31. if (option) {
  32. (!option.axisPointer || option.axisPointer.length === 0)
  33. && (option.axisPointer = {});
  34. var link = option.axisPointer.link;
  35. // Normalize to array to avoid object mergin. But if link
  36. // is not set, remain null/undefined, otherwise it will
  37. // override existent link setting.
  38. if (link && !zrUtil.isArray(link)) {
  39. option.axisPointer.link = [link];
  40. }
  41. }
  42. });
  43. // This process should proformed after coordinate systems created
  44. // and series data processed. So put it on statistic processing stage.
  45. echarts.registerProcessor(echarts.PRIORITY.PROCESSOR.STATISTIC, function (ecModel, api) {
  46. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  47. // allAxesInfo should be updated when setOption performed.
  48. ecModel.getComponent('axisPointer').coordSysAxesInfo =
  49. axisPointerModelHelper.collect(ecModel, api);
  50. });
  51. // Broadcast to all views.
  52. echarts.registerAction({
  53. type: 'updateAxisPointer',
  54. event: 'updateAxisPointer',
  55. update: ':updateAxisPointer'
  56. }, axisTrigger);