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

Setting Graph's Y-Axis Scale Programatically

2 Answers 331 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brent Hetland
Top achievements
Rank 1
Brent Hetland asked on 27 Apr 2015, 05:55 PM

Hi,

I am using Q2 2014 SP1 of Telerik Reporting.  My report contains a single Graph in the detail section, but my datasource contains alot of items that will be graphed (so I'll get one of my graphs for every item in the data source I'm binding it to).  Each of the graphs that are created, may have wildly different values.

In the cases where the values of a single graph are both very small and very large, I will want to set the Y-Axis Scale to "Logarithmic".  But the challenge is that I'll need to do that at run-time since I can't set that property in the designer (since most of the time it will be a Numeric Scale, not Logarithmic).

It doesn't seem like any of the events (ItemDataBinding, ItemDataBound, or NeedDataSource) can be used to help me do this?

So, can I change the Graph's Y-Axis Scale anywhere in the report's code behind?

Thanks,
Brent

2 Answers, 1 is accepted

Sort by
0
Brent Hetland
Top achievements
Rank 1
answered on 27 Apr 2015, 07:51 PM

I also want to add that I'm using a DateTime for the X-Axis and some of my chart data will be daily, some weekly, some monthly, etc... Currently in the designer for the chart, I have the XAxis LabelFormat set to {0:MMM-yy}, which works great when my data is Monthly.  But it is not the format I want to use for weekly and daily data.

 

So I also need to be able to set the XAxis LabelFormat property at runtime.  Where can I do this?

0
Ivan Hristov
Telerik team
answered on 29 Apr 2015, 07:06 AM
Hello Brent,

You cannot change the type of the scale at runtime, because this would mean to change the definition, which is currently processing and that is not allowed by design. However, you can create two graphs (one with a Numeric and one with a Logarithmic scale) in your details section and make one of them invisible according to your data using Bindings.

As from Q1 2015 you can set the Graph's axis label format using Bindings, which is a very handy feature in such cases. You can read more about that in this documentation article: How to: Use Bindings to Control the Coordinate System Properties.

Hope it helps.

Regards,
Ivan Hristov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
General Discussions
Asked by
Brent Hetland
Top achievements
Rank 1
Answers by
Brent Hetland
Top achievements
Rank 1
Ivan Hristov
Telerik team
Share this question
or