This is a migrated thread and some comments may be shown as answers.
Y-Axis formatter in KB, MB, GB, etc.
4 Answers 47 Views
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 24 Jun 2010, 10:53 PM
Is there a AxisY.DefaultLabelFormat I can specify to change raw bytes into computer storage (1024=KB, 1024^2=MB, ...) for my y-axis?  For that matter, is there any standard way to do this for generic numeric formatting (for use in RadGridView, say.)

I'm open to a custom method or IValueConverter or whatever to do the work, as long as I can get the right scale (which I can determine from the min and max Y values in the collection, if nothing else.)

Thx,
Tim

4 Answers, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 30 Jun 2010, 10:11 AM
Hi Tim,

One possible solution is to set the following in your code behind:
RadChart1.DefaultView.ChartArea.AxisX.AutoRange = false;
//Set Min, Max and Step for the AxisX
RadChart1.DefaultView.ChartArea.AxisX.AddRange(-1024, 10240, 1024);
 
RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "0,KB";

In that way you will achieve "0KB, 1KB, 2KB, ...10KB" labels. Having KB and MB at the same time on your Axis is not possible.

Please excuse us for the inconvenience caused.

All the best,
Sia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tim
Top achievements
Rank 1
answered on 30 Jun 2010, 03:10 PM
I'll give that a try, thanks.  What about if I used a logarithmic axis?  Then I might get 1KB, 10KB, 100KB, 1MB, 10MB, ... which would be nice if the range is big enough.

So far, I've been able to get 0.00GB, 0.01GB, 0.10GB, 1.0GB, 10GB, 100GB, etc.  BUT below 1.00GB the bars point down (with AutoRange=true)


Tim

0
Sia
Telerik team
answered on 02 Jul 2010, 09:32 AM
Hi Tim,

Yes, you can use logarithmic scale in your scenario. Just set
RadChart1.DefaultView.ChartArea.AxisY.IsLogarithmic = true;
and you will see the bars from the screenshot2.jpg. You can compare it with the default look from the screenshot1.jpg.

Here you can see how to format your items' labels also:
DataSeries series1 = new DataSeries()
{
   new DataPoint(1024),
   new DataPoint(10240),
   new DataPoint(102400),
   new DataPoint(1024000)
};
series1.Definition = new BarSeriesDefinition();
series1.Definition.ItemLabelFormat = "0,KB";
 
RadChart1.DefaultView.ChartArea.AxisY.IsLogarithmic = true;
 
RadChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "0,KB";
 
RadChart1.DefaultView.ChartArea.DataSeries.Add(series1);

If you need somethings else, do not hesitate to contact us again.

Greetings,
Sia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sia
Telerik team
answered on 02 Jul 2010, 09:50 AM
Hi Tim,

Just a quick followup.

In your case your step is 1024, but the ItemLabelFormat supports only the standard .NET formats. That is why all values are devided in 1000.

So, unfortunately, this approach would not be applicable for bar labels as  the formatted values differ from the true values.

All the best,
Sia
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Tim
Top achievements
Rank 1
Answers by
Sia
Telerik team
Tim
Top achievements
Rank 1
Share this question
or