如何在WPF中添加chart控件,绘制X,Y轴及动态曲线
1个回答
推荐于2017-11-27 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517196
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
我们可以使用Toolkit Chart 控件去绘制图形
添加System.Windows.Controls.DataVisualization.Toolkit.dll 引用后,XAML中可以以下面的方式使用
<Window x:Class="WpfChart3._5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
Title="MainWindow" Height="350" Width="525">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10" Grid.Column="1" Grid.Row="0">
<charting:Chart x:Name="waitingtasks" BorderBrush="Transparent" BorderThickness="0" VerticalAlignment="Stretch" Title="Waiting Tasks">
<charting:Chart.TitleStyle>
<Style TargetType="datavis:Title">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Foreground" Value="White"/>
</Style>
</charting:Chart.TitleStyle>
<charting:Chart.LegendStyle>
<Style TargetType="datavis:Legend">
<Setter Property="Width" Value="0" />
</Style>
</charting:Chart.LegendStyle>
<charting:Chart.Axes>
<charting:LinearAxis Orientation="X" Title="Time" Interval="20" ShowGridLines="False"/>
<charting:LinearAxis Title="Number of Waiting Tasks" Orientation="Y" Interval="5" ShowGridLines="False"/>
</charting:Chart.Axes>
<charting:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True"
AnimationSequence="FirstToLast"/>
</charting:Chart>
</Grid>
</Window>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询