WPF Toolkit 之 AreaSeries chart with DateTime Axis

本文介绍如何在WPF Toolkit的图表中隐藏每个数据点的物理显示,并设置不透明度及背景样式。通过修改AreaSeries的数据点样式可以实现这一效果。此外,还展示了如何配置时间轴标签的显示格式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

By default, the WPF Toolkit chart displays physical points for each datapoint in the series. You can turn this off by setting the data point style:

				var newSeries = new AreaSeries()
				                	{
										Title = categoryToAllocationList.Key,
										Opacity = 1,
										IndependentValuePath = "TimeSpan",
				                		DependentValuePath = "AllocatedCores",
                                        ItemsSource = categoryToAllocationList.Value,
				                		HorizontalContentAlignment = HorizontalAlignment.Left
				                	};
			    
                //Don't display physical points for each data point
				var dataPointOpacitySetter = new Setter(OpacityProperty, 0.0);
				var backgroundSetter = new Setter(BackgroundProperty, brushes[count]);
				newSeries.DataPointStyle = new Style(typeof (AreaDataPoint))
				                           	{
												Setters = { dataPointOpacitySetter, backgroundSetter }
				                           	};

                //Make sure the color is not transparent among multiple area serieses
				var pathOpacitySetter = new Setter(OpacityProperty, 1.0);
				newSeries.PathStyle = new Style(typeof (Path))
				                      	{
											Setters = { pathOpacitySetter }
				                      	};
				
				myGridUsageChart.Series.Add(newSeries);

Please note TimeSpan property must be DateTime type.

<DVC:Chart Name="myXXXChart" Title="XXX Chart" 
                  LegendTitle="XXX XXX" Margin="8,12,12,17" Grid.Column="1">
            
            <DVC:Chart.Axes>
                <DVC:DateTimeAxis Orientation="X" IntervalType="Hours" Interval="1">
                    <DVC:DateTimeAxis.AxisLabelStyle>
                        <Style TargetType="DVC:DateTimeAxisLabel">
                            <Setter Property="StringFormat" Value="{}{0:HH:mm}" />
                        </Style>
                    </DVC:DateTimeAxis.AxisLabelStyle>
                </DVC:DateTimeAxis>
                <DVC:LinearAxis Orientation="Y" ShowGridLines="False" 
                                Visibility="Visible" />
            </DVC:Chart.Axes>
            <DVC:Chart.Series>
                <DVC:AreaSeries Title="Series 1" IndependentValuePath="TimeSpan" DependentValuePath="AllocatedCores" Background="Orange" >
                </DVC:AreaSeries>

                <DVC:AreaSeries Title="Series 2" IndependentValuePath="TimeSpan" DependentValuePath="AllocatedCores" Background="Green" >
                    
                </DVC:AreaSeries>
            </DVC:Chart.Series>
        </DVC:Chart>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值