![](/img/trans.png)
[英]How to add secondary Y-axis in RadCartesianChart windows store apps
[英]RadCartesianChart didn't drawn because of null values for some points
我使用Telerik RadCartesianChart,它在ObservableCollection上的ItemSource綁定。
例如,它具有3個項目:
值1 = 10
值2 =空
值3 = 20
其StrokeMode =“ AllButPlotLine”,
由於值為空,因此未繪制線。 我可以畫嗎?
問候,
RadChart(RadCartesianChart)支持空值(null / NaN)。 這是使用MVVM模式的示例,供您瀏覽。 請注意,橘子沒有任何值。
在以下位置的安裝文件夾中還有一個空值示例:Windows 8.1 XAML Q2 2014 \\ C:\\ Program Files(x86)\\ Telerik \\ UI \\ Demos \\ Examples \\ Chart \\ EmptyValues
MainPage.xaml中
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<chart:RadCartesianChart Width="700" Height="700">
<chart:RadCartesianChart.Grid>
<chart:CartesianChartGrid MajorLinesVisibility="XY" StripLinesVisibility="Y">
<chart:CartesianChartGrid.MajorXLineStyle>
<Style TargetType="Line">
<Setter Property="Stroke" Value="#B45121"/>
<Setter Property="StrokeDashArray" Value="4,2"/>
</Style>
</chart:CartesianChartGrid.MajorXLineStyle>
<chart:CartesianChartGrid.MajorYLineStyle>
<Style TargetType="Line">
<Setter Property="Stroke" Value="#58622D"/>
<Setter Property="StrokeDashArray" Value="10,2"/>
</Style>
</chart:CartesianChartGrid.MajorYLineStyle>
</chart:CartesianChartGrid>
</chart:RadCartesianChart.Grid>
<chart:RadCartesianChart.DataContext>
<local:ViewModel/>
</chart:RadCartesianChart.DataContext>
<chart:RadCartesianChart.HorizontalAxis>
<chart:CategoricalAxis/>
</chart:RadCartesianChart.HorizontalAxis>
<chart:RadCartesianChart.VerticalAxis>
<chart:LinearAxis/>
</chart:RadCartesianChart.VerticalAxis>
<chart:LineSeries ItemsSource="{Binding SeriesData}">
<chart:LineSeries.CategoryBinding>
<chart:PropertyNameDataPointBinding PropertyName="Category"/>
</chart:LineSeries.CategoryBinding>
<chart:LineSeries.ValueBinding>
<chart:PropertyNameDataPointBinding PropertyName="Value"/>
</chart:LineSeries.ValueBinding>
</chart:LineSeries>
</chart:RadCartesianChart>
</Grid>
CustomPoint.cs文件
public class CustomPoint
{
public string Category { get; set; }
public double Value { get; set; }
}
ViewModel.cs
public class ViewModel
{
public ViewModel()
{
this.SeriesData = new List<CustomPoint>()
{
new CustomPoint{ Category = "Apples", Value = 10 },
new CustomPoint{ Category = "Oranges"},
new CustomPoint{ Category = "Pears", Value = 15 },
};
}
public List<CustomPoint> SeriesData { get; set; }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.