2011-05-18 12 views
17

मेरे पास एक साधारण चार्ट है, और मैं एक्स-अक्ष पर लेबल 45 डिग्री घुमाएगा। मैं क्या गलत कर रहा हूं?सी # चार्ट घुमावदार लेबल

Chart c = new Chart(); 
c.ChartAreas.Add(new ChartArea()); 
c.Width = 200; 
c.Height = 200; 
Series mySeries = new Series(); 
mySeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 }); 
mySeries.LabelAngle = 45; // why doesn't this work? 
c.Series.Add(mySeries); 

उत्पादन होता है:

img

मैं System.Web.UI.DataVisualization.Charting से चार्टिंग सामान का उपयोग कर रहा हूँ।

उत्तर

25

प्रलेखन कहता है कि श्रृंखला। लेबल एंगल डेटा बिंदु लेबल कोण सेट करता है, जो (मुझे लगता है) चार्ट के कॉलम के ऊपर एक लेबल है।

अक्ष लेबल के कोण सेट करने के लिए यह एक कोशिश:

var c = Chart1; 
c.ChartAreas.Add(new ChartArea()); 
c.Width = 200; 
c.Height = 200; 
Series mySeries = new Series(); 
mySeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 }); 
//mySeries.LabelAngle = -45; // why doesn't this work? 
c.Series.Add(mySeries); 
c.ChartAreas[0].AxisX.LabelStyle.Angle = 45; // this works 
+0

मैं हाल ही में इस क्षेत्र की वस्तु के साथ लेबल को घुमाने के लिए कोशिश कर रहा था, जो काम नहीं कर रहा था। चार्ट ऑब्जेक्ट को जोड़ना यह एक आकर्षण की तरह काम करता है। –

16

यहाँ है कैसे मैं आमतौर पर मेरी एक्स अक्ष लेबल बारी बारी से।

ChartArea area = new ChartArea(); 
area.AxisX.IsLabelAutoFit = true; 
area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30; 
area.AxisX.LabelStyle.Enabled = true; 

परिणाम

enter image description here

कुंजी संपत्ति/लाइन पर ऊपर देखने के लिए "LabelAutoFitStyle" है।

0

मैं यह काम करने के लिए इन पंक्तियों की जरूरत:

chartarea.AxisX.LabelStyle.Angle = -90; 
chartarea.AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount; 
chartarea.AxisX.IsLabelAutoFit = false; 
+0

वूप्स, 45 डिग्री की आवश्यकता नहीं पढ़ी, लेकिन यह किसी को भी मदद कर सकता है ... – Sean

संबंधित मुद्दे