Invalid code in documentation.

9 posts, 0 answers
  1. Nick
    Nick avatar
    19 posts
    Member since:
    Oct 2011

    Posted 07 Dec 2011 Link to this post

    Just so you know, there are multiple errors here: http://www.telerik.com/help/wpf/radchartview-axes-datetimeaxes.html (XAML and VB).
  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 08 Dec 2011 Link to this post

    Hello Nick,

    Indeed you are correct -- we will forward your feedback to our techincal writers so they can review and update the help topic(s).

    Here is the correct code for your reference:

    XAML
    <UserControl x:Class="SilverlightApplication16_vb.MainPage"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
     
        <Grid x:Name="LayoutRoot" Background="White">
     
            <telerik:RadCartesianChart x:Name="chart">
                <telerik:RadCartesianChart.HorizontalAxis>
                    <telerik:DateTimeContinuousAxis LabelFitMode="MultiLine"
                                        LabelFormat="MMM yyyy"/>
                </telerik:RadCartesianChart.HorizontalAxis>
     
                <telerik:RadCartesianChart.VerticalAxis>
                    <telerik:LinearAxis/>
                </telerik:RadCartesianChart.VerticalAxis>
     
                <telerik:RadCartesianChart.Series>
                    <telerik:LineSeries Stroke="Orange" StrokeThickness="2"/>
                </telerik:RadCartesianChart.Series>
                 
            </telerik:RadCartesianChart>
     
        </Grid>
    </UserControl>

    VB.NET
    Imports Telerik.Windows.Controls.ChartView
     
    Partial Public Class MainPage
        Inherits UserControl
     
        Public Sub New()
            InitializeComponent()
     
            Dim lastDate As DateTime = DateTime.Now
            Dim lastVal As Double = 20
     
            Dim dataSource As List(Of ChartDataObject) = New List(Of ChartDataObject)
            For i As Integer = 0 To 5 Step 1
                Dim obj As ChartDataObject = New ChartDataObject
                obj.[Date] = lastDate.AddMonths(1)
                obj.Value = lastVal
                dataSource.Add(obj)
     
                lastVal += 1
                lastDate = obj.[Date]
            Next
     
            Dim series As LineSeries = DirectCast(Me.chart.Series(0), LineSeries)
     
            Dim categoryBinding As PropertyNameDataPointBinding = New PropertyNameDataPointBinding
            categoryBinding.PropertyName = "Date"
     
            Dim valueBinding As PropertyNameDataPointBinding = New PropertyNameDataPointBinding
            valueBinding.PropertyName = "Value"
     
            series.CategoryBinding = categoryBinding
            series.ValueBinding = valueBinding
            series.ItemsSource = dataSource
        End Sub
     
    End Class
     
    Public Class ChartDataObject
        Dim _date As Date
        Dim _value As Double
     
        Public Property [Date]() As DateTime
            Get
                Return Me._date
            End Get
            Set(value As DateTime)
                Me._date = value
            End Set
        End Property
     
        Public Property Value() As Double
            Get
                Return Me._value
            End Get
            Set(value As Double)
                Me._value = value
            End Set
        End Property
    End Class

    We have updated your Telerik points as well.


    Best wishes,
    Giuseppe
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Nick
    Nick avatar
    19 posts
    Member since:
    Oct 2011

    Posted 08 Dec 2011 Link to this post

    Thanks.  Unfortunately, the code still does not run.  I get:  "The property 'Stroke' does not exist in XML namespace 'http://schemas.telerik.com/2008/xaml/presentation" on the XAML side.  

    If I remove those attributes (just to get passed that error), the VB throws the error: 'Add value to collection of type 'Telerik.Windows.Controls.ChartView.PresenterCollection(Telerik.Windows.Controls.ChartView.CartesianSeries)' threw an exception.' Line number '23' and line position '22'.

  5. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 08 Dec 2011 Link to this post

    Hello Nick,

    We double-checked the code and it works as expected on our end -- we have attached runnable sample projects (WPF/SL) for your reference.

    Hope this helps.


    Regards,
    Giuseppe
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Nick
    Nick avatar
    19 posts
    Member since:
    Oct 2011

    Posted 08 Dec 2011 Link to this post

    Same errors for me after copying/pasting your code.  Could this be a result of having Q1, Q2 and Q3 installed at the same time?
  7. Nick
    Nick avatar
    19 posts
    Member since:
    Oct 2011

    Posted 08 Dec 2011 Link to this post

    OK.  Found the problem.  The code samples do not work if you have a reference to both Telerik.Windows.Controls.Charting and Telerik.Windows.Controls.Chart in the same project.  The problem stems from the fact that there is ambiguity between the Charting and Chart references that are not handled in the sample/example code.  This is a problem for me particularly because I am in the process of replacing the Charts in my project with the ChartView control to see if that alleviates the memory leak that occurs when using the Chart control.
  8. Nick
    Nick avatar
    19 posts
    Member since:
    Oct 2011

    Posted 08 Dec 2011 Link to this post

    OK, I have successfully swapped out theChart with the ChartView.  Without making any other changes, the application (which streams real-time data) is at least 5x faster!  

    In my old setup, I had tooltips, pointmarks, etc. all turned off on the chart controls, which were bound to observable collections and I limited the sampling to 6000 (10 minutes of rolling data).   The application would always crash on my machine after about 1.5-2 hours streaming the data (outofmemoryexception).   I tried everything-- even automatically calling gc.collect every 10 seconds.  Nothing quelled the Chart controls' hunger for more and more memory.  

    This control, although only in beta, is leaps and bounds faster at real-time data.  Kudos to you,Telerik.  You have officially resolved the last major hurdle we had to ship our SCADA software (which also uses your treeview, griview, menu, map and input controls).

    A minor question I still had was, how do I change the color of the X and Y axis labels?  I can seem to find that in the documentation.

    Thanks!
  9. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 09 Dec 2011 Link to this post

    Hi Nick,

    You can achieve the desired effect by setting the Axis.LabelStyle property like this:
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <Style x:Key="LabelStyle" TargetType="TextBlock">
                <Setter Property="Foreground" Value="Red" />
            </Style>
        </Grid.Resources>
     
        <telerik:RadCartesianChart x:Name="RadChart1">
            <telerik:BarSeries>
                <telerik:BarSeries.DataPoints>
                    <telerik:CategoricalDataPoint Value="2" />
                    <telerik:CategoricalDataPoint Value="1" />
                    <telerik:CategoricalDataPoint Value="4" />
                    <telerik:CategoricalDataPoint Value="5" />
                    <telerik:CategoricalDataPoint Value="6" />
                </telerik:BarSeries.DataPoints>
            </telerik:BarSeries>
     
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:CategoricalAxis LabelStyle="{StaticResource LabelStyle}" />
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis LabelStyle="{StaticResource LabelStyle}" />
            </telerik:RadCartesianChart.VerticalAxis>
        </telerik:RadCartesianChart>
    </Grid>

    Hope this helps.


    All the best,
    Giuseppe
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  10. Denis
    Denis avatar
    2 posts
    Member since:
    Mar 2009

    Posted 31 Jan 2013 Link to this post

    Thx for the solution.
Back to Top
UI for WPF is Visual Studio 2017 Ready