axes_constants.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * DevExtreme (viz/axes/axes_constants.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var _map = require("../core/utils").map;
  11. module.exports = {
  12. logarithmic: "logarithmic",
  13. discrete: "discrete",
  14. numeric: "numeric",
  15. left: "left",
  16. right: "right",
  17. top: "top",
  18. bottom: "bottom",
  19. center: "center",
  20. horizontal: "horizontal",
  21. vertical: "vertical",
  22. convertTicksToValues: function(ticks) {
  23. return _map(ticks || [], function(item) {
  24. return item.value
  25. })
  26. },
  27. validateOverlappingMode: function(mode) {
  28. return "ignore" === mode || "none" === mode ? mode : "hide"
  29. },
  30. getTicksCountInRange: function(ticks, valueKey, range) {
  31. var i = 1;
  32. if (ticks.length > 1) {
  33. for (; i < ticks.length; i++) {
  34. if (Math.abs(ticks[i].coords[valueKey] - ticks[0].coords[valueKey]) >= range) {
  35. break
  36. }
  37. }
  38. }
  39. return i
  40. },
  41. areLabelsOverlap: function(bBox1, bBox2, spacing, alignment) {
  42. var horizontalInverted = bBox1.x > bBox2.x;
  43. var verticalInverted = bBox1.y > bBox2.y;
  44. var x1 = bBox1.x;
  45. var x2 = bBox2.x;
  46. var width1 = bBox1.width;
  47. var width2 = bBox2.width;
  48. if ("left" === alignment) {
  49. x1 += width1 / 2;
  50. x2 += width2 / 2
  51. } else {
  52. if ("right" === alignment) {
  53. x1 -= width1 / 2;
  54. x2 -= width2 / 2
  55. }
  56. }
  57. var hasHorizontalOverlapping = horizontalInverted ? x2 + width2 + spacing > x1 : x1 + width1 + spacing > x2;
  58. var hasVerticalOverlapping = verticalInverted ? bBox2.y + bBox2.height > bBox1.y : bBox1.y + bBox1.height > bBox2.y;
  59. return hasHorizontalOverlapping && hasVerticalOverlapping
  60. }
  61. };