2014-09-19 41 views
0

我们使用打开的xml在exl导出中显示条形图,但它没有在数据上显示标签,如每个条上方的值。 这里是我使用在c中打开xml图表显示数据标签#

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