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

Y axis questions

12 Answers 163 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 23 Oct 2010, 12:30 AM
Hi,

A couple of questions about the Y axis:

1. On a line chart, we need the Y axis range to be reversed, so that 0 is at the top and (say) 5000 is at the bottom. Can this be done? We'd ideally like to keep AutoRange switched on so that we don't need to calculate the maximum value.

2. On another line chart, we need the Y axis to be labelled with a set of strings rather than numbers. The graph shows the cumulative time taken by a set of tasks. For example, the task "Write proposal" (on the Y axis) needs to be against the number 4.5 days (X axis). I think this is satisfied by categorical charts, except can the strings be on the Y axis instead of the X axis?

Many thanks

Ed

12 Answers, 1 is accepted

Sort by
0
Thomas Kroll
Top achievements
Rank 1
answered on 25 Oct 2010, 06:45 PM
I've satisfied your #1 question by multiplying all the y-axis values by -1.  But the problem is now the labels are preceded by a - symbol.

My question is, how do you get rid of the - symbol after multiplying all the values by -1?

Thanks in advance to all that help!
0
Evgenia
Telerik team
answered on 27 Oct 2010, 08:31 AM
Hello,

1. You can set reverse order for axis Y labels with this approach:
Subscribe for ItemDataBound event of the chart and then make series items' YValue negative like this:
private void RadChart1_ItemDataBound(object sender, Telerik.Windows.Controls.Charting.ChartItemDataBoundEventArgs e)
       {
           e.DataPoint.YValue = -e.DataPoint.YValue; 
       }

This will affect the axis too - it will show negative values with 0 at the top. The key in the clue is to set Custom Format Strings (http://msdn.microsoft.com/en-us/library/0c899ak8.aspx) to the property DefaultLabelFormat of the YAxis.
What you need is the "##;##;0" custom format - this will suppress the "-" sign for negative values and will show 0 as start tick. You can set it like this:
RadChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{##;##;0}";
Additionaly you can reformat the way DataPoints's Labels appear (as they will appear as negative) or hide them. Here is how to format them:
RadChart1.DefaultSeriesDefinition.ItemLabelFormat = "#Y{##;##;0}";
NOTE that format expressions for AxisY and ItemLabels are different. This is described in our help article - http://www.telerik.com/help/silverlight/radchart-features-format-expressions.html.

@Thomas - you can get rid of the "-" sign by using same CustomFormat as mentioned above.
Have in mind that this approach won't work for BarSeries for example as they will appear as negative values - turned down.

2. To be able to set custom labels for RadChart you should follow this help topic - http://www.telerik.com/help/silverlight/chart-custom-labels.html.

Kind regards,
Evgenia
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
Thomas Kroll
Top achievements
Rank 1
answered on 27 Oct 2010, 03:22 PM
Thank you, that is indeed EXACTLY what I was looking for.

Once again, the Telerik support beats everyone hands down.
0
Courouble Damien
Top achievements
Rank 1
answered on 29 Dec 2010, 04:54 PM
Hey guys,

I've test this workaround with sucess but what about changing the Step when this reverse is apply ?

I'm mean if I have an axis Y from 0 to 10 (0 is a the bottom) with a step of 1, if I apply this reverse 'effect' i'm gonna have 0 on top and 10 on the bottom, and now if i change the step from 1 to 2, the 0 is gonna desappear because the step begin a the bottom ..

Is there a way to fix that ??

Thanks,

Damien
0
Evgenia
Telerik team
answered on 30 Dec 2010, 03:45 PM
Hi Courouble,

You can find a sample project attached reproducing the Reverse Y Axis workaround. The step for Y Axis is set to 2 as you mentioned and everything is vizualized as expected. Note that the MinValue is -10 and the MaxValue is 0 - no matter that the "-" sign is supressed from the Y Axis labels the values on the axis are negative.
If you change the Step to 3 for example the 0 dissapears and this is expected behavior cause the Step starts to increase from the MinValue which is -10. If you want to see the 0 - just change this MinValue to -12 for example. 

Regards,
Evgenia
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Kristian Kretschmer
Top achievements
Rank 1
answered on 15 Aug 2011, 02:17 PM
How can I reverse the Y axis when I manual add the DataSeries?
The ItemDataBound Event is not firing in this case.
0
Evgenia
Telerik team
answered on 15 Aug 2011, 02:48 PM
Hello Kristian,

Since our latest Release we have implemented Inverse Axis feature. Now it's much more easier to achieve the required functionality with just setting the IsInverse property of the AxisY to true. A sample demonstrating it is available online. Please note that the way RadChart is populated with data (databound or not) doesn't matters to the Inverse Axis feature.

Best wishes,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Kristian Kretschmer
Top achievements
Rank 1
answered on 15 Aug 2011, 02:57 PM
We still use the Q3 2010 SP1 release.
0
Evgenia
Telerik team
answered on 16 Aug 2011, 02:02 PM
Hello Kristian,

In this case - where the Chart is populated with data manually, and you can't wire to ItemDataBound event you can loop through the items of  the DataSeries and change the YValue like this:

InitializeComponent();
            DataSeries lineSeries = new DataSeries();
            lineSeries.Definition = new LineSeriesDefinition();
  
            lineSeries.Add(new DataPoint() { YValue = 10 });
            lineSeries.Add(new DataPoint() { YValue = 6 });
            lineSeries.Add(new DataPoint() { YValue = 8 });
            lineSeries.Add(new DataPoint() { YValue = 0 });
  
            RadChart1.DefaultView.ChartArea.DataSeries.Add(lineSeries);
  
            RadChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{##;##;0}";
            RadChart1.DefaultView.ChartArea.DataSeries[0].Definition.ItemLabelFormat = "#Y{##;##;0}";
  
            RadChart1.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Inside;
            for (int i = 0; i < RadChart1.DefaultView.ChartArea.DataSeries[0].Count; i++)
            {
                RadChart1.DefaultView.ChartArea.DataSeries[0][i].YValue = -RadChart1.DefaultView.ChartArea.DataSeries[0][i].YValue;
            }

Please have in mind that this improvised workaround won't work for Bar Series as I described in my previous posts.
I still suggest that you download the latest version of our controls (Q2 2011) and use the official Inverse Axis feature which is tested and works for Bar Series.

Greetings,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Neeraj
Top achievements
Rank 1
answered on 13 Sep 2011, 08:40 AM
I need Reverse my X Axis which is DateTime column. Since this is a date value how can I inverse this?
0
Evgenia
Telerik team
answered on 15 Sep 2011, 01:07 PM
Hello Neeraj,

Your issue with reverse XAxis where the items are DateTime looks more like a Sorting of DateTime values task. You can review this forum post where a similar issue is discussed.
Note that you should sort them before binding the Chart. 

Best wishes,
Evgenia
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Neeraj
Top achievements
Rank 1
answered on 15 Sep 2011, 01:39 PM
i was able to do it using isInverse aftre downloading the latest build, isInverse works for DateTime X Axis. Though you are right, it could be done by sorting at sql level, but i was not looking for that because my source does not have data for some of week/months, I would like it to be shown in charts.
Tags
Chart
Asked by
Edward
Top achievements
Rank 1
Answers by
Thomas Kroll
Top achievements
Rank 1
Evgenia
Telerik team
Courouble Damien
Top achievements
Rank 1
Kristian Kretschmer
Top achievements
Rank 1
Neeraj
Top achievements
Rank 1
Share this question
or