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

radc:RadChart - Bar Chart - Display dynamic string value in label for X axix

3 Answers 185 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Dane asked on 25 Feb 2009, 11:16 PM
I,m very new to radc:RadChart.
This may be really simple thing. But still cannot do this. radc:RadChart I started today.:)  
I have a bar chart, which I need to display 24 hours in X value, but I need to display this value as string. Because this a dynamic field I'm getting from database.

as an example i need to display last 24 hours as 1 hour time gap from current time to back 24 hours.

9.34-8.34| 8.34 - 7.34 | 7.34-6.34| ...

I have this data. I just want to add this value to label and display on x axix.

For y axix I have integer value coming from same table.

My table structure as belows. It has only two columns.

count - int -> Y axix
TimeSpan - string -> X axix
Appreciate help., I'm already playing with charts..

3 Answers, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 25 Feb 2009, 11:47 PM
Ok.. i think I got it.. if I want to add these values in code behind, this is the way...
this seems Ok...

RadChart2.XAxis.AddItem("1.34 - 2.34");
            RadChart2.XAxis.AddItem("2.34 - 3.34");
            RadChart2.XAxis.AddItem("3.34 - 4.34");
Top achievements
Rank 1
answered on 26 Feb 2009, 12:43 AM
no I'm not getting correct values in chart.. :(

This is my ASPX page..,

<radc:RadChart ID="RadChart2" BarWidthPercent="90" runat="server" Height="400px"
                    <Legend ItemFont="Arial, 6.75pt"></Legend>
                    <YAxis Step="1">
                        <radc:ChartTitle Text="Bar" TextFont="Arial, 9.75pt, style=Bold">
                    <XAxis AutoScale="False" DataLabelsColumn="hour_start" MaxItemsCount="24" LabelRotationAngle="-70"
                        <radc:ChartSeries Name="Series 1">
                            <Appearance MainColor="199, 243, 178" SecondColor="17, 147, 7" BorderColor="DimGray">
                            <LabelAppearance TextFont="Arial, 8pt">

this is my code behind..

ChartSeries s = RadChart2.GetChartSeries(0);
            foreach (DataRow dr in dsHourlyData.Tables[0].Rows)
                ChartSeriesItem item = new ChartSeriesItem();
                item.YValue = Convert.ToDouble(dr["Count"]);

but this dosn't give me the exact out put as record in my data table.. :(
Appreciate some body tell me whats wrong I'm doing here...

Vladimir Milev
Telerik team
answered on 02 Mar 2009, 07:29 AM
Hello Dane,

What do you mean you are not getting correect values? The string values will appear in the order you are adding them (i.e. they will not be sorted), and in this case SeriesItem XValues will not be respected because you are supplying string data, not numeric. But besides that everything looks correct. Can you please elaborate a bit?

Sincerely yours,
Vladimir Milev
Chart (Obsolete)
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Vladimir Milev
Telerik team
Share this question