I am using the DataBind method, so I am not adding the X and Y values manually.
I need a way of find out out how many labels are present on each axis so I can dymanically set the labelstep value. For Example, if there are 12 x-axis labels then I want the labelstep for the X axis to be 1. If there are 300 then I want it to be 300/30 (or whatever).
It seems like this must be easy, but I am missing something.
Thanks,
Mike
10 Answers, 1 is accepted
You can easily obtain the current number of labels generated on each axis through the radChart1.PlotArea.XAxis.Items.Count and .Yaxis.Items.Count properties. That number, however, depends on the LabelStep property as only the required number of labels are generated.
To aquire the correct number of data points, you just need to retrieve it from this.radChart1.Series[0].Items.Count. This will solve the problem for X axis, but I am not sure what you need as information on the Y axis. Usually, the Y axis automatically scales itself, searching for the optimum number of labels and optimum range to correctly represent the given range.
All the best,
Evtim
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
The x-axis is solved, but the Y axis is still a problem. I did try setting AutoScale to "true" for the Y Axis, but that is not working.
I am thinking that the following would work:
- Let's assume that I want no more than 60 labels on the axis.
- Set the Y labelstep to 1.
- Find the max and min Y values by looping though each series, and subtract the min from the max. This would give me the total number of labels on the Y axis if the labelstep were 1.
- Take that number and divide by 60 (our max label setting)
- So lets say the min is 0 and the max is 300. Then we do (300-0)/60 = 5. We now set labelstep for the Y axis to 5.
So, my questions are as follows:
- Is this the best approach?
- How can I get the max and min values for any given series?
Currently, the RadChart does not expose API for retrieving the Min/Max values from the series. So, I would say your approach is correct.
I suggest setting the steps on the DataBound event (if you use data binding). That will ensure the data is initialized.
Regards,
Evtim
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
In an earlier reply you said, "Usually, the Y axis automatically scales itself, searching for the optimum number of labels and optimum range to correctly represent the given range." How can I get this to happen? It sounds as if you are describing an "automated" labelstep value. What might I be missing?
Yes, you are correct, the RadChart does not allow using AutoScale and Scale breaks together.
Best,
Evtim
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
I have AxisMode set to Extended, it display fine even when largest Y-Axis bar is almost full ( since mode is extened )
But when I set ScaleBreaks to true, the AxisMode = Extended does not seem to work, my item label is displaying in the bar and was covered partially by the scalebreak curve line.
What's the way to achieve what I want to do?
Please help.
Thanks
With AutoScale set to true the algorithm usually manages to produce the axis segments so that there is enough space above the largest bar. If AutoScale is set to false you can add AxisSegment objects to YAxis.ScaleBrakes.Segments collection manually, providing the desired configuration for MinValue, MaxValue and Step.
Best regards,
Ves
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
For i = 0 To dtcolumn.Tables(1).Rows.Count - 1
For k = 0 To dt.Rows.Count - 1
If (dtcolumn.Tables(1).Rows(i)("mintime")) = (dt.Rows(k)("time")) Then
dt.Rows(k)(cumul) = Math.Round(dtcolumn.Tables(1).Rows(i)(
"cumulative"), 2)
' RadChart1.Series(1).AddItem(dt.Rows(k)(cumul))
End If
Next
Next
RadChart1.Series(0).DataYColumn =
"incs"
RadChart1.Series(1).DataYColumn =
"cumula"
RadChart1.Series(1).Appearance.FillStyle.MainColor = Drawing.Color.Red
' 'RadChart1.PlotArea.XAxis.DataLabelsColumn = "time"
For i = 0 To dt.Rows.Count - 1
RadChart1.PlotArea.XAxis.AddItem(
CDate(dt.Rows(i)("time")))
'RadChart1.Series().
Next
' RadChart1.PlotArea.XAxis.MaxValue = 60
'RadChart1.PlotArea.XAxis.MinValue = 0
RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Styles.ChartValueFormat.LongTime
'RadChart1.PlotArea.XAxis.Appearance.CustomFormat = "hh:mm:ss"
RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.Black
RadChart1.PlotArea.XAxis.LabelStep = 5
RadChart1.PlotArea.XAxis.AutoScale =
FalseMAny thanks in Advance
When configuring the X axis manually for DateTime values, you need to use their OLEAutomation equivalents. You can use the DateTime.ToOADate method for this purpose. You can find such example here.
Regards,
Ves
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.