Rad chartview y xis label formatting not works

8 posts, 1 answers
  1. Praveen
    Praveen avatar
    14 posts
    Member since:
    Oct 2011

    Posted 08 Mar 2013 Link to this post

    Hi,

    I am using latest telerik winform dll for my C#.net windows application. In my app, I have populated a radchartview( Line chart) control programatically by the following lines:

                LineSeries lineSeria = new LineSeries();
                lineSeria.VerticalAxis.LabelFormat = "{0:#,###}";        // Y axis label formatting
                lineSeria.HorizontalAxis.LabelFormat = "{0:MM/dd/yyyy}"; //X axis label formatting
                lineSeria.HorizontalAxis.LabelRotationAngle = 300;
                lineSeria.HorizontalAxis.LabelFitMode = AxisLabelFitMode.Rotate;
                lineSeria.HorizontalAxis.LabelInterval = graphInterval;
                lineSeria.VerticalAxis.LabelInterval = 2;  

                List<Graph_Stat> lstGraph = _oGraphBal.LoadGraphs(); //Loading a generic list for populating chartview
                lineSeria.ValueMember = "Value"; //decimal value
                lineSeria.CategoryMember = "Date"; //date time
                lineSeria.DataSource = lstGraph;     //setting datasouce for line series
       this.chartFrontedContractsSold.Series.Add(lineSeria); //adding line series to chartview and populating it

    Here in this example , I have formatted both X and Y axis labels of chartview. The datetime value in X axis shows the correct formatting result. But the Y axis label not shows any formatted output ( for Eg, if I have a value 1000, it should have to be displayed as 1,000).

    Please help me.

    -Praveen.
         
  2. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 13 Mar 2013 Link to this post

    Hello Praveen,

    Thank you for writing.

    I can confirm that there is an issue with the formatting of the labels in Linear axes. I have logged this issue in our Public Issue Tracking System - PITS. You can track the progress of the issue, subscribe for status changes and add your vote/comment to it on the following link - PITS Issue.

    Until the issue is resolved you can workaround it by creating a custom format provider and assigning it to the linear axis of your chart:
    public class MyFormatProvider : IFormatProvider, ICustomFormatter
    {
        public object GetFormat(Type formatType)
        {
            if (formatType == typeof(ICustomFormatter))
            {
                return this;
            }
     
            return null;
        }
     
        public string Format(string format, object arg, IFormatProvider formatProvider)
        {
            if (arg == null)
            {
                throw new ArgumentNullException("arg");
            }
     
            double value;
     
            if (!double.TryParse(arg.ToString(), out value))
            {
                throw new ArgumentNullException("arg");
            }
     
            return string.Format("{0:" + format + "}", value);
        }
    }

    And here is how to use this format provider:
    lineSeria.VerticalAxis.LabelFormatProvider = new MyFormatProvider();

    I have also updated your Telerik points for bringing this issue to our attention.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Regards,
    Ivan Petrov
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Praveen
    Praveen avatar
    14 posts
    Member since:
    Oct 2011

    Posted 13 Mar 2013 Link to this post

    Hi Ivan Petrov,

    The solution helped me a lot and it works fine. Thank you very much..!!  :)

    Regards,
    Praveen

    ,
  5. Mark
    Mark avatar
    1 posts
    Member since:
    May 2013

    Posted 03 Jun 2013 Link to this post

    Hello Telerik support,

    I still have a similar problem, even after upgrading to your latest version.

    I have a stacked bar chart in horizontal form, so the x-axis is linear. The linear input are ticks, so of type long, and i would like to format this to hours, or datetimes; ideally i would set a datetime at the origin and then the labels should count on from there.

    At the moment my Format function  returns the ToString  of (value/TimeSpan.TickPerHour). My value variable is of type long.
    Any ideas how I can get this to work?

    Thanks,

    Mark
  6. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 06 Jun 2013 Link to this post

    Hello Mark,

    Thank you for writing.

    Please, find attached an example project where I have tried to implement what I understand is your case. If this is not what you want to achieve or if this does not replicate your setup, I would kindly ask you to send me a more detailed explanation. Any additional materials like screenshots or sketches would also be helpful.

    Looking forward to your reply.

    Regards,
    Ivan Petrov
    Telerik
    RadChart for WinForms is obsolete. Now what?
  7. Roger
    Roger avatar
    6 posts
    Member since:
    Jul 2012

    Posted 08 Oct 2013 Link to this post


    Hi Ivan,

    Would it be possible to have a VS 2010 version please of RadChartViewExample.zip, preferably VB.net? c# ok, though.

    cheers

    Roger
  8. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 11 Oct 2013 Link to this post

    Hi Roger,

    Thank you for writing.

    I have attached a VS 2010 VB version of the project. 

    I hope you find this useful. Should you need further assistance, I would be glad to provide it.

    Regards,
    Ivan Petrov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  9. Roger
    Roger avatar
    6 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2013 Link to this post

    Thanks Ivan,

    Appreciated.

    Roger
Back to Top
UI for WinForms is Visual Studio 2017 Ready