回复 5楼lufq的帖子
“单位:小时”测试代码如下:
- public MainWindow()
- {
- InitializeComponent();
- this.c1chart1.View.AxisX.Position = C1.WPF.C1Chart.AxisPosition.Far;
- this.c1chart1.View.AxisX.Title = "fdfdsfd";
- CreateTitle(this.c1chart1.View.AxisY, "单位:小时", new SolidColorBrush(Colors.Red));
- }
- void c1chart1_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- Random a = new Random();
- int fontsize = a.Next(10, 100);
- this.c1chart1.View.AxisX.FontSize = fontsize;
- }
- void CreateTitle(Axis ax, string text, SolidColorBrush fg)
- {
- TextBlock tb = new TextBlock()
- {
- TextAlignment = TextAlignment.Right,
- Text = text,
- HorizontalAlignment = HorizontalAlignment.Left,
- VerticalAlignment = VerticalAlignment.Top,
- Width = 80,
- RenderTransform = new RotateTransform() { Angle = 90 },
- RenderTransformOrigin = new Point(0.8, 2.9) // new Point(0.8,1.1),
- };
- if (fg != null)
- tb.Foreground = fg;
- ax.Title = new Border()
- {
- HorizontalAlignment = HorizontalAlignment.Left,
- VerticalAlignment = VerticalAlignment.Top,
- Child = tb,
- };
- }
- }
复制代码
首先需要获取屏幕分辨率,根据分辨率设置字体大小,C1Chart设置字体大小代码如下,
- this.c1chart1.View.AxisX.FontSize = fontsize;
复制代码 |