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

Multi Series RadBarChart incorrect x- points

2 Answers 55 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Renee
Top achievements
Rank 1
Renee asked on 30 Oct 2012, 07:27 PM
I have a bar chart with multiple series. When I have only one series, the bar shows up on the correct X Point. When I add a second series, the bar will no longer sit on its proper x point.

The images below graphandline.png and 2graphandline.png show the bar chart before and after the second series is added. You will notice that the first graph shows a point after 10/24. When a second series is added, that 10/24 point moves to the left of the 10/23 mark on the x axis. The third chart 3graphandline.png shows the graphs after manually setting the range and steps. As you can see, the x points are sitting between days. This graph is databound with the following code

chartResults.DataManager.ValuesXColumn = "iDate"

chartResults.DataGroupColumn = "sType"

chartResults.PlotArea.XAxis.Appearance.ValueFormat = Styles.ChartValueFormat.ShortDate

chartResults.DataSource = dt

 
The snippet below is a sample of data being added to the data table. It converts the date to an object, as suggested in the online documentation.

fValue = rdr("sValue").ToString

Dim dDate As DateTime = rdr("dStartDateTime")
Dim oDate As Date = New Date(dDate.Year, dDate.Month, dDate.Day)

Dim oRow As DataRow = dt.NewRow
oRow("fValue") = fValue
oRow("iDate") = oDate.ToOADate()     
oRow("sDate") = rdr("dStartDateTime").ToString
oRow("sType") = sDrug
dt.Rows.Add(oRow)

Is there something I am missing, or doing wrong. The goal is to have the x points from series 1 remain on the correct x point when another series is added. Any advice, or suggestions are appreciated.

Many thanks in advance!

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 02 Nov 2012, 12:27 PM
Hi,

As you have already found RadChart does not handle DateTime values natively. That is why they should be converted to double. Now, two adjacent days would have double values that differ by 1. So, when XAxis.AutoScale is true RadChart calculates certain range, but it is not guaranteed, that the all ticks will appear for specific time of the day. In order to get a better understanding of this, please set RadChart.PlotArea.XAxis.Appearance.CustomFormat to something that includes time e.g. "MMMM/yy/dd hh:mm" If the labels are too long and not entirely visible, please set RadChart.AutoLayout to true. Now, with the above custom format you should actually find that it is not the bar that moves, but the ticks as they are not guaranteed to match midnight or another fixed moment of the day.

The solution here would be to use AutoScale=false and custom axis range. You have already tried this and the bar does not match the tick. One possible reason would be the actual DateTime value of the item. If the axis range is calculated, so that the ticks match midnight, but the item's XValue matches noon, the bar would appear off the tick. The solution would be to adjust (actually to floor) the Bar's XValue - you can hook ItemDataBound event of the chart for this.


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
John Willey
Top achievements
Rank 1
answered on 12 Nov 2012, 03:36 PM
Setting the Scale manually did not work either. I had initially been setting the BarWidthPercent at the series level. Once I set it at the control level, the issue was resolved.

The following line of code to fixed the problem
RadChart.PlotArea.Chart.Appearance.BarWidthPercent= 1


Many thanks for the help!
Tags
Chart (Obsolete)
Asked by
Renee
Top achievements
Rank 1
Answers by
Ves
Telerik team
John Willey
Top achievements
Rank 1
Share this question
or