axisPointer.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var echarts = require("../echarts");
  2. var zrUtil = require("zrender/lib/core/util");
  3. var axisPointerModelHelper = require("./axisPointer/modelHelper");
  4. var axisTrigger = require("./axisPointer/axisTrigger");
  5. require("./axisPointer/AxisPointerModel");
  6. require("./axisPointer/AxisPointerView");
  7. require("./axisPointer/CartesianAxisPointer");
  8. // CartesianAxisPointer is not supposed to be required here. But consider
  9. // echarts.simple.js and online build tooltip, which only require gridSimple,
  10. // CartesianAxisPointer should be able to required somewhere.
  11. echarts.registerPreprocessor(function (option) {
  12. // Always has a global axisPointerModel for default setting.
  13. if (option) {
  14. (!option.axisPointer || option.axisPointer.length === 0) && (option.axisPointer = {});
  15. var link = option.axisPointer.link; // Normalize to array to avoid object mergin. But if link
  16. // is not set, remain null/undefined, otherwise it will
  17. // override existent link setting.
  18. if (link && !zrUtil.isArray(link)) {
  19. option.axisPointer.link = [link];
  20. }
  21. }
  22. }); // This process should proformed after coordinate systems created
  23. // and series data processed. So put it on statistic processing stage.
  24. echarts.registerProcessor(echarts.PRIORITY.PROCESSOR.STATISTIC, function (ecModel, api) {
  25. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  26. // allAxesInfo should be updated when setOption performed.
  27. ecModel.getComponent('axisPointer').coordSysAxesInfo = axisPointerModelHelper.collect(ecModel, api);
  28. }); // Broadcast to all views.
  29. echarts.registerAction({
  30. type: 'updateAxisPointer',
  31. event: 'updateAxisPointer',
  32. update: ':updateAxisPointer'
  33. }, axisTrigger);