This is a migrated thread and some comments may be shown as answers.

Line chart not working properly.

5 Answers 56 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Mugdha Aditya
Top achievements
Rank 1
Mugdha Aditya asked on 17 Sep 2011, 08:17 PM
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 :(






5 Answers, 1 is accepted

Sort by
0
Mugdha Aditya
Top achievements
Rank 1
answered on 20 Sep 2011, 08:06 AM
any update on this?? .. :(

0
Ves
Telerik team
answered on 21 Sep 2011, 12:25 PM
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
0
Mugdha Aditya
Top achievements
Rank 1
answered on 22 Sep 2011, 02:50 PM
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)

0
Accepted
Ves
Telerik team
answered on 27 Sep 2011, 09:40 AM
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
0
Mugdha Aditya
Top achievements
Rank 1
answered on 03 Oct 2011, 11:49 AM
Hey...

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

Tags
Chart (Obsolete)
Asked by
Mugdha Aditya
Top achievements
Rank 1
Answers by
Mugdha Aditya
Top achievements
Rank 1
Ves
Telerik team
Share this question
or