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.
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
0
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);
}
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
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
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