Source: axis/AxisDefs.js

  1. /**
  2. * @module AxisDefs
  3. * @description This module contains global axis members
  4. */
  5. export {
  6. AxisDefs,
  7. AxisLocation
  8. };
  9. /**
  10. * @enum
  11. */
  12. var AxisDefs = {
  13. X_AXIS_INDEX: 0,
  14. Y_AXIS_INDEX: 1,
  15. }
  16. /**
  17. * @enum {String}
  18. * @readonly
  19. */
  20. var AxisLocation = {
  21. /**
  22. * @member {String}
  23. * @description X axis above the plot body
  24. **/
  25. X_AXIS_TOP : "xTop",
  26. /**
  27. * @member {String}
  28. * @description Y axis to the left of the plot body
  29. **/
  30. Y_AXIS_LEFT : "yLeft",
  31. /**
  32. * @member {String}
  33. * @description X axis below the plot body
  34. **/
  35. X_AXIS_BOTTOM : "xBottom",
  36. /**
  37. * @member {String}
  38. * @description Y axis to the right of the plot body
  39. **/
  40. Y_AXIS_RIGHT : "yRight",
  41. }
  42. /**
  43. * Test the validity of any axis location string
  44. * @throws Error if the string does not match any value in {@link AxisLocation}
  45. * @param {String} location Location to test
  46. * @return void
  47. */
  48. export function testAxisLocation(location) {
  49. const values = Object.values(AxisLocation);
  50. if (values.indexOf(location) === -1) {
  51. throw Error(`Unrecognized axis location ${location}. Choose from ${values.join(", ")}`);
  52. }
  53. }