Hide Minor Ticks X-Axis RadChart

Thread is closed for posting
4 posts, 0 answers
  1. Rakesh
    Rakesh avatar
    6 posts
    Member since:
    Aug 2012

    Posted 03 Jan 2012 Link to this post

    Hi,

    I have a requirement of binding Daily points on to the Charts. On the X-Axis i am trying to show the Label of some 5 dates and hiding all the other labels. I want to show the major ticks for which Dates are being displayed and hide all the minor ticks. Is this possible to show only Major and not the Minor ticks when binding dynamically. 
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Jan 2012 Link to this post

    Hello,

    XAxis has only a MajorTick property. Take a look into the following documentation for more.
    Ticks

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rakesh
    Rakesh avatar
    6 posts
    Member since:
    Aug 2012

    Posted 04 Jan 2012 Link to this post

    Please find the below code, suggest me if anything is missing in acheving my requirement.

    Aspx
    <PlotArea XAxis-LayoutMode="Normal" Appearance-FillStyle-FillType="Solid" Appearance-Border-Visible="false">
                                                                <XAxis DataLabelsColumn="Timeline" AxisLabel-TextBlock-Text="Timeline" Appearance-MinorTick-Visible="false"
                                                                    Appearance-MinorGridLines-Visible="false" Appearance-MajorGridLines-Visible="false" Appearance-MajorTick-Visible="true">
                                                                </XAxis>
                                                                <YAxis IsZeroBased="false" Appearance-MinorGridLines-Visible="false" Appearance-MajorGridLines-Visible="false"
                                                                    AxisLabel-Marker-Visible="false" Appearance-MajorTick-Visible="false" Appearance-MinorTick-Visible="false"
                                                                    AutoScale="false">
                                                                </YAxis>
                                                            </PlotArea>

    C#
       ChartSeries s = Chart.Series[0];
                for (int i = 0; i < List.Count; i++)
                {
                    ChartSeriesItem item = new ChartSeriesItem();
                    item.YValue = List[i].Views;
                    item.ActiveRegion.Tooltip = List[i].Views.ToString("#,#", CultureInfo.InvariantCulture) + " views on " + List[i].Week.ToShortDateString();
                    Chart.PlotArea.XAxis.AddItem(weeklyActivityList[i].Week.ToString("dd-MMM"));
                    if (i % mod == 0)
                        Chart.PlotArea.XAxis.GetItem(i).Visible = true;
                    else
                        Chart.PlotArea.XAxis.GetItem(i).Visible = false;
                    s.Items.Add(item);                    
                }
  5. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 06 Jan 2012 Link to this post

    Hi,

    You can hide some of the axis labels by wiring to the chart's BeforeLayout event like this:
    void radChart_BeforeLayout(object sender, EventArgs e)
        {
            foreach (var item in radChart.PlotArea.XAxis.Items)
            {
                if ((double)item.Value > new DateTime(2009, 8, 1, 0, 0, 0).ToOADate())
                {
                    item.TextBlock.Text = " ";
                }
            }
        }

    The code above will hide all XAxis labels with date value bigger than 2009/08/01.

    Regarding your other questions about hiding some of the major ticks, there is no way to loop through MajorTicks of the axes which means that you can either make all of them invisible or nor of them.

    Greetings,
    Peshito
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top