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.
Unfortunately, activation email could not send to your email. Please try again.

X axis labelling issue

Thread ID:

Created:

Updated:

Platform:

Replies:

19339 Sep 23,2004 12:46 PM Apr 14,2005 03:28 PM Windows Forms 3
loading
Tags: Chart
Administrator [Syncfusion]
Asked On September 23, 2004 12:46 PM

I have a chart that plots a line series ranging from 0 to 200 along the horizontal X axis. When the chart draws the labels, I want it to draw every 10th one so that the X axis is as follows: 0---10---20---30---...190---200 and not try to label every single point. What property do I need to set in order for this to happen? TIA

Davis Jebaraj [Syncfusion]
Replied On September 24, 2004 09:08 AM

Hi, The ChartFormatAxisLabel event of the ChartControl can be handled to provide custom labels for any of the Axes. http://www.syncfusion.com/Support/article.aspx?id=10455 Sample: F19339ChartAxisLabel_9534.zip // Add the handler this.chartControl1.ChartFormatAxisLabel += new ChartFormatAxisLabelEventHandler(this.chartControl1_ChartFormatAxisLabelEventHandler); // The event handler private void chartControl1_ChartFormatAxisLabelEventHandler(object sender,ChartFormatAxisLabelEventArgs args ) { if(args.IsAxisPrimary && args.AxisOrientation == Orientation.Horizontal) { if(this.checkBox1.Checked && args.Value % 10 != 0) { args.Label = ""; args.Handled = true; } } } Regards, Davis

Administrator [Syncfusion]
Replied On September 24, 2004 11:01 AM

Thank you David. That did the trick! >Hi, > >The ChartFormatAxisLabel event of the ChartControl can be handled to provide custom labels for any of the Axes. > >http://www.syncfusion.com/Support/article.aspx?id=10455 > >Sample: > >F19339ChartAxisLabel_9534.zip > >// Add the handler >this.chartControl1.ChartFormatAxisLabel += new ChartFormatAxisLabelEventHandler(this.chartControl1_ChartFormatAxisLabelEventHandler); > >// The event handler >private void chartControl1_ChartFormatAxisLabelEventHandler(object sender,ChartFormatAxisLabelEventArgs args ) > { > if(args.IsAxisPrimary && args.AxisOrientation == Orientation.Horizontal) > { > if(this.checkBox1.Checked && args.Value % 10 != 0) > { > args.Label = ""; > args.Handled = true; > } > } > } > >Regards, > >Davis > >

Ashes Mukherjee
Replied On April 14, 2005 03:28 PM

I tried this sample trying to solve a similar problem. I wanted to render a text label for every label that is an even number. Could not get it to work. Finally, I brute forced a list of labels and used the following code to solve it. ***** int[] points = {1,5,2,3,6,9,4,16,3,17,8,2,25,22}; string[] labels = new string[points.Length]; for(int i = 0; i < points.Length; i++) { if(points[i] % 2 == 0) labels[i] = points[i].ToString(); else labels[i] = ""; } for(int i = 0; i < labels.Length; i++) { chartControl1.PrimaryXAxis.Labels.Add (labels[i]); } chartControl1.PrimaryXAxis.ValueType = ChartValueType.Custom; >Hi, > >The ChartFormatAxisLabel event of the ChartControl can be handled to provide custom labels for any of the Axes. > >http://www.syncfusion.com/Support/article.aspx?id=10455 > >Sample: > >F19339ChartAxisLabel_9534.zip > >// Add the handler >this.chartControl1.ChartFormatAxisLabel += new ChartFormatAxisLabelEventHandler(this.chartControl1_ChartFormatAxisLabelEventHandler); > >// The event handler >private void chartControl1_ChartFormatAxisLabelEventHandler(object sender,ChartFormatAxisLabelEventArgs args ) > { > if(args.IsAxisPrimary && args.AxisOrientation == Orientation.Horizontal) > { > if(this.checkBox1.Checked && args.Value % 10 != 0) > { > args.Label = ""; > args.Handled = true; > } > } > } > >Regards, > >Davis > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;