font of Axes label

12 posts, 0 answers
  1. asghar
    asghar avatar
    23 posts
    Member since:
    Dec 2018

    Posted 26 Dec 2018 Link to this post

    hi.

    i want to change font and color of  Axes label.but when i changed it, change font of the all number in Axes.

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3412 posts

    Posted 27 Dec 2018 Link to this post

    Hello, 

    If you want to change the font only for a single label in the axis, you can access the respective AxisLabelElement via the LinearAxis.Children collection and set the desired Font as it is demonstrated in the code snippet below:

    ScatterSeries scatterSeries = new ScatterSeries();
    scatterSeries.Name = "";
    scatterSeries.DataPoints.Add(new ScatterDataPoint(15, 19));
    scatterSeries.DataPoints.Add(new ScatterDataPoint(18, 10));
    scatterSeries.DataPoints.Add(new ScatterDataPoint(13, 15));
    scatterSeries.DataPoints.Add(new ScatterDataPoint(10, 8));
    scatterSeries.DataPoints.Add(new ScatterDataPoint(5, 12));
    scatterSeries.PointSize = new SizeF(8, 8);
    this.radChartView1.Series.Add(scatterSeries);
     
    LinearAxis horizontalAxis = radChartView1.Axes.Get<LinearAxis>(0);
    AxisLabelElement axisLabel = horizontalAxis.Children[1] as AxisLabelElement;
    axisLabel.Font = new Font("Arial",12f, FontStyle.Italic);



    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. asghar
    asghar avatar
    23 posts
    Member since:
    Dec 2018

    Posted 29 Dec 2018 Link to this post

    thx.

    but i want this 

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3412 posts

    Posted 31 Dec 2018 Link to this post

    Hello,  

    According to the provided screenshot, it seems that you want to change the font for the title of the entire RadChartView which is located at the bottom. You can use the following code snippet:

    this.radChartView1.ShowTitle = true;
    this.radChartView1.Title = "Sample title";
    this.radChartView1.ChartElement.TitlePosition = TitlePosition.Bottom;
    this.radChartView1.ChartElement.TitleElement.TextAlignment = ContentAlignment.MiddleCenter;
    this.radChartView1.ChartElement.TitleElement.Font = new Font("Arial",12f, FontStyle.Italic);




    I hope this information helps. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. asghar
    asghar avatar
    23 posts
    Member since:
    Dec 2018

    Posted 01 Jan Link to this post

    tnx

    but i want change the font title of axis x and axis y.

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3412 posts

    Posted 02 Jan Link to this post

    Hello,   

    Thank you for specifying that you need to change the font of the horizontal axis. It was not easy to understand what is the exact requirement that you have from the previous replies. 

    In order to achieve it, you can use the following code snippet: 

    LinearAxis horizontalAxis = radChartView1.Axes.Get<LinearAxis>(0);
    horizontalAxis.Title = "Axis' title";
    horizontalAxis.Font= new Font("Arial",12f, FontStyle.Italic);

    I hope this information helps.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  7. asghar
    asghar avatar
    23 posts
    Member since:
    Dec 2018

    Posted 03 Feb in reply to Dess | Tech Support Engineer, Sr. Link to this post

    I encountered an error message
  8. asghar
    asghar avatar
    23 posts
    Member since:
    Dec 2018

    Posted 03 Feb in reply to asghar Link to this post

    hi

    at the end,i did it

    radChart1.Axes[0].TitleElement.Font= new Font("Arial", 15, FontStyle.Bold);
  9. asghar
    asghar avatar
    23 posts
    Member since:
    Dec 2018

    Posted 03 Feb in reply to asghar Link to this post

    Finally, I did it
    radChart1.Axes[0].TitleElement.Font= new Font("Arial, 15, FontStyle.Bold);
  10. Brandon
    Brandon avatar
    21 posts
    Member since:
    Jan 2019

    Posted 04 Feb Link to this post

    I converted:

    LinearAxis horizontalAxis = radChartView1.Axes.Get<LinearAxis>(0);
    horizontalAxis.Title = "Axis' title";
    horizontalAxis.Font= new Font("Arial",12f, FontStyle.Italic);

     

    to:

    Dim HA As LinearAxis = DashBoard.chtNewDayAvg.Axes.[Get](Of LinearAxis)(0)
    Dim AL As AxisLabelElement = DirectCast(HA.Children(1), AxisLabelElement)
    AL.ForeColor = Color.White
    If RecHasData(Counts) Then
        'Play with the 30 day rolling avg.
        DashBoard.chtNewDayAvg.ShowLegend = False
        DashBoard.chtNewDayAvg.Series(0).DataPoints.Clear()
        'Not sure about the areas
        For I As Integer = 0 To UB(Counts)
            Dim Statuses As New List(Of String)
            Statuses.AddRange(Split(GetFromSet(Counts, 1, I), Separator2))
            Dim AssetsDown As Integer = 0
            For II As Integer = 0 To Statuses.Count - 1
                Dim Val As Integer
                Integer.TryParse(Statuses(II).Split(Separator)(AssetTypeSlot), Val)
                Select Case Statuses(II).Split(Separator)(0)
                    Case "Down"
                        AssetsDown += Val : If Val > MaxDwn Then MaxDwn = Val
                    Case "Repairing"
                        AssetsDown += Val : If Val > MaxDwn Then MaxDwn = Val
                End Select
            Next
            Dim DT As String = FMDB(GetFromSet(Counts, 0, I), False).ToShortDateString
            Dim P As New CategoricalDataPoint(AssetsDown, DT)
            P.Label = AssetsDown
            DashBoard.chtNewDayAvg.Series(0).DataPoints.Add(P)
        Next
        Dim HA As LinearAxis = DashBoard.chtNewDayAvg.Axes.[Get](Of LinearAxis)(0)
        Dim AL As AxisLabelElement = DirectCast(HA.Children(0), AxisLabelElement)
        AL.ForeColor = Color.White
    End If

    HA is nothing, so I get an Object Reference error on the second line where it tries to get the children.

    You example was to adjust the font for a specific horizontal label.  I just want to set the ForeColor for all of them.  This is the code I'm using to populate the Graph with data.

     

  11. Brandon
    Brandon avatar
    21 posts
    Member since:
    Jan 2019

    Posted 04 Feb Link to this post

    Nevermind.  Set the forecolor using this:

    DashBoard.chtNewDayAvg.Series(0).Axes(0).ForeColor = Color.White

    DashBoard.chtNewDayAvg.Series(0).Axes(1).ForeColor = Color.White

  12. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3412 posts

    Posted 05 Feb Link to this post

    Hello,         
     
    I am glad that the problem you were facing is now resolved. Feel free to access the axis after RadChartView is populated with points. Then, it is not supposed to be null.

    Note that if you want to customize the labels in the axis, you can access the respective AxisLabelElement via the LinearAxis.Children collection apply the desired style.

    Feel free to use our online converter for translating C# to VB.NET and vice versa: http://converter.telerik.com/

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top