Line chart populated from uint[]

4 posts, 0 answers
  1. David
    David avatar
    22 posts
    Member since:
    Oct 2012

    Posted 16 Oct 2012 Link to this post

    Hi,

    I'm new to Telerik controls and WPF for that matter.  I have an array of uint, always will have 2048 items and I'd like to plot a line chart using the ChartView.  I cannot figure out the right combination of what type of data series and how to format the axis. This array will be updating periodically, so is there away for the chart to get updated when the array does?  Also is there a way to fill in the area beneath the line chart?

    Looking for some code snippets, or a sample project.  We are looking to buy a WPF toolkit in the very near future for up to 5 developers.

    Thanks!
  2. David
    David avatar
    22 posts
    Member since:
    Oct 2012

    Posted 16 Oct 2012 Link to this post

    I basically figured out how to populate the chart with data for a Line chart from my array:

     

     

     

    //globally defined    
    private uint[] _EDSData = new uint[2048];   
        
      
    void timer_Tick(object sender, EventArgs e) 
     
       RandomlyPopulateArray(_EDSData);      
       radCartesianChart1.Series[0].ItemsSource = null;    
       radCartesianChart1.Series[0].ItemsSource = _EDSData;    

    My XAML looks as follows:

    <telerik:RadCartesianChart Grid.Row="0"  Name="radCartesianChart1">
        
      <telerik:RadCartesianChart.HorizontalAxis>
        <telerik:CategoricalAxis MajorTickInterval="256"
                                 LabelInterval="128"
                                 ShowLabels="True"
                                 />
      </telerik:RadCartesianChart.HorizontalAxis>
        
      <telerik:RadCartesianChart.VerticalAxis>
        <telerik:LinearAxis />
      </telerik:RadCartesianChart.VerticalAxis>
        
      <telerik:RadCartesianChart.Series>
        <telerik:LineSeries Stroke="Orange"
                            StrokeThickness="2">
        </telerik:LineSeries>
          
      </telerik:RadCartesianChart.Series>
    </telerik:RadCartesianChart>

    I would like to know how I can label my X-axis, basically just the index of the data point in the array.  Also I would like to know how to fill the area under the line.

    Thanks!

  3. UI for WPF is Visual Studio 2017 Ready
  4. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 17 Oct 2012 Link to this post

    Hi David,

    how I can label my X-axis
    Try decreasing the LabelInterval. Try a value of 2 and see how it goes.

    how to fill the area under the line
    Try the AreaSeries instead of the LineSeries.

    Regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. David
    David avatar
    22 posts
    Member since:
    Oct 2012

    Posted 17 Oct 2012 Link to this post

    Thank you for your help Peter!
Back to Top