0

I use Telerik RadCartesianChart, Its ItemSource binding on ObservableCollection.

For example it has 3 Items:

Value 1 = 10

Value 2 = null

value 3 = 20

Its StrokeMode ="AllButPlotLine" ,

The line didn't drawn because of the null value. Can I draw it?

Regards,

Samar ElFwakhry
  • 59
  • 1
  • 1
  • 9

1 Answers1

1

RadChart (RadCartesianChart) supports empty (null/NaN) values. Here is an example using the MVVM pattern for you to explore. Please note that there is no Value represented for Oranges.

There is also an example of Empty Values in your installation folder found here : C:\Program Files (x86)\Telerik\UI for Windows 8.1 XAML Q2 2014\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 file

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; }
}
mbcrump
  • 974
  • 3
  • 7
  • 15