سؤال

ugly pie chart

لا يمكنني العثور على العقار الذي يتحكم في رؤية الملصقات في مخططات الفطيرة. أحتاج إلى إيقاف تشغيل الملصقات حيث تتوفر المعلومات في الأسطورة.

أي شخص يعرف ما هي الخاصية التي يمكنني استخدامها في الكود وراء؟

حاولت تعيين تسميات السلسلة إلى لا شيء Chart1.Series[i].Label = string.Empty; ولكن يبدو أن الملصقات تظهر على أي حال.

هل كانت مفيدة؟

المحلول

Chart1.Series[i]["PieLabelStyle"] = "Disabled";

يعمل أيضًا ، ولا يلزم تعيينه لكل نقطة بيانات.

نصائح أخرى

وجدت الجواب هنا: http://social.msdn.microsoft.com/forums/en-us/mswinwebchart/thread/32ccd993-5f43-47a3-bcbc-e772a13a87fe

اتضح أن هناك مجموعة غامضة DataPointCustomProperty تسمى Pielabelstyle التي تحكم رؤية الملصقات في مخططات الفطيرة. والأسوأ من ذلك ، يجب تعيين الخاصية على كل نقطة بيانات.

for (var i = 0; i < chart.Series.Count; i++) 
    for (var j = 0; j < chart.Series[i].Points.Count; j++)
        chart.Series[i].Points[j]["PieLabelStyle"] = "Disabled";

تغيير الخصائص المخصصة الرسم البياني سوف يقوم بالخدعة أيضًا ولا توجد حاجة إلى ترميز

<asp:Series Name="Series1" ChartType="Pie" CustomProperties="PieLabelStyle=Disabled">

قد يكون هذا الموقع حل مشكلتك

page page_load محمي (مرسل الكائن ، eventArgs e) {
// إدراج رمز لإنشاء مخطط فطيرة أساسي // راجع منشور مدونتي بعنوان "PIE Charts in ASP.NET" للحصول على رمز المصدر الكامل

     // Set pie labels to be outside the pie chart
     this.Chart2.Series[0]["PieLabelStyle"] = "Outside";

     // Set border width so that labels are shown on the outside
     this.Chart2.Series[0].BorderWidth = 1;
     this.Chart2.Series[0].BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);

     // Add a legend to the chart and dock it to the bottom-center
     this.Chart2.Legends.Add("Legend1");
     this.Chart2.Legends[0].Enabled = true;
     this.Chart2.Legends[0].Docking = Docking.Bottom;
     this.Chart2.Legends[0].Alignment = System.Drawing.StringAlignment.Center;

     // Set the legend to display pie chart values as percentages
     // Again, the P2 indicates a precision of 2 decimals
     this.Chart2.Series[0].LegendText = "#PERCENT{P2}";

     // By sorting the data points, they show up in proper ascending order in the legend
     this.Chart2.DataManipulator.Sort(PointSortOrder.Descending, Chart2.Series[0]);
 }

قم أيضًا بزيارة موقع الويب هذا أيضًا ، فأنا آخذ هذا الرمز من هذا الموقع التعليمي اللطيف جدًا على MsChartshttp://betterdashboards.wordpress.com/2009/02/04/display-percentages-on-a-pie-char

... وجواب بن بتنسيق vb.net:

Chart1.Series(0)("PieLabelStyle") = "Disabled"

يعمل بشكل جيد لوضع سلسلة كاملة

objChart.ChartAreas[0].AxisY.LabelStyle.Enabled = false;

يمكن أيضًا القيام بذلك في واجهة المستخدم بواسطة

  1. فتح نافذة محرر السلسلة (زر Ellipsis في لوحة الخصائص الرئيسية)
  2. اختيار السلسلة المطلوبة
  3. توسيع CustomProperties منشأه
  4. الاختيار Disabled

Example

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top