WPF Toolkit 之 AreaSeries chart with DateTime Axis

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、付费专栏及课程。

余额充值