Aspose.Words无需Microsoft Word也可在任何平台上知足Word文档的一切操做需求。本文将与你们分享如何检测文件格式和检查格式兼容性。git
图表是一种很是有用的工具,能以图形的方式表示或可视化任何类型的数据,从而对目标受众产生最大的影响。图表能够让用户查看所表示数据的结果,以便更好地理解和预测当前和将来的数据。
github
在Word文档中,能够根据用户的须要使用各类类型的图表。为了使图表更易于理解,能够将图表标题和轴标题添加到图表中。轴标题一般适用于能够在图表中显示的全部轴,最经常使用的图表类型有两个轴。 沿图表底部的X轴是横轴,沿图表左侧的Y轴是纵轴。bash
在某些状况下,用户可能须要隐藏图表轴或其中任何一个。使用Aspose.Words for .NET,能够经过将特定轴的ChartAxis.Hidden属性值设置为false来实现。此属性指示此轴是否隐藏。默认值为false。ide
如下代码段显示了如何隐藏图表的Y轴。工具
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
Chart chart = shape.Chart;
// Clear demo data.
chart.Series.Clear();
// Fill data.
chart.Series.Add("AW Series 1",
new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" },
new double[] { 1.2, 0.3, 2.1, 2.9, 4.2 });
// Hide the Y axis.
chart.AxisY.Hidden = true;
dataDir = dataDir + @"HideChartAxis_out.docx";
doc.Save(dataDir);
复制代码
下面给出了图表的结果视图,其中隐藏了Y轴:ui
在使用ChartAxis时,Aspose.Words for .NET可以让用户自定义标签对齐的方式。默认状况下,Microsoft Word会将全部轴标签对齐到中心,以下所示:spa
TickAabelAlignment属性已在ChartAxis类下引入,用于设置标签对齐。ChartAxis类表示图表的轴选项。TickLabelAlignment属性可获取或设置轴刻度标签的文本对齐方式,仅在多行标签的状况下才有效。 默认值为“ParagraphAlignment.Center”。code
如下代码段显示了TickLabelAlignment的工做状况。cdn
Document doc = new Document(dataDir + "Document.docx");
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
ChartAxis axis = shape.Chart.AxisX;
//This property has effect only for multi-line labels.
axis.TickLabelAlignment = ParagraphAlignment.Right;
doc.Save(dataDir + "Document_out.docx");复制代码
生成的图表视图以下所示:blog