Line Chart Series from Data?

Thread is closed for posting
6 posts, 0 answers
  1. Aaron
    Aaron avatar
    38 posts
    Member since:
    Apr 2008

    Posted 22 Jul 2010 Link to this post

    I'm trying to create a line chart that appears similar to the following screenshot, which I did in Excel. 

    Basically, as you can see, the first column contains the location ID.  For each unique Location ID, the chart should generate a new series.  The data for that series then appears in column 2 (date) and column 3 (tempurature).

    Is there anyway to do this with Rad Chart?

    Thanks.

    Aaron
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 27 Jul 2010 Link to this post

    Hello Aaron,

    One possible option to handle this setup would be to use two line series, one for each data group. This is demonstrated in the screenshot attached to this message.
    You can plot the data declaratively:

    <Series>
                               <telerik:ChartSeries Name="Series 1" Type="Line">                           
                                   <Items>
                                       <telerik:ChartSeriesItem YValue="63" Name="Item 1">
                                       </telerik:ChartSeriesItem>
                                       <telerik:ChartSeriesItem YValue="45" Name="Item 2">
                                       </telerik:ChartSeriesItem>
                                       <telerik:ChartSeriesItem YValue="66" Name="Item 3">
                                       </telerik:ChartSeriesItem>
                                       <telerik:ChartSeriesItem YValue="78" Name="Item 4">
                                       </telerik:ChartSeriesItem>
                                       <telerik:ChartSeriesItem YValue="34" Name="Item 5">
                                       </telerik:ChartSeriesItem>
                                   </Items>
                               </telerik:ChartSeries>
                               <telerik:ChartSeries Name="Series 1" Type="Line">                           
                                   <Items>
                                       <telerik:ChartSeriesItem YValue="23" Name="Item 1">
                                       </telerik:ChartSeriesItem>
                                       <telerik:ChartSeriesItem YValue="67" Name="Item 2">
                                       </telerik:ChartSeriesItem>
                                       <telerik:ChartSeriesItem YValue="89" Name="Item 3">
                                       </telerik:ChartSeriesItem>
                                       <telerik:ChartSeriesItem YValue="56" Name="Item 4">
                                       </telerik:ChartSeriesItem>
                                       <telerik:ChartSeriesItem YValue="37" Name="Item 5">
                                       </telerik:ChartSeriesItem>
                                   </Items>
                               </telerik:ChartSeries>
                           </Series>

    or use a datasource to populate the data:

    http://www.telerik.com/help/aspnet-ajax/buildingdatabinddatabase.html

    I hope this information gets you started properly.

    Greetings,
    Yavor
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Aaron
    Aaron avatar
    38 posts
    Member since:
    Apr 2008

    Posted 27 Jul 2010 Link to this post

    Thanks, Yavor, for the reply.

    I do get how I would go about adding series to the graph programmatically.  What I don't get, and what isn't apparent from the tutorial you sent me the link to, is how I can tell RadChart how to add the series automatically from distinct values in a particular column, in this case Location. 

    Thanks.

    Aaron
  4. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 28 Jul 2010 Link to this post

    Hello Aaron,

    In order to ensure the proper mapping between the data and the series, you can add a series for each data field, as in the example suggested earlier:

    RadChart1.Series[0].DataYColumn = "TotalSales";
               RadChart1.PlotArea.XAxis.DataLabelsColumn = "CategoryName";
               // assign appearance related properties
               RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 300;
               RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color =
               System.Drawing.Color.BlueViolet;
               RadChart1.PlotArea.Appearance.Dimensions.Margins.Bottom =
               Telerik.Charting.Styles.Unit.Percentage(30);
               // bind to the datasource
               RadChart1.DataBind();

    Let me know how this approach meets your requirements.

    All the best,
    Yavor
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Aaron
    Aaron avatar
    38 posts
    Member since:
    Apr 2008

    Posted 03 Aug 2010 Link to this post

    Hi Yavor,

    Thanks again for all of your help.

    I actually don't want to add a series for multiple columns.  All my series come from one column. 

    I want the series to come from the distinct values in a foreign key field.  In other words, if my locationID field is a foreign key to another table (in this case, a table called Locations), and it contains values like {7,7,7,12,12,31,31,31} I would want 3 different series to show up on the graph: one for all the Y values associated with the 7 key, one for the 12's and one for the 31's. 

    Thanks!

    Aaron
  6. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 06 Aug 2010 Link to this post

    Hi Aaron,

    You can use the DataGroupColumn feature to achieve the desired effect.

    Hope this helps.


    Greetings,
    Freddie
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top