migrating to radchartview

3 posts, 0 answers
  1. stijn Ver Eecke
    stijn Ver Eecke avatar
    10 posts
    Member since:
    May 2010

    Posted 28 Aug 2014 Link to this post

    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. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 01 Sep 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. stijn Ver Eecke
    stijn Ver Eecke avatar
    10 posts
    Member since:
    May 2010

    Posted 02 Sep 2014 in reply to Pavel R. Pavlov Link to this post

    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
Back to Top