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

Chart Axis Tick Label

7 Answers 55 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Anatoly Chekh
Top achievements
Rank 1
Anatoly Chekh asked on 17 Feb 2011, 04:01 PM
Hello!

I have two questions about chart axis points:

1) If tick point value is greater then or equals to 1 quadrillion then I have index out of bounds exception in the your dll while try to format it (in ChartNumberFormatter.GetStringFormat). As result I see empty label.

Code:

long maxValue = 1000000000000000; // 10^15;
long step = maxValue;

_radChart.DefaultView.ChartArea.AxisY.MinorTicksVisibility = Visibility.Collapsed;
_radChart.DefaultView.ChartArea.AxisY.MinValue = 0;
_radChart.DefaultView.ChartArea.AxisY.MaxValue = maxValue;
_radChart.DefaultView.ChartArea.AxisY.Step = step;
_radChart.DefaultView.ChartArea.AxisY.AutoRange = false;

_radChart.ItemsSource = new int[] {1};

2)

Additional code:

_radChart.DataBound += DataBound;

private void DataBound(object sender, ChartDataBoundEventArgs e)
{
   for (int index = 0; index < _radChart.DefaultView.ChartArea.AxisY.TickPoints.Count; index++)
   {
      TickPoint tick = _radChart.DefaultView.ChartArea.AxisY.TickPoints[index];
      tick.Label = "Hello " + index;
   }
}

In this case there is no exception and I see tick labels ('Hello 0' and 'Hello 1').
But If the intervals count is not exact (i.e. maxValue = 10^15 + 1) then tick.Label = "Hello " + index; doesn't affect. And I see this exception again.

Also in simple case when maxValue = 10 and step = 3 - tick.Label = "Hello " + index; also doesn't have any affect.

What can I do with this issues?

7 Answers, 1 is accepted

Sort by
0
Missing User
answered on 23 Feb 2011, 09:12 AM
Hi Anatoly Chekh,

It is possible when using very big values to get out of bounds exception, however most such cases are handled internally. I tried to reproduce the issue locally but I wasn't able to get such an exception. You can open a formal support ticket and send us a runnable sample project that we can investigate locally and give you an appropriate solution.

Best wishes,
Polina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Anatoly Chekh
Top achievements
Rank 1
answered on 23 Feb 2011, 10:43 PM
Hello, Polina!

Yes, exception in this case is handled internally (I see inner exception). But as result I see empty strings for all axis labels in the chart beside define number.

Thanks, Anatoly Chekh!
0
Missing User
answered on 01 Mar 2011, 08:20 AM
Hi Anatoly Chekh,

I prepared a sample project with the provided code, but I didn't get such an exception. You can find the sample in the attached file. We will appreciate if you modify it to replicate the erroneous behavior or send us another working project which demonstrates it. Thus we will be able to identify the cause for the problem and provide an explanation.

Thank you in advance for your cooperation.

All the best,
Polina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Anatoly Chekh
Top achievements
Rank 1
answered on 01 Mar 2011, 07:06 PM
Hello, Polina.

You can get this case in two ways:
1) Remove from you code radChart.DataBound event
2) set radChart.DefaultView.ChartArea.AxisY.MaxValue = maxValue + 1; (not exact maxValue)

Thanks, Abatoly Chekh.
0
Missing User
answered on 07 Mar 2011, 01:32 PM
Hello Anatoly Chekh,

I tried the listed suggestions but I didn't get this exception. Could you please describe the functionality that you want to achieve and the scenarios in which you need such big values? It will be very helpful if you modify the provided project or send us a new one which reproduces this issue.  Thus we will debug it locally, and advise you further.

Thank you in advance.

Kind regards,
Polina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Anatoly Chekh
Top achievements
Rank 1
answered on 08 Mar 2011, 11:38 PM
Hello!

Heres your solution: http://ifolder.ru/22296851

One thing what I do - comment line number 33 (// radChart.DataBound += new EventHandler<ChartDataBoundEventArgs>(radChart_DataBound);)

As result I see labels with empty text. (See attachment)

We need to show date time on the Y axis. So we use date time ticks (which is big number) and then apply labet to the label tick.

P.S. We took a look on your code. The exception is  throw in in the ChartNumberFormatter.GetStringFormat method: you hard coded array for the number formats from 0 power to 12. So array has 5 items. If we have y = 10^15 = (10^3)^5 - index is 5. So array[5] is thrown.

Thanks, Anatoly Chekh!
0
Missing User
answered on 14 Mar 2011, 04:28 PM
Hello Anatoly Chekh,

You will need to convert the ticks from long to double before binding them to the AxisY. You can re-template the ItemLabelStyle and bind the desired strings by a custom converter. In order to indicate the TickPoints' labels that will be modified, you will need to set a custom word to the RadChart.DefaultView.ChartArea.AxisY.DefaultLabelFormat and use it to find the needed TickPoints. In the attached files you can find an example how to achieve this solution.

I hope this helps.

All the best,
Polina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Chart
Asked by
Anatoly Chekh
Top achievements
Rank 1
Answers by
Missing User
Anatoly Chekh
Top achievements
Rank 1
Share this question
or