YAxisLabelsLeft.as 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package elements.axis {
  2. import flash.text.TextField;
  3. public class YAxisLabelsLeft extends YAxisLabelsBase {
  4. public function YAxisLabelsLeft(json:Object) {
  5. this.lblText = "#val#";
  6. this.i_need_labels = true;
  7. super(json,'y_axis');
  8. }
  9. // move y axis labels to the correct x pos
  10. public override function resize( left:Number, sc:ScreenCoords ):void {
  11. var maxWidth:Number = this.get_width();
  12. var i:Number;
  13. var tf:YTextField;
  14. for( i=0; i<this.numChildren; i++ ) {
  15. // right align
  16. tf = this.getChildAt(i) as YTextField;
  17. tf.x = left - tf.width + maxWidth;
  18. }
  19. // now move it to the correct Y, vertical center align
  20. for ( i=0; i < this.numChildren; i++ ) {
  21. tf = this.getChildAt(i) as YTextField;
  22. if (tf.rotation != 0) {
  23. tf.y = sc.get_y_from_val( tf.y_val, false ) + (tf.height / 2);
  24. }
  25. else {
  26. tf.y = sc.get_y_from_val( tf.y_val, false ) - (tf.height / 2);
  27. }
  28. //
  29. // this is a hack so if the top
  30. // label is off the screen (no chart title or key set)
  31. // then move it down a little.
  32. //
  33. if (tf.y < 0 && sc.top == 0) // Tried setting tf.height but that didnt work
  34. tf.y = (tf.rotation != 0) ? tf.height : tf.textHeight - tf.height;
  35. }
  36. }
  37. }
  38. }