【问题标题】:Microsoft Charting scrollable LineSeries within WPFWPF 中的 Microsoft Charting 可滚动 LineSeries
【发布时间】:2013-01-31 20:44:54
【问题描述】:

我正在使用 System.Windows.Controls.DataVisualization.Charting 在 WPF 中创建折线图 它在显示数据时工作正常。但是,取决于正在访问的数据 它变得非常凌乱和皱缩。 如果数据太宽,图表是否可以向右滚动?

这是我的 xaml 图表

            <DVC:Chart Canvas.Top="80" Grid.Column="1" Grid.Row="0" Canvas.Left="10" Name="mcChart" Background="LightSteelBlue" Height="676">

                <DVC:Chart.Series>
                    <DVC:LineSeries Title="File Count" IndependentValueBinding="{Binding Path=Key}"
                          DependentValueBinding="{Binding Path=Value}"  >

                    </DVC:LineSeries>

                </DVC:Chart.Series>

            </DVC:Chart>

从 CS 代码中,我只是将图形的数据设置为 KeyValuePair 的列表

  ((LineSeries)mcChart.Series[0]).ItemsSource = data.ToArray(); 

这是显示明显问题的图表。

如果我无法滚动,另一个选择是删除 x 轴标签。这是我的第二选择,但我也不知道该怎么做。 谢谢

【问题讨论】:

    标签: c# wpf wpftoolkit microsoft-chart-controls


    【解决方案1】:
    Remove the x axis labels 
    

    可以使用轴的AxisLabelStyle来做到这一点。

        void DrawLineChart()
        {
          var line1 = new LineSeries();
          line1.IndependentAxis = new LinearAxis(){Orientation = AxisOrientation.X,AxisLabelStyle = GetHidenAxisStyle()};
        }
    
    
        private Style GetHidenAxisStyle()
        {
            Style style = new Style(typeof(AxisLabel));
            Setter st2 = new Setter(AxisLabel.BorderBrushProperty,
                                        new SolidColorBrush(Colors.White));
            Setter st3 = new Setter(AxisLabel.BorderThicknessProperty, new Thickness(0));
            Setter st4 = new Setter(AxisLabel.TemplateProperty, null);
            style.Setters.Add(st2);
            style.Setters.Add(st3);
            style.Setters.Add(st4);
            return style;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-11
      • 2014-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多