This is a migrated thread and some comments may be shown as answers.

migrating to radchartview

2 Answers 73 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
stijn Ver Eecke
Top achievements
Rank 1
stijn Ver Eecke asked on 28 Aug 2014, 03:07 PM
hello, i am trying to replace my radchart with a radchartview,
but i stumble on this problem  : the lines connecting my values are not drawn ( using line series)
( i am using a DateTimeCategoricalAxis because i only want ticks for dates with actual records in my itemsource,
and don't need the distance between 2 values to be an indication of the time between, the production environment wil have multiple values on some day, and none on others, but i dont think is the cause of my problem   )
( screenshot to show the resulting window)
viewmodel :
public class ViewModel
{
public ViewModel()
{
List<TestItem> items = new List<TestItem>();
for (int i = 1 ; i< 20; i++){
var r = new TestItem();

r.Datum = DateTime.Now.AddDays(-1 * i * i /** 10 / 3*/);
if (( i % 2) == 0){
r.Waarde1 = DateTime.Now.Second / i;
}
if ((i % 3) == 0)
r.Waarde2 = DateTime.Now.Millisecond / i;
if ((i % 5) == 0)
r.Waarde3 = DateTime.Now.Second;
items.Add(r);
}
Items = items;
 }
public List<TestItem> Items { get; set; }
}

public class TestItem {

public DateTime Datum { get; set; }
public decimal? Waarde1 { get; set; }
public decimal? Waarde2 { get; set; }
public decimal? Waarde3 { get; set; }

public override string ToString()
{
return string.Format(" {0:d} : {1} - {2} - {3} ", Datum,Waarde1,Waarde2, Waarde3);
}
}

<Window x:Class="testChart.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Test="clr-namespace:testChart"
Title="MainWindow" Height="568" Width="828" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<Window.Resources>
<Test:ViewModel x:Key="Vm"/>
<SolidColorBrush x:Key="TempColor" Color="Brown" />
<SolidColorBrush x:Key="GewichtColor" Color="#FF25A0DA" />
<SolidColorBrush x:Key="PijnColor" Color="#FFFF6900" />
</Window.Resources>
<Grid DataContext="{StaticResource Vm}" Height="517" Width="783">
<telerik:RadCartesianChart HorizontalAlignment="Left" Margin="0,12,0,0" Name="radCartesianChart1" VerticalAlignment="Top" Height="465" Width="654">
<telerik:RadCartesianChart.Behaviors>
<telerik:ChartPanAndZoomBehavior />
</telerik:RadCartesianChart.Behaviors>
 <telerik:RadCartesianChart.Grid>
<telerik:CartesianChartGrid MajorLinesVisibility="XY" MajorXLineDashArray="5, 5" MajorYLineDashArray="5, 5">
 </telerik:CartesianChartGrid>
</telerik:RadCartesianChart.Grid>
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:DateTimeCategoricalAxis LineThickness="1" MajorTickInterval="1" MajorTickLength="5" TickThickness="1" LabelFormat="ddMMyyyy" LabelFitMode="Rotate" />
</telerik:RadCartesianChart.HorizontalAxis>
 <telerik:LineSeries ItemsSource="{Binding Path=Items}" CategoryBinding="Datum" ValueBinding="Waarde1" CombineMode="Stack" StrokeThickness="1" ShowLabels="True" Stroke="Red">
<telerik:LineSeries.StrokeShapeStyle>
<Style TargetType="Path">
<Setter Property="Stroke" Value="Red"/>
<Setter Property="StrokeDashArray" Value="10 5"/>
<Setter Property="StrokeThickness" Value="3"/>
</Style>
</telerik:LineSeries.StrokeShapeStyle>
<telerik:LineSeries.VerticalAxis>
<telerik:LinearAxis LineStroke="Red" Background="Red" BorderThickness="1">
  </telerik:LinearAxis>
</telerik:LineSeries.VerticalAxis>
<telerik:LineSeries.PointTemplate>
<DataTemplate>
<Ellipse Fill="AliceBlue" Height="10" Width="10"/>
</DataTemplate>
</telerik:LineSeries.PointTemplate>
</telerik:LineSeries>
<telerik:LineSeries ItemsSource="{Binding Path=Items}" StrokeThickness="10" ShowLabels="False" Stroke="Blue" CombineMode="Stack" BorderThickness="1">
<telerik:LineSeries.CategoryBinding>
<telerik:PropertyNameDataPointBinding PropertyName="Datum" />
</telerik:LineSeries.CategoryBinding>
<telerik:LineSeries.ValueBinding>
<telerik:PropertyNameDataPointBinding PropertyName="Waarde2" />
</telerik:LineSeries.ValueBinding>
<telerik:LineSeries.PointTemplate>
<DataTemplate>
<Ellipse Fill="Blue" Height="10" Width="10"/>
</DataTemplate>
</telerik:LineSeries.PointTemplate>
<telerik:LineSeries.VerticalAxis>
<telerik:LinearAxis LineStroke="Green" Background="#FF001900" BorderThickness="1" />
</telerik:LineSeries.VerticalAxis>
</telerik:LineSeries>
<telerik:LineSeries ItemsSource="{Binding Path=Items}" StrokeThickness="10" ShowLabels="True" Stroke="#FF000019">
<telerik:LineSeries.CategoryBinding>
<telerik:PropertyNameDataPointBinding PropertyName="Datum" />
</telerik:LineSeries.CategoryBinding>
<telerik:LineSeries.ValueBinding>
<telerik:PropertyNameDataPointBinding PropertyName="Waarde3" />
</telerik:LineSeries.ValueBinding>
<telerik:LineSeries.VerticalAxis>
<telerik:LinearAxis LineStroke="Red" Background="#FF001900" BorderThickness="1" />
</telerik:LineSeries.VerticalAxis>
<telerik:LineSeries.PointTemplate>
<DataTemplate>
<Ellipse Fill="Red" Height="10" Width="10"/>
</DataTemplate>
</telerik:LineSeries.PointTemplate>
</telerik:LineSeries>
</telerik:RadCartesianChart>
 </Grid>
</Window>

2 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 01 Sep 2014, 01:26 PM
Hi,

Thank you for providing us with detailed information about your scenario. It helped us to identify the cause of your issue. The reported behavior is caused by the data you are using. Please keep in mind that in order to draw a line you need at least two points. In your business data the points that are defined are alternating with null. Meaning that every second point in your data is null. This means that the chart is not able to draw any line. If you change the LineSeries with a BarSeries you will see that fact.

In order to draw the lines you can change the null value with the average value of the points surrounding the null value. For example if you have the values 2, null and 4 you can replace the null with (4+2)/2=3 and the line will be drawn.

I hope this information will help you out.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
stijn Ver Eecke
Top achievements
Rank 1
answered on 02 Sep 2014, 07:54 AM
this does not really help me,
i thought the radchartview had empty value support ,
we had no such problems with this data with the radchart.

in our data it is possible that there will be multiple empties for every value , so an average is not really feasable,
i will try to make a different datacollection for every 'value' , so that it wont contain nulls
Tags
ChartView
Asked by
stijn Ver Eecke
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
stijn Ver Eecke
Top achievements
Rank 1
Share this question
or