This is a migrated thread and some comments may be shown as answers.

Hide Minor Ticks X-Axis RadChart

3 Answers 215 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Rakesh
Top achievements
Rank 1
Rakesh asked on 03 Jan 2012, 10:12 PM
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. 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Jan 2012, 08:40 AM
Hello,

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

Thanks,
Princy.
0
Rakesh
Top achievements
Rank 1
answered on 04 Jan 2012, 10:03 AM
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);                    
            }
0
Peshito
Telerik team
answered on 06 Jan 2012, 12:46 PM
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
Tags
Chart (Obsolete)
Asked by
Rakesh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rakesh
Top achievements
Rank 1
Peshito
Telerik team
Share this question
or