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

X axis labelling issue

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

3 Replies

DJ Davis Jebaraj Syncfusion Team September 24, 2004 01:08 PM UTC

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


AD Administrator Syncfusion Team September 24, 2004 03:01 PM UTC

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 > >


AM Ashes Mukherjee April 14, 2005 07:28 PM UTC

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 > >

Loader.
Live Chat Icon For mobile
Up arrow icon