@@ -546,7 +546,8 @@ private void PaintTitle(ChartGraphics graph, RectangleF rect)
546
546
return ;
547
547
548
548
// Get title text
549
- string titleText = this . Text ;
549
+ string titleText = this . Text . Replace ( "\\ n" , "\n " ) ;
550
+ TextOrientation drawOrientation = GetTextOrientation ( ) ;
550
551
551
552
// Prepare string format
552
553
using StringFormat format = new StringFormat ( ) ;
@@ -598,7 +599,7 @@ private void PaintTitle(ChartGraphics graph, RectangleF rect)
598
599
}
599
600
600
601
// Measure string size
601
- SizeF size = graph . MeasureStringRel ( titleText . Replace ( " \\ n" , " \n " ) , this . Font , new SizeF ( 100 , 100 ) , format , this . GetTextOrientation ( ) ) ;
602
+ SizeF size = graph . MeasureStringRel ( titleText , this . Font , new SizeF ( 100 , 100 ) , format , drawOrientation ) ;
602
603
603
604
// Adjust text size
604
605
float zPositon = 0f ;
@@ -616,8 +617,16 @@ private void PaintTitle(ChartGraphics graph, RectangleF rect)
616
617
617
618
// Adjust text size
618
619
int index = this . Axis . ChartArea . IsMainSceneWallOnFront ( ) ? 0 : 1 ;
619
- size . Width *= size . Width / ( textSizeProjection [ index ] . X - textSizeProjection [ ( index == 0 ) ? 1 : 0 ] . X ) ;
620
- size . Height *= size . Height / ( textSizeProjection [ 2 ] . Y - textSizeProjection [ 0 ] . Y ) ;
620
+ float f = textSizeProjection [ index ] . X - textSizeProjection [ ( index == 0 ) ? 1 : 0 ] . X ;
621
+ if ( Math . Abs ( f ) < 1 )
622
+ f = f >= 0 ? 1 : - 1 ;
623
+
624
+ size . Width *= size . Width / f ;
625
+ f = textSizeProjection [ 2 ] . Y - textSizeProjection [ 0 ] . Y ;
626
+ if ( Math . Abs ( f ) < 1 )
627
+ f = f >= 0 ? 1 : - 1 ;
628
+
629
+ size . Height *= size . Height / f ;
621
630
}
622
631
623
632
@@ -688,25 +697,25 @@ private void PaintTitle(ChartGraphics graph, RectangleF rect)
688
697
rotationCenterProjection [ 0 ] . PointF = graph . GetAbsolutePoint ( rotationCenterProjection [ 0 ] . PointF ) ;
689
698
rotationCenterProjection [ 1 ] . PointF = graph . GetAbsolutePoint ( rotationCenterProjection [ 1 ] . PointF ) ;
690
699
691
- // Calcuate axis angle
692
- float angleXAxis = ( float ) Math . Atan (
700
+ // Calculate axis angle
701
+ float angleXAxis = MathF . Atan (
693
702
( rotationCenterProjection [ 1 ] . Y - rotationCenterProjection [ 0 ] . Y ) /
694
703
( rotationCenterProjection [ 1 ] . X - rotationCenterProjection [ 0 ] . X ) ) ;
695
- angleXAxis = ( float ) Math . Round ( angleXAxis * 180f / ( float ) Math . PI ) ;
704
+ angleXAxis = MathF . Round ( angleXAxis * 180 / MathF . PI ) ;
696
705
angle += ( int ) angleXAxis ;
697
706
}
698
707
}
699
708
700
709
// Draw string
701
710
using Brush brush = new SolidBrush ( this . ForeColor ) ;
702
711
graph . DrawStringRel (
703
- titleText . Replace ( " \\ n" , " \n " ) ,
712
+ titleText ,
704
713
this . Font ,
705
714
brush ,
706
715
rotationCenter ,
707
716
format ,
708
717
angle ,
709
- this . GetTextOrientation ( ) ) ;
718
+ drawOrientation ) ;
710
719
}
711
720
712
721
#endregion
0 commit comments