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 182 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Dane
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
0
Dane
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");
0
Dane
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"
                    Width="800px">
                    <Legend ItemFont="Arial, 6.75pt"></Legend>
                    <YAxis Step="1">
                    </YAxis>
                    <Titles>
                        <radc:ChartTitle Text="Bar" TextFont="Arial, 9.75pt, style=Bold">
                        </radc:ChartTitle>
                    </Titles>
                    <XAxis AutoScale="False" DataLabelsColumn="hour_start" MaxItemsCount="24" LabelRotationAngle="-70"
                        ValueFormat=="None">
                    </XAxis>
                    <Series>
                        <radc:ChartSeries Name="Series 1">
                            <Appearance MainColor="199, 243, 178" SecondColor="17, 147, 7" BorderColor="DimGray">
                            </Appearance>
                            <LabelAppearance TextFont="Arial, 8pt">
                            </LabelAppearance>
                        </radc:ChartSeries>
                    </Series>
                </radc:RadChart>






this is my code behind..

ChartSeries s = RadChart2.GetChartSeries(0);
            s.Items.Clear();
            foreach (DataRow dr in dsHourlyData.Tables[0].Rows)
            {
                ChartSeriesItem item = new ChartSeriesItem();
                item.YValue = Convert.ToDouble(dr["Count"]);
                RadChart2.XAxis.AddItem(dr["hourRange"].ToString());
                s.Items.Add(item);
            }

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...

0
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
Tags
Chart (Obsolete)
Asked by
Dane
Top achievements
Rank 1
Answers by
Dane
Top achievements
Rank 1
Vladimir Milev
Telerik team
Share this question
or