2014-09-19 3 views
0

Мы используем открытый xml для отображения гистограммы в exl-экспорте, но на нем нет ярлыков данных, таких как значения над каждым баром. Вот код, я используюОтображение меток данных в открытых xml-диаграммах в C#

BarChart barChart = plotArea.AppendChild<BarChart>(new BarChart(new BarDirection() { Val = new   EnumValue<BarDirectionValues>(BarDirectionValues.Column) }, 
       new BarGrouping() { Val = new EnumValue<BarGroupingValues>(BarGroupingValues.Clustered) })); 
BarChartSeries barChartSeries = barChart.AppendChild<BarChartSeries>(new BarChartSeries(new Index() 
       { 
        Val = 
         new UInt32Value(i) 
       }, 
        new Order() { Val = new UInt32Value(i) }, 
        new SeriesText(new NumericValue() { Text = key }))); 

где ключ значение данных для бара. Но все же он не отображается. Может ли кто-нибудь сказать, где именно нужно помещать метку данных, чтобы метки значений были видны поверх каждого столбца на гистограмме

ответ

0

Вам просто нужно создать класс DataLabels, изменить, как вы хотите, чтобы они выглядели и добавили его к вашему серии. Упование это помогает

 C.DataLabels dataLabels2 = new C.DataLabels(); 

     C.TextProperties textProperties2 = new C.TextProperties(); 
     A.BodyProperties bodyProperties2 = new A.BodyProperties(); 
     A.ListStyle listStyle2 = new A.ListStyle(); 

     A.Paragraph paragraph2 = new A.Paragraph(); 

     A.ParagraphProperties paragraphProperties2 = new A.ParagraphProperties(); 

     A.DefaultRunProperties defaultRunProperties2 = new A.DefaultRunProperties() { FontSize = 700 }; 

     A.SolidFill solidFill2 = new A.SolidFill(); 
     A.SchemeColor schemeColor2 = new A.SchemeColor() { Val = A.SchemeColorValues.Background1 }; 

     solidFill2.Append(schemeColor2); 

     defaultRunProperties2.Append(solidFill2); 

     paragraphProperties2.Append(defaultRunProperties2); 
     A.EndParagraphRunProperties endParagraphRunProperties2 = new A.EndParagraphRunProperties() { Language = "en-US" }; 

     paragraph2.Append(paragraphProperties2); 
     paragraph2.Append(endParagraphRunProperties2); 

     textProperties2.Append(bodyProperties2); 
     textProperties2.Append(listStyle2); 
     textProperties2.Append(paragraph2); 
     C.ShowLegendKey showLegendKey2 = new C.ShowLegendKey() { Val = false }; 
     C.ShowValue showValue2 = new C.ShowValue() { Val = true }; 
     C.ShowCategoryName showCategoryName2 = new C.ShowCategoryName() { Val = false }; 
     C.ShowSeriesName showSeriesName2 = new C.ShowSeriesName() { Val = false }; 
     C.ShowPercent showPercent2 = new C.ShowPercent() { Val = false }; 
     C.ShowBubbleSize showBubbleSize2 = new C.ShowBubbleSize() { Val = false }; 
     C.ShowLeaderLines showLeaderLines2 = new C.ShowLeaderLines() { Val = false }; 

     dataLabels2.Append(textProperties2); 
     dataLabels2.Append(showLegendKey2); 
     dataLabels2.Append(showValue2); 
     dataLabels2.Append(showCategoryName2); 
     dataLabels2.Append(showSeriesName2); 
     dataLabels2.Append(showPercent2); 
     dataLabels2.Append(showBubbleSize2); 
     dataLabels2.Append(showLeaderLines2); 


     barChartSeries2.Append(dataLabels2); 
Смежные вопросы