YAxis Label Formating

6 posts, 0 answers
  1. Claude IMBERT
    Claude IMBERT avatar
    68 posts
    Member since:
    Oct 2006

    Posted 18 Jun 2008 Link to this post

    Hello,

    I put some data in my RadChart thanks to a datatable.

    My data is  integers like '12000'', 50000', '100000' and represents milliseconds time.

    Then, in my Bar Chart, that display bars, and my YAxis Label display '0', '20000',... and I want to display this number in this format : hh:mm:ss:fff

    How can I do ?

    Regards,

    YSP


  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 20 Jun 2008 Link to this post

    Hello Claude,

    There are a couple of ways to get the desired result:
    1. Convert the input to valid Ole Automation DateTime, then change the plot area's Y-axis value format:
      this.radChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime; 
    2. On the BeforeLayout event, go through the Yaxis items collection and change the text of each item to the correct value:
      1 public Form1() 
      2
      3     InitializeComponent(); 
      4  
      5     this.radChart1.BeforeLayout += new EventHandler<EventArgs>(radChart1_BeforeLayout); 
      6
      7  
      8 private void radChart1_BeforeLayout(object sender, EventArgs e) 
      9
      10     foreach (ChartAxisItem axisItem in this.radChart1.PlotArea.YAxis.Items) 
      11     { 
      12         axisItem.TextBlock.Text = "Custom string"
      13     } 
      14
    Should you need further assistance, just drop us a line.

    Best wishes,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Claude IMBERT
    Claude IMBERT avatar
    68 posts
    Member since:
    Oct 2006

    Posted 23 Jun 2008 Link to this post

    That's works. Thank you.

    Now, I want to know how can I change the YAxis scale of my Chart.

    In fact, before I had 0-100000-200000-300000 because my data was 32145-132657-265788 (For example) and now, I have 00:32:678- etc..

    I want to tryto have correct scale like : 00:02:00-00:04:00 etc....

    Best Regards,

    YSP
  5. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 25 Jun 2008 Link to this post

    Hi Claude,

    Setting custom scale on X or Y axis is done through the AddRange method of the respective axis in the plot area. Please, review the following posts:
    Dynamically change the Step/Min/Max value
    Problem on Scale Breaks(it is not appearing)




    All the best,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Hassan
    Hassan avatar
    1 posts
    Member since:
    Aug 2008

    Posted 20 Jul 2009 Link to this post

    I am using Reporting 2009 Q2 version on windows form. would you please tell me if BeforeLayout is supported? I would like to change the YAxis label and it seems that's the only way.

    Thanks,
    HF
  7. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 23 Jul 2009 Link to this post

    Hi Hassan,

    Unfortunately the charting report item does not expose this event. You can still customize the axis labels in the NeedDataSource event handler, but you will need to disable the Axis.AutoScale feature and you will need to create each axis item on your own:

    private void chart1_NeedDataSource(object sender, EventArgs e) 
        ChartSeries series = new ChartSeries(); 
        chart1.Series.Add(series); 
     
        for (int i = 0; i < 10; i++) 
        { 
            series.AddItem(new ChartSeriesItem(i)); 
        } 
     
        chart1.PlotArea.YAxis.AutoScale = false
        for (int j = 0; j < 5; j++) 
        { 
            ChartAxisItem item = new ChartAxisItem("TEST"); 
            item.Value = j * 2; 
            chart1.PlotArea.YAxis.Items.Add(item); 
        } 



    Greetings,
    Manuel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for WinForms is Visual Studio 2017 Ready