cut label

4 posts, 0 answers
  1. Guido
    Guido avatar
    5 posts
    Member since:
    Apr 2016

    Posted 21 Apr Link to this post

    hi,

    how can I solve the problem of the date labels cut on the x axis.

    see attached image

    tanks in advance. Guido.
  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 25 Apr Link to this post

    Hello Guido,

    Thank you for writing.

    You should set the ClipLabels property to false for the horizontal axis:
    public Form1()
    {
        InitializeComponent();
     
        LineSeries series = new LineSeries();
        series.DataPoints.Add(new CategoricalDataPoint(6, DateTime.Now));
        series.DataPoints.Add(new CategoricalDataPoint(4, DateTime.Now.AddDays(1)));
        series.DataPoints.Add(new CategoricalDataPoint(7, DateTime.Now.AddDays(2)));
        series.DataPoints.Add(new CategoricalDataPoint(5, DateTime.Now.AddDays(3)));
        DateTimeCategoricalAxis categoricalAxis = new DateTimeCategoricalAxis();
        categoricalAxis.DateTimeComponent = DateTimeComponent.Day;
        categoricalAxis.ClipLabels = false;
        series.HorizontalAxis = categoricalAxis;
        radChartView1.Series.Add(series);
    }

    I hope this information helps. Should you have further questions I would be glad to help.

     Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Guido
    Guido avatar
    5 posts
    Member since:
    Apr 2016

    Posted 25 Apr in reply to Dess Link to this post

    Hi Dess.

    Tanks for the reply.

    The example works, but how can I do if I use DataSource?

    In this case, assigne categoricalAxis to the series produces two axes x:

    Dim categoricalAxis As New DateTimeCategoricalAxis()
                categoricalAxis.ClipLabels = False

                With RadChartView1
                    .Series.Clear()
                    .ShowLegend = True
                    .LegendTitle = "Legenda"
                    .Controllers.Add(New SmartLabelsController())
                    .ShowGrid = True
                End With

                With Spese
                    .ValueMember = "SpeseAl"
                    .CategoryMember = "Aggiornamento"
                    .LegendTitle = "Spese"
                    .DataSource = dt
                    .ShowLabels = True
                    .Palette = New PaletteEntry(Color.Gainsboro, Color.Green)
                    .HorizontalAxis = categoricalAxis
                End With
                RadChartView1.Series.Add(Spese)

     

    see attached image.

     

  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 26 Apr Link to this post

    Hello Guido,

    Thank you for writing back. 

    Please refer to the following code snippet demonstrating how to access the horizontal axis when binding RadChartView and disable labels clipping:
    Private table As DataTable
    Sub New()
        InitializeComponent()
        table = New DataTable()
        table.Columns.Add("Value", GetType(Double))
        table.Columns.Add("Name", GetType(String))
        Dim rand As New Random
        For index = 1 To 10
            table.Rows.Add(rand.Next(0, 50), DateTime.Now.AddDays(index))
        Next
        Dim lineSeria As New LineSeries()
        RadChartView1.Series.Add(lineSeria)
        lineSeria.ValueMember = "Value"
        lineSeria.CategoryMember = "Name"
        lineSeria.DataSource = table
        lineSeria.HorizontalAxis.ClipLabels = False
    End Sub

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top