Y axis label format

11 posts, 1 answers
  1. RoxanaC
    RoxanaC avatar
    71 posts
    Member since:
    Dec 2009

    Posted 08 Feb 2010 Link to this post

    Hello!
    I use the following line in my code:
    this.telerikChart.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{N0} " + unitName + " ";



    I try to format the Y axis labels in a way that it shows the actual value concatenated with a specific unit name, but the way provided by you in the tutorial give me only rounded values concatenated with the unit name - like in the image attached labelformat.png - and I get on Y axis few times 0 values, few 1 values and not the real values that I need (shown correctly but without unit in labelformatnorounding.png)

    What is the correct format string if I don.t want this rounding?

    Thank you!
    Roxana

  2. Answer
    Ves
    Admin
    Ves avatar
    2879 posts

    Posted 10 Feb 2010 Link to this post

    Hello Roxana,

    You can use this format:

    "#VAL" + unitName + " "

    Note that #VAL is used with no additional formatting.

    Regards,
    Ves
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. UI for WPF is Visual Studio 2017 Ready
  4. RoxanaC
    RoxanaC avatar
    71 posts
    Member since:
    Dec 2009

    Posted 10 Feb 2010 Link to this post

    Right! I should have tried it!
    Thank you!
  5. Muhammad
    Muhammad avatar
    35 posts
    Member since:
    Jun 2010

    Posted 24 Mar 2011 Link to this post

    Hi, 
    Can i have labels of Y-axis displayed in the center of graph. Right now Y axis on the left side and X xis labels on the bottom. I want both to be displayed i the middle of graph.
  6. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 29 Mar 2011 Link to this post

    Hi Muhammad,

    Presently, the requested functionality is not available out of the box. The labels are positioned along the x and y axis, and there is no straightforward option to reposition them along the middle of the graph.

    Regards,
    Yavor
    the Telerik team
  7. sai
    sai avatar
    43 posts
    Member since:
    Feb 2015

    Posted 14 May 2015 in reply to Yavor Link to this post

    hi,

     

    please check attaches screen shot.

     as of now we are showing 148.75. instead of that we want to show 148.45

    means curently its shoiwng in decimal.we need to show in minutes.

     

    Please provide the fix for this asap.

     

    i am using wpf cartecian chart.

  8. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 15 May 2015 Link to this post

    Hi Sai,

    I am not sure that I understand what is the issue that you are experiencing. The label of a data point will display the point's value without any formatting applied. However, keep in mind that the numeric values of the data points are stored in a property of type System.Double and if you set too big decimal number, this number will be round in order to fit in the System.Double's range. 

    Furthermore, I am not sure what you mean by saying that you need to show minutes. Can you please clarify this? Also, it would be helpful if you can provide us with an isolated project that demonstrates your implementation and drawings with the expected result. This will help us in better understanding your case and assist you further. In addition you can take a look at the Label Definitions help article that demonstrates how you can customize the data point's labels.

    Regards,
    Martin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  9. sai
    sai avatar
    43 posts
    Member since:
    Feb 2015

    Posted 21 May 2015 in reply to Martin Link to this post

    Hi,

     

    In my application some of the graph showing the value as 15.50. it means 15 hours and 30mins.

     

    but its showing like 15.50 in decimla format.

     

    i want to show the value in datetime for mat like 15.30

     

    please test and let me know the exact format for this label to show.

  10. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 25 May 2015 Link to this post

    Hi Sai,

    In order to achieve the desired effect you can use a LabelDefinition for the series and a custom Template along with an IValueConverter. This way you can define a text element for the label and bind its text with a converter which will convert the decimal part into minutes representation. Here is an example:
    public class NumberToMinutesNumberConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var labelValue = double.Parse((string)value);
            // convert the label's value
            // return the converted value
        }
    }

    <local:NumberToMinutesNumberConverter x:Key="numberToMinutesNumberConverter" />
    .....
    <telerik:BarSeries.LabelDefinitions>
      <telerik:ChartSeriesLabelDefinition>
            <telerik:ChartSeriesLabelDefinition.Template>
                <DataTemplate>
                    <TextBlock Text="{Binding Label, Converter={StaticResource numberToMinutesNumberConverter}}" />
                </DataTemplate>
            </telerik:ChartSeriesLabelDefinition.Template>
        </telerik:ChartSeriesLabelDefinition>
    </telerik:BarSeries.LabelDefinitions>

    Please try this and let me know if it works for you.

    Regards,
    Martin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  11. sai
    sai avatar
    43 posts
    Member since:
    Feb 2015

    Posted 25 May 2015 in reply to Martin Link to this post

    Hi,

     

    Thank you for yourreply.

     

    I am uisng cartesian chart.

     

    and i am taking care of binding and chart creation from codebehind.

     

    please let me know the solution for this to implement from codebehind.

  12. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 26 May 2015 Link to this post

    Hello Sai,

    Here is an example how you can create the LabelDefinition in code and add it to the LabelDefinitions collection of the series:
    <Window.Resources>
        <local:numberToMinutesNumberConverter x:Key="numberToMinutesNumberConverter" />
        <DataTemplate x:Key="seriesLabelTemplate">
            <TextBlock Text="{Binding Label, Converter={StaticResource numberToMinutesNumberConverter}}" />
        </DataTemplate>
    </Window.Resources>

    var series = new BarSeries();
    // code that set up the series
     
    var definition = new ChartSeriesLabelDefinition() { Template = (DataTemplate)this.Resources["seriesLabelTemplate"] };
    series.LabelDefinitions.Add(definition);

    If you want to define the DataTemplate also in code you can use several approach about which you can read in StackOverflow or in the corresponding Microsoft WPF documentation. You can also take a look at the Creating WPF Data Templates in Code: The Right Way blog post.

    I hope this is useful.

    Regards,
    Martin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready