Line chart not working properly.

Thread is closed for posting
6 posts, 1 answers
  1. Mugdha Aditya
    Mugdha Aditya avatar
    71 posts
    Member since:
    Mar 2010

    Posted 17 Sep 2011 Link to this post

    I am using line charts.
    i am binding list item to chat but its not working correctly.
    Am getting 2 datatable , and trying to bind both on 1 chart. but it plotted wrong data.
    1 dataset for 1 series and 2nd for another series.

    1st Datatable having data as below which we add in 1st list.
    Q1 08 150453000
    Q2 08 158688000
    Q4 08 1515
    Q1 09 1000

    2nd Datatable having data as below which we add in 2nd list.
    Q4 08 2525
    Q1 09 2000

    1st one series its displaying correct but in 2nd there is no data for Q1 08 and Q2 08 still its plotting line chart from Q1 08  to Q2 08. it should plot from Q4 08 to Q1 09. :(

    Below is my code... if somthing is missing then plz let me know.

    for(int MainSeries = 0 ; MainSeries < 2 ; MainSeries ++)
    {
        DataTable chardata= gettingdata();
    CharSeries series = gettingseries here;
    List<String> lAxislabel = new List<String> ();

    if(chardata!=null)
    {
        foreach(DataRaw drv in chardata.Rows)
        {
            //Adding ding values to list
            lAxislabel.Add[drv[Xvalue].Tostring();
            ChartSeriesItem item = new ChartSeriesItem ();
            //Adding values fot chartseriesitem
            item.YValue  = Math.Round(double.Parce(drv[Yvalue].toString(),1);
            series.item.Add(item);
        }
    }

    if(lAxislabel.count >0 )
    {
        ChartAxisitem[] lsXAxis = new ChartAxisitem[lAxislabel.count];
        for(int i=0;i<lAxislabel.count;i++)
        {
            lsXAxis [i] = new ChartAxisitem(lAxislabel[i]);
        }

    //objChart is chart object
    objChart.Autolayout = true;
    objChart.series.Add(series);
    objChart.PlotArea.xAxis.AutoScale = false;

    if(objChart.PlotArea.xAxis.items.count = 0)
        objchart.PlotArea.xAxis.items.Addrange(lsXAxis );

      objchart.PlotArea.xAxis.LayoutMode = ChartAxisLayoutMode.inside;
      objChart.PlotArea.YAxis.AutoScale = true;

    objchart.legend.Apperance.Visible = true.
    }

    }

    Mainseries means 2 seres for which we are geeting data frm 2 different datatable.
    may be there are some speeling mistake in above code but ignore thos ebcz am typing this code here only. above code is not cpy pasted from original code. so sorry for tthat and plzzzzzz help me... why 2nd series data is coming wrong :(






  2. Mugdha Aditya
    Mugdha Aditya avatar
    71 posts
    Member since:
    Mar 2010

    Posted 20 Sep 2011 Link to this post

    any update on this?? .. :(

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 21 Sep 2011 Link to this post

    Hello Mugdha Aditya,

    The ChartSeriesItems are not aware of the axis labels. Adding an item to a ChartSeries means the item gets the next available spot. In order to place an item at a specific position along the X axis you need to set its XValue property. Eg. the item for Q1 08 should have XValue=1, the item for Q2 08 should have XValue=2 etc.

    Best regards,
    Ves
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  5. Mugdha Aditya
    Mugdha Aditya avatar
    71 posts
    Member since:
    Mar 2010

    Posted 22 Sep 2011 Link to this post

    Noo...still its not working :(

    if

     

     

    (drv["XValue"].ToString() == "Q1 08")

     item.XValue = 1;

     

     if (drv["XValue"].ToString() == "Q2 08")

     item.XValue = 2;

     

     if (drv["XValue"].ToString() == "Q4 08")

     item.XValue = 3;

     

     if (drv["XValue"].ToString() == "Q1 09")

     item.XValue = 4;

    i did this but no use... it darw some weird chart :( (Please check attachment)

  6. Answer
    Ves
    Admin
    Ves avatar
    2879 posts

    Posted 27 Sep 2011 Link to this post

    Hi Mugdha Aditya,

    Please, find attached a small example, showing this scenario.

    Best regards,
    Ves
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  7. Mugdha Aditya
    Mugdha Aditya avatar
    71 posts
    Member since:
    Mar 2010

    Posted 03 Oct 2011 Link to this post

    Hey...

    sorry for thr late reply .
    Its working fine.. thnku :)

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017