• <menu id="w2i4a"></menu>
  • logo Spire.Doc系列教程

    文檔首頁(yè)>>Spire.Doc系列教程>>Spire.Doc系列教程(10): 給 PowerPoint 圖表添加數(shù)據(jù)標(biāo)簽并設(shè)置外觀樣式

    Spire.Doc系列教程(10): 給 PowerPoint 圖表添加數(shù)據(jù)標(biāo)簽并設(shè)置外觀樣式


    <p>數(shù)據(jù)標(biāo)簽可以顯示圖表中的數(shù)據(jù)系列或其單個(gè)數(shù)據(jù)點(diǎn)的詳細(xì)信息,使圖表更易于理解。本文將介紹如何使用Spire.Presentation給PowerPoint圖表添加數(shù)據(jù)標(biāo)簽并設(shè)置數(shù)據(jù)標(biāo)簽的外觀樣式(邊框樣式、填充樣式)。注意有些圖表類型如Surface3D、Surface3DNoColor、Contour、ContourNoColor這幾種圖表不支持設(shè)置數(shù)據(jù)標(biāo)簽。
    <br/>
    以下是原PowerPoint圖表的截圖</p>

    <div class="text-center"><img alt="Spire.Doc" class="img-thumbnail" src="http://image.evget.com/images/article/2018/L-20181009-PPT-1.png" style="border:0" /></div>

    
    //創(chuàng)建Presentation實(shí)例
    Presentation ppt = new Presentation();
    //加載PowerPoint文檔
    ppt.LoadFromFile("Input.pptx");
    
    //獲取圖表
    IChart chart = ppt.Slides[0].Shapes[0] as IChart;
    
    //給圖表的第一個(gè)系列添加數(shù)據(jù)標(biāo)簽,并設(shè)置數(shù)據(jù)標(biāo)簽的格式
    
    //給第一個(gè)數(shù)據(jù)點(diǎn)添加數(shù)據(jù)標(biāo)簽
    ChartDataLabel label1 = chart.Series[0].DataLabels.Add();
    //顯示標(biāo)簽的值
    label1.LabelValueVisible = true;
    //顯示標(biāo)簽的系列名稱
    label1.SeriesNameVisible = true;
    //設(shè)置標(biāo)簽的邊框樣式
    label1.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
    label1.Line.SolidFillColor.Color = Color.Red;
    //設(shè)置標(biāo)簽的填充樣式
    label1.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
    label1.Fill.SolidColor.Color = Color.Yellow;
    
    //給第二個(gè)數(shù)據(jù)點(diǎn)添加數(shù)據(jù)標(biāo)簽
    ChartDataLabel label2 = chart.Series[0].DataLabels.Add();
    //顯示標(biāo)簽的值
    label2.LabelValueVisible = true;
    //顯示標(biāo)簽的系列名稱
    label2.SeriesNameVisible = true;
    //設(shè)置標(biāo)簽的邊框樣式
    label2.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
    label2.Line.SolidFillColor.Color = Color.Red;
    //設(shè)置標(biāo)簽的填充樣式
    label2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
    label2.Fill.SolidColor.Color = Color.Yellow;
    
    //給第三個(gè)數(shù)據(jù)點(diǎn)添加數(shù)據(jù)標(biāo)簽
    ChartDataLabel label3 = chart.Series[0].DataLabels.Add();
    //顯示標(biāo)簽的值
    label3.LabelValueVisible = true;
    //顯示標(biāo)簽的系列名稱
    label3.SeriesNameVisible = true;
    //設(shè)置標(biāo)簽的邊框樣式
    label3.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
    label3.Line.SolidFillColor.Color = Color.Red;
    //設(shè)置標(biāo)簽的填充樣式
    label3.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
    label3.Fill.SolidColor.Color = Color.Yellow;
    
    //給第四個(gè)數(shù)據(jù)點(diǎn)添加數(shù)據(jù)標(biāo)簽
    ChartDataLabel label4 = chart.Series[0].DataLabels.Add();
    //顯示標(biāo)簽的值
    label4.LabelValueVisible = true;
    //顯示標(biāo)簽的系列名稱
    label4.SeriesNameVisible = true;
    //設(shè)置標(biāo)簽的邊框樣式
    label4.Line.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
    label4.Line.SolidFillColor.Color = Color.Red;
    //設(shè)置標(biāo)簽的填充樣式
    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="http://image.evget.com/images/article/2018/L-20181009-PPT-2.png" style="border:0" /></div>
     

     

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();