API Docs for:
Show:

File: app/components/nf-vertical-line.js

  1. import Ember from 'ember';
  2. import HasGraphParent from 'ember-nf-graph/mixins/graph-has-graph-parent';
  3. import RequireScaleSource from 'ember-nf-graph/mixins/graph-requires-scale-source';
  4.  
  5. /**
  6. Draws a vertical line on a graph at a given x domain value
  7. @namespace components
  8. @class nf-vertical-line
  9. @extends Ember.Component
  10. @uses mixins.graph-has-graph-parent
  11. @uses mixins.graph-requires-scale-source
  12. */
  13. export default Ember.Component.extend(HasGraphParent, RequireScaleSource, {
  14. tagName: 'line',
  15.  
  16. classNames: ['nf-vertical-line'],
  17.  
  18. attributeBindings: ['lineX:x1', 'lineX:x2', 'y1', 'y2'],
  19.  
  20. /**
  21. The top y coordinate of the line
  22. @property y1
  23. @type Number
  24. @default 0
  25. @private
  26. */
  27. y1: 0,
  28.  
  29. /**
  30. The bottom y coordinate of the line
  31. @property y2
  32. @type Number
  33. @private
  34. @readonly
  35. */
  36. y2: Ember.computed.alias('graph.graphHeight'),
  37.  
  38. /**
  39. The x domain value at which to draw the vertical line on the graph
  40. @property x
  41. @type Number
  42. @default null
  43. */
  44. x: null,
  45.  
  46. /**
  47. The calculated x coordinate of the vertical line
  48. @property lineX
  49. @type Number
  50. @private
  51. @readonly
  52. */
  53. lineX: Ember.computed('xScale', 'x', function(){
  54. var xScale = this.get('xScale');
  55. var x = this.get('x');
  56. var px = xScale ? xScale(x) : -1;
  57. return px && px > 0 ? px : 0;
  58. }),
  59. });