YAxisLabelsRight.as 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package elements.axis {
  2. import flash.text.TextField;
  3. public class YAxisLabelsRight extends YAxisLabelsBase {
  4. public function YAxisLabelsRight(json:Object) {
  5. this.lblText = "#val#";
  6. this.i_need_labels = true;
  7. super(json, 'y_axis_right');
  8. }
  9. // move y axis labels to the correct x pos
  10. public override function resize( left:Number, box: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. // left 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 = box.get_y_from_val( tf.y_val, true ) + (tf.height / 2);
  24. }
  25. else {
  26. tf.y = box.get_y_from_val( tf.y_val, true ) - (tf.height / 2);
  27. }
  28. if (tf.y < 0 && box.top == 0) // Tried setting tf.height but that didnt work
  29. tf.y = (tf.rotation != 0) ? tf.height : tf.textHeight - tf.height;
  30. }
  31. }
  32. }
  33. }