小编Fuz*_*zie的帖子

如何治愈C#winforms图表的摆动?

我在C#WPF应用程序中实现了一些实时图表,但我使用的是WinForms图表,因为它们通常很容易使用,而且性能令人惊讶.

无论如何,我已经把图表工作得很好,除了一个我无法解决的重大问题:

摇摇欲坠的图表

当我向图表添加数据时,它有时只会自行调整大小.有时它会做很多事情,给自己带来摆动,使图表超级阅读和处理烦人.

我的问题是:如何防止这个该死的图表不断调整自己?!

一些其他信息:

该图表包含在我的XAML中:

<WindowsFormsHost Grid.Row="1" Grid.ColumnSpan="2" Margin="5">
  <winformchart:Chart Dock="Fill" x:Name="Session0Chart">
    <winformchart:Chart.ChartAreas>
      <winformchart:ChartArea/>
    </winformchart:Chart.ChartAreas>
  </winformchart:Chart>
</WindowsFormsHost>
Run Code Online (Sandbox Code Playgroud)

通过以下方式初始化:

// initialize it!
chart.Palette = ChartColorPalette.Bright;

// setup the labels
Font monoSpaceFont = new Font("Consolas", 10);
chart.ChartAreas[0].AxisX.LabelStyle.Font = monoSpaceFont;
chart.ChartAreas[0].AxisY.LabelStyle.Font = monoSpaceFont;

// set the axis limits appropriately
chart.ChartAreas[0].AxisY.Maximum = 600;
chart.ChartAreas[0].AxisY.Minimum = -200;

// set up grid lines and axis styles
chart.ChartAreas[0].AxisX.MinorGrid.Enabled = true;
chart.ChartAreas[0].AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dash;
chart.ChartAreas[0].AxisX.MinorGrid.LineColor = System.Drawing.Color.Gray;
chart.ChartAreas[0].AxisX.MinorGrid.Interval = 0.04;
chart.ChartAreas[0].AxisX.LabelStyle.Format = "F2";
chart.ChartAreas[0].AxisX.LabelAutoFitStyle = …
Run Code Online (Sandbox Code Playgroud)

c# wpf charts xaml winforms

12
推荐指数
1
解决办法
515
查看次数

标签 统计

c# ×1

charts ×1

winforms ×1

wpf ×1

xaml ×1