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

Handling series with missing items

5 Answers 85 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 20 Feb 2009, 07:58 PM
I have a data set that I want to present as a line chart.

I've specified the x axis labels as one of the columns, a 2nd column is the datagroupcolumn and the 3rd is the value.

The issue arises because the xaxis appears to be the distinct values from the xaxis column however for some of the groups these rows don't exist and aren't plotted this results in some series the plots don't line up with the x axis correctly.

imagine this data set

x axis    Group    Value
1            1            1
2            1            2     
3            1            2     
4            1            2     
3            2            10     
4            2            11     


You will note that the group 2 doesn't have any values for x values 1 and 2. The chart however seems to plot by index value and not by x axis value. i.e. at the nth position of the axis it plots group[i].value[n], so in the data above for xaxis 1 we get Group 1 =1 and Group2 = 10.

Apart from filling in all the gaps in the dataset what can be done.

5 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 23 Feb 2009, 07:19 AM
Hi Simon,

Indeed, by default RadChart plots its items by index value. You can force an item to a certain X position by setting its XValue. For databound chart you need to set the DataXColumn property of the ChartSeries. However, when grouping is applied you cannot have pre-defined series. In this case you need to use the DataManager. You can set its ValuesXColumn, so that the auto-created series will use this column/field name to populate the XValue property of their items. Here is an example:

        DataTable tbl = new DataTable(); 
        DataColumn col = new DataColumn("XValue"); 
        col.DataType = typeof(double); 
        tbl.Columns.Add(col); 
        col = new DataColumn("Group"); 
        col.DataType = typeof(double); 
        tbl.Columns.Add(col); 
        col = new DataColumn("YValue"); 
        col.DataType = typeof(double); 
        tbl.Columns.Add(col); 
 
        tbl.Rows.Add(new object[] { 1, 1, 1 }); 
        tbl.Rows.Add(new object[] { 2, 1, 2 }); 
        tbl.Rows.Add(new object[] { 3, 1, 2 }); 
        tbl.Rows.Add(new object[] { 4, 1, 2}); 
        tbl.Rows.Add(new object[] { 3, 2, 10 }); 
        tbl.Rows.Add(new object[] { 4, 2, 11 }); 
 
        RadChart1.DataSource = tbl; 
        RadChart1.DataGroupColumn = "Group"
        RadChart1.DataManager.ValuesXColumn = "XValue"
        RadChart1.DataBind(); 

Hope this helps.

Regards,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Simon
Top achievements
Rank 1
answered on 24 Feb 2009, 02:05 PM
I've tried your suggestion and I get "The type of column with name  DaysTil is not numeric"

The datasource is an array of type 

class

 

RegRate { public int ConferenceId { get; set; } public double DaysTil { get; set; } public int Count { get; set; } public int Attended { get; set; } public double AttendedRate { get; set; } }

I've tried double, int and decimal and all the same.

 

0
Ves
Telerik team
answered on 27 Feb 2009, 07:41 AM
Hello Simon,

I am afraid you have hit a bug in RadChart. There should not be any difference between binding to an array or to another datasource. Unfortunately, this is not the case at the moment, so this type of binding is not available for arrays. Still, if you use a List you will be able to apply this approach.

Sincerely,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Simon
Top achievements
Rank 1
answered on 27 Feb 2009, 10:10 AM
If I use a datatable I can still get the same error. This is the scenario I get

My data set needs to be order by the grouping value in order to be able to generate running totals.

If I then use that in the chart, the x values aren't sorted.

If I then order the data by the x value  I get the same column is not a numeric value error.
0
Ves
Telerik team
answered on 02 Mar 2009, 02:31 PM
Hello Simon,

We are not currently aware of such issues. Can you please open a formal support ticket and attach a small runnable page, showing this behavior. Please, include the details about the desired scenario and the expected result, so we can debug it locally and provide further assistance.

All the best,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Chart (Obsolete)
Asked by
Simon
Top achievements
Rank 1
Answers by
Ves
Telerik team
Simon
Top achievements
Rank 1
Share this question
or