轉帖|使用教程|編輯:李爽夏|2018-10-09 14:09:31.000|閱讀 809 次
概述:數據標簽可以顯示圖表中的數據系列或其單個數據點的詳細信息,使圖表更易于理解。本文將介紹如何使用Spire.Presentation給PowerPoint圖表添加數據標簽并設置數據標簽的外觀樣式(邊框樣式、填充樣式)。注意有些圖表類型如Surface3D、Surface3DNoColor、Contour、ContourNoColor這幾種圖表不支持設置數據標簽。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
<p>數據標簽可以顯示圖表中的數據系列或其單個數據點的詳細信息,使圖表更易于理解。本文將介紹如何使用Spire.Presentation給PowerPoint圖表添加數據標簽并設置數據標簽的外觀樣式(邊框樣式、填充樣式)。注意有些圖表類型如Surface3D、Surface3DNoColor、Contour、ContourNoColor這幾種圖表不支持設置數據標簽。
<br/>
以下是原PowerPoint圖表的截圖</p>
<div class="text-center"><img alt="Spire.Doc" class="img-thumbnail" src="//image.fc6vip.cn/images/article/2018/L-20181009-PPT-1.png" style="border:0" /></div>
//創建Presentation實例 Presentation ppt = new Presentation(); //加載PowerPoint文檔 ppt.LoadFromFile("Input.pptx"); //獲取圖表 IChart chart = ppt.Slides[0].Shapes[0] as IChart; //給圖表的第一個系列添加數據標簽,并設置數據標簽的格式 //給第一個數據點添加數據標簽 ChartDataLabel label1 = chart.Series[0].DataLabels.Add(); //顯示標簽的值 label1.LabelValueVisible = true; //顯示標簽的系列名稱 label1.SeriesNameVisible = true; //設置標簽的邊框樣式 label1.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; label1.Line.SolidFillColor.Color = Color.Red; //設置標簽的填充樣式 label1.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; label1.Fill.SolidColor.Color = Color.Yellow; //給第二個數據點添加數據標簽 ChartDataLabel label2 = chart.Series[0].DataLabels.Add(); //顯示標簽的值 label2.LabelValueVisible = true; //顯示標簽的系列名稱 label2.SeriesNameVisible = true; //設置標簽的邊框樣式 label2.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; label2.Line.SolidFillColor.Color = Color.Red; //設置標簽的填充樣式 label2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; label2.Fill.SolidColor.Color = Color.Yellow; //給第三個數據點添加數據標簽 ChartDataLabel label3 = chart.Series[0].DataLabels.Add(); //顯示標簽的值 label3.LabelValueVisible = true; //顯示標簽的系列名稱 label3.SeriesNameVisible = true; //設置標簽的邊框樣式 label3.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; label3.Line.SolidFillColor.Color = Color.Red; //設置標簽的填充樣式 label3.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; label3.Fill.SolidColor.Color = Color.Yellow; //給第四個數據點添加數據標簽 ChartDataLabel label4 = chart.Series[0].DataLabels.Add(); //顯示標簽的值 label4.LabelValueVisible = true; //顯示標簽的系列名稱 label4.SeriesNameVisible = true; //設置標簽的邊框樣式 label4.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; label4.Line.SolidFillColor.Color = Color.Red; //設置標簽的填充樣式 label4.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; label4.Fill.SolidColor.Color = Color.Yellow; //保存文檔 ppt.SaveToFile("DataLabels.pptx", FileFormat.Pptx2013);
<P>效果圖:</P>
<div class="text-center"><img alt="Spire.Doc" class="img-thumbnail" src="//image.fc6vip.cn/images/article/2018/L-20181009-PPT-2.png" style="border:0" /></div>
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: