private static void Main(string[] args){Document doc = new Document();DocumentBuilder builder = new DocumentBuilder(doc);builder.Writeln("普通饼图:");AddPieChart(builder);builder.Writeln();builder.Writeln("3D饼图:");AddPie3dChart(builder);doc.Save("abc.docx");}/// <summary>/// 添加饼图/// </summary>private static void AddPieChart(DocumentBuilder builder){AddPieChart(builder,ChartType.Pie,"普通饼图");}/// <summary>/// 添加3D饼图/// </summary>private static void AddPie3dChart(DocumentBuilder builder){AddPieChart(builder,ChartType.Pie3D,"3D饼图");}private static void AddPieChart(DocumentBuilder builder, ChartType chatType, string title){var shape = builder.InsertChart(chatType, 200, 200);Chart chart = shape.Chart;ChartSeriesCollection seriesCollection = chart.Series;seriesCollection.Clear();//清除默认//类别var categories = new string[]{"1", "2", "3", "4"};//值var values = new double[]{20, 20, 30, 40};chart.Legend.Position= LegendPosition.Right;//显示在右边//添加数据var chatSeries = seriesCollection.Add(title,categories , values);//设置数据显示
            SetChartSeriesDataLabel(chatSeries,categories.Count());}private static void SetChartSeriesDataLabel(ChartSeries chatSeries,int count){ChartDataLabelCollection dataLabelCollection = chatSeries.DataLabels;for (int i = 0; i < count; i++){ChartDataLabel chartDataLabel = dataLabelCollection.Add(i);chartDataLabel.ShowLegendKey = true;chartDataLabel.ShowLeaderLines = true;chartDataLabel.ShowCategoryName = true;chartDataLabel.ShowPercentage = true;chartDataLabel.ShowSeriesName = false;chartDataLabel.ShowValue = true;chartDataLabel.Separator = "  ";}}说明:目前还有一个问题,就是通过aspose.words插入的图表目前还不支持右键编辑数据功能,这个查看了官方的回复,说现阶段还不支持,具体的可以参考一下地址说明https://forum.aspose.com/t/unable-to-edit-chart-data-manually-in-word-chart-using-apose-word-for-net-15-6-0/44166https://forum.aspose.com/t/how-to-enable-data-editing-of-chart-in-ms-word/24575

转载于:https://www.cnblogs.com/sczmzx/p/8352445.html

c# Aspose.Words插入饼图PieChart相关推荐

  1. label mpchart 饼图_MPAndroidChart之饼图PieChart

    前段时间没Android端的需求,所以在学前端,所以也差不多有一个多月没更新文章了,前端我是新手也基本没法写什么文章,只能总结一些比较基础的内容,然后现在暂时Android这边又开始了新的版本开发,所 ...

  2. piechart 文档 android,Android饼图 PieChart

    PieChart 饼图,android 图表.会根据定义PieChartView的大小自动居中,所以如果要调整位置,只需要在xml更改PieChartView位置大小即可. 1.先看一下效果图: 展示 ...

  3. Flex 饼图PieChart

    <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="h ...

  4. MPAndroidChart饼图PieChart的使用

      在一个安卓项目中大量使用了MPAndroidChart的饼图,所以大致总结一下使用方法. 1.引入   app下的build.gradle中加入: implementation 'com.gith ...

  5. MPAndroidChart饼图PieChart

    之前的记账软件中,加入了GitHub上的开源项目,MPAndroid. 现在介绍一下饼状图. 首先将MPAndroidChart的jar包导入到libs中,jar包的链接可以去girhub下载,进去找 ...

  6. Android MPAndroidChart之饼图PieChart

    APP为了能让用户对数据有更直观,更便捷的认识,我们通常都选择了以图表的方式展示给用户,如折线图.饼图.条形图等-今天和大家分享下MPAndroidChart,一个强大便捷的图标控件. Android ...

  7. LiveChart:如何使用饼图PieChart

    代码如下: 前端代码: 注意:这里主要内容是Series属性,Series绑定到后端的PieSeries legendLocation:表示标签在饼图的哪个位置,Right表示在右边 InnerRad ...

  8. aspose.word 插入段落样式失效或段落文本样式无效 请配合正确食用方式

    Apose.word 样式失效的情况,再根据目前自己跌倒的次数,自己默默写上一点笔记 以下将展示一些aspose word 文档的属性和一些方法给大家参照 方便日后处理文档查找解决方法使用.请大家自行 ...

  9. Aspose.Cells 插入行和列(插入单行、插入多行、插入单列、插入多列)

    1 插入单行 1.1 InsertRow(int rowIndex) Workbook workbook=new Workbook(); WorkSheet worksheet=workbook.Wo ...

最新文章

  1. LeetCode简单题之删除字符使字符串变好
  2. 案例解析|广东自由流收费稽核方案,AI稽核新模式
  3. 【计算机网络】—— 差错编码(纠错编码)
  4. tensorflow windows
  5. SpringMvc2 使用注解形式发布请求地址
  6. VALSE学习(二):行人重识别研究进展回顾
  7. 《软件构架实践》读后感-02
  8. mysql 分组 前几条_查询分组后每个分组的前几条记录
  9. 8uftp链接linux,8UFTP工具,FTP工具连接的办法,配置方式
  10. 回归预测 | MATLAB实现DBN深度置信网络多输入单输出回归预测
  11. [原创]MASM32新手指南
  12. 深度学习:Nvidia显卡驱动安装
  13. 第一章 FreeSWITCH 的架构
  14. 游戏优化利器 | Android GPU Inspector 开放 Beta 测试版
  15. JVM 面试 4 连炮,你能顶住么?
  16. Excel.Application使用手册(API)
  17. 五分钟理解MVC三层架构
  18. pr导出视频在哪里?
  19. python实现打开笔记本摄像头
  20. java什么是线程安全_什么是线程安全?

热门文章

  1. LINUX命令之stat及显示的三个时间戳
  2. zypper 工具详解
  3. 快速通过软件设计师考试方法
  4. VS2005-此计算机下已安装了试用版,必须先卸载以前安装的试用版后才能安装另一个试用版
  5. 字符编码详解及由来(UNICODE,UTF-8,GBK)
  6. L3-019 代码排版 (30 分)-PAT 团体程序设计天梯赛 GPLT
  7. Unsupported major.minor version (jdk版本错误)解决方案办法
  8. Spring中定时任务Quartz集群配置学习
  9. Windows下Tuxedo的安装与配置-无数据库
  10. 百度定位---适配8.0限制后台定位