Chart Axis Tick Label

8 posts, 0 answers
  1. Anatoly Chekh
    Anatoly Chekh avatar
    86 posts
    Member since:
    Apr 2010

    Posted 17 Feb 2011 Link to this post

    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?
  2. Missing user
    Missing user avatar

    Posted 23 Feb 2011 Link to this post

    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!
  3. Anatoly Chekh
    Anatoly Chekh avatar
    86 posts
    Member since:
    Apr 2010

    Posted 23 Feb 2011 Link to this post

    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!
  4. Missing user
    Missing user avatar

    Posted 01 Mar 2011 Link to this post

    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!
  5. Anatoly Chekh
    Anatoly Chekh avatar
    86 posts
    Member since:
    Apr 2010

    Posted 01 Mar 2011 Link to this post

    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.
  6. Missing user
    Missing user avatar

    Posted 07 Mar 2011 Link to this post

    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!
  7. Anatoly Chekh
    Anatoly Chekh avatar
    86 posts
    Member since:
    Apr 2010

    Posted 08 Mar 2011 Link to this post

    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!
  8. Missing user
    Missing user avatar

    Posted 14 Mar 2011 Link to this post

    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!
Back to Top