Profile Picture

How to detect and avoid the axis lables overlapping?

Posted By bargitta chen 13 Years Ago
Author
Message
bargitta chen
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 18, Visits: 1

Dear experts,

Currently, I am using bar chart. When the label of each bar is too long, I want to show it tilted or in several lines as the attachment (like the one in excel). But I do not know how to detect such overlapping lables and tilt them propertly.

I do appreciate your help. Thanks in advance.



Attachments
barchart.jpg (63 views, 60.00 KB)
Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Bargitta,

You can actually achieve both outlooks - the following code snippets show how to have automatically rotated labels and automatically wrapped labels (we recommend the second option as horizontal texts are easier to read):

   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

   NBarSeries bar = new NBarSeries();
   bar.Values.Add(10);
   bar.Values.Add(20);
   bar.Values.Add(30);

   chart.Series.Add(bar);

   NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;
   scaleX.AutoLabels = false;

   scaleX.Labels.Add("Tabular Design and Analysis");
   scaleX.Labels.Add("Well Path Design");
   scaleX.Labels.Add("Drilling Engeneering");

   // option 1 - use value labels and rotate 30 or 45
   scaleX.LabelStyle.ContentAlignment = ContentAlignment.TopCenter;
   scaleX.LabelFitModes = new LabelFitMode[] { LabelFitMode.Rotate30, LabelFitMode.AutoScale };
   scaleX.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0, false);

   // option 2 (recommended) - use value labels and rotate 30 or 45
   NRangeScaleLabelStyle rangeScaleLabelStyle = new NRangeScaleLabelStyle();
   rangeScaleLabelStyle.TickMode = RangeLabelTickMode.None;
   rangeScaleLabelStyle.WrapText = true;
   scaleX.LabelStyle = rangeScaleLabelStyle;

Hope this helps - let us know if you meet any problems.



Best Regards,
Nevron Support Team



bargitta chen
Posted 13 Years Ago
View Quick Profile
Junior Member

Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 18, Visits: 1
Thank you team, very helpful!



Similar Topics


Reading This Topic