We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Axis Lable

Hi,
I want Set XAxisLable Manualy,
In a for block i set my Series :
for (int i = 0; i < n ; i++)
{
string Title = items[i];
ChartSeries series = new ChartSeries();
series.Name = Title;
series.Points.Add(i, result[i]);
series.Type = ChartSeriesType.StackingColumn;
series.Text = series.Name;
chart1.Series.Add(series);
series.PrepareStyle += new ChartPrepareStyleInfoHandler(series_PrepareStyle);
}




void series_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries series = sender as ChartSeries;
args.Style.DisplayText = true;
args.Style.TextOrientation = ChartTextOrientation.Smart;
series.Style.Font.Size = 12;
}

and set my labels :

private void chart1_ChartFormatAxisLabel(object sender, ChartFormatAxisLabelEventArgs e)
{
chart1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.AutomaticMode;
int index = (int)e.Value;
if (e.AxisOrientation == ChartOrientation.Horizontal && index < chart1.Series.Count && index > 0)
e.Label = chart1.Series[index - 1].Name;
}



When my series is more than 5 it shows XaxisLabel for odd Series and when my series is more than 10 it shows XaxisLable for 3,6,9 and when .... but i want see all my XaxisLabel.
what can i do?

2 Replies

SM smh June 28, 2009 08:49 AM UTC

i try 2 use usermode and write :

chart1.PrimaryXAxis.Labels.Add(new ChartAxisLabel(items[i], Color.Maroon, new Font("Arial", 9F, System.Drawing.FontStyle.Bold)));


but all of my Xaxis has shown on Serie[0];


MS Manimala S Syncfusion Team June 30, 2009 01:17 PM UTC

Hi Mahdi,

Sorry for the delay in responding.

To set custom labels for the axis ChartAxisTickLabelDrawingMode must be set as Usermode. But in the code you have given as Automaticmode. So this will not force custom labels to be displyed. I have created a sample to set custom labels for the axis. Kindly get the sample from the following link.

http://files.syncfusion.com/support/Chart.Windows/V7.2.0.20/F83927/main.htm

Kindly, let me know if you have any other queries.

Thanks,
Manimala.



Loader.
Live Chat Icon For mobile
Up arrow icon