Last Label Visibilty in x-axis hidden not working

1 Answer 73 Views
ChartView
Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
Om Pushkara deep asked on 14 Jun 2021, 04:26 PM | edited on 14 Jun 2021, 04:26 PM

Hi ,

I am trying to hide the last label in y-axis which is kind of inverted but i have attached the image and code for the same


        

private void LoadBarChart() { chart.View.AreaType = ChartAreaType.Cartesian; chart.AngleTransform = 90; RangeBarSeries rangeBarSeries = new RangeBarSeries(); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 14, DateTime.Now.TimeOfDay.TotalMinutes + 10, "5/17/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 7, DateTime.Now.TimeOfDay.TotalMinutes + 5, "5/17/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 4, DateTime.Now.TimeOfDay.TotalMinutes + 2, "5/17/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 30, DateTime.Now.TimeOfDay.TotalMinutes + 10, "5/18/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 7, DateTime.Now.TimeOfDay.TotalMinutes + 5, "5/18/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 4, DateTime.Now.TimeOfDay.TotalMinutes + 2, "5/19/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes - 89, DateTime.Now.TimeOfDay.TotalMinutes - 100, "5/20/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 7, DateTime.Now.TimeOfDay.TotalMinutes + 5, "5/20/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes - 79, DateTime.Now.TimeOfDay.TotalMinutes - 90, "5/21/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 7, DateTime.Now.TimeOfDay.TotalMinutes + 5, "5/21/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 14, DateTime.Now.TimeOfDay.TotalMinutes + 10, "5/22/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 7, DateTime.Now.TimeOfDay.TotalMinutes + 5, "5/22/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 14, DateTime.Now.TimeOfDay.TotalMinutes + 10, "5/23/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 7, DateTime.Now.TimeOfDay.TotalMinutes + 5, "5/23/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 14, DateTime.Now.TimeOfDay.TotalMinutes + 10, "5/25/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 7, DateTime.Now.TimeOfDay.TotalMinutes + 5, "5/24/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 14, DateTime.Now.TimeOfDay.TotalMinutes + 10, "5/26/2021")); rangeBarSeries.DataPoints.Add(new RangeDataPoint(DateTime.Now.TimeOfDay.TotalMinutes + 7, DateTime.Now.TimeOfDay.TotalMinutes + 5, "5/26/2021")); CategoricalAxis horizontalAxis = new CategoricalAxis(); horizontalAxis.ClipLabels = false; horizontalAxis.ShowLabels = false; horizontalAxis.PlotMode = AxisPlotMode.BetweenTicks; rangeBarSeries.HorizontalAxis = horizontalAxis; chart.View.Series.Add(rangeBarSeries); rangeBarSeries.VerticalAxis.LabelFormatProvider = new MyFormatProvider(); rangeBarSeries.VerticalAxis.ClipLabels = false; rangeBarSeries.VerticalAxis.LabelRotationAngle = -45; rangeBarSeries.VerticalAxis.LabelFitMode = AxisLabelFitMode.Rotate; LinearAxis verticalAxis = chart.View.Axes.Get<LinearAxis>(1); verticalAxis.Minimum = 0; //Minutes 0:00 verticalAxis.Maximum = 1440; //Minutes 23:00 verticalAxis.MajorStep = 60; //60 minutes in an hour verticalAxis.LastLabelVisibility = AxisLastLabelVisibility.Hidden; }

 

    public class MyFormatProvider : IFormatProvider, ICustomFormatter
    {
        public object GetFormat(Type formatType)
        {
            return this;
        }
        public string Format(string format, object arg, IFormatProvider formatProvider)
        {
            int totalminutes = Convert.ToInt32(arg);
            TimeSpan timeSpan = TimeSpan.FromMinutes(totalminutes);
            return timeSpan.ToString(@"hh\:mm");
        }
    }

    LinearAxis verticalAxis = chart.View.Axes.Get<LinearAxis>(1);
            verticalAxis.Minimum = 0; //Minutes 0:00
            verticalAxis.Maximum = durationofdayDST; //Minutes 23:00
            verticalAxis.MajorStep = 60; //60 minutes in an hour
            verticalAxis.LastLabelVisibility = AxisLastLabelVisibility.Hidden;
        }

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Jun 2021, 09:02 AM

Hello,

Following the provided code snippet, I have prepared a sample project.

If the labels are not rotated, the last label on the axis is hidden indeed:

However, when rotated, the last label is not hidden:

I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to use AxisLabelFitMode.None.

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

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
commented on 16 Jun 2021, 09:31 AM

Thanks a lot for providing an alternate solution and thanks for the telerik points :)
Tags
ChartView
Asked by
Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or