-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
怎么更改生成的折线图的线的颜色? #104
Comments
@wangchunle 您可以使用Stroke.Color设置折线图中线条的颜色。 例如看下面的代码: Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add chart with default data. You can specify different chart types and sizes.
Shape shape = builder.insertChart(ChartType.LINE, 432, 252);
// Chart property of Shape contains all chart related options.
Chart chart = shape.getChart();
// Get chart series collection.
ChartSeriesCollection seriesColl = chart.getSeries();
// Delete default generated series.
seriesColl.clear();
// Create category names array, in this example we have two categories.
String[] categories = new String[] { "AW Category 1", "AW Category 2" };
// Adding new series. Please note, data arrays must not be empty and arrays must be the same size.
ChartSeries s1 = seriesColl.add("AW Series 1", categories, new double[] { 1, 2 });
ChartSeries s2 = seriesColl.add("AW Series 2", categories, new double[] { 3, 4 });
ChartSeries s3 = seriesColl.add("AW Series 3", categories, new double[] { 5, 6 });
ChartSeries s4 = seriesColl.add("AW Series 4", categories, new double[] { 7, 8 });
// Set color of the lines
s1.getFormat().getStroke().setColor(Color.red);
s2.getFormat().getStroke().setColor(Color.black);
s3.getFormat().getStroke().setColor(Color.blue);
s4.getFormat().getStroke().setColor(Color.yellow);
doc.save("C:\\Temp\\out.docx"); PS: 获得支持的主要场所是 Aspose.Words 支持论坛。 |
@AlexNosk 谢谢,请问getFormat()这个方法哪个版本才有?我现在项目里用的是19.5版本的,好像没有这个方法。 |
@wangchunle 此功能从 Aspose.Words 21.6 版本开始可用: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
怎么更改生成的折线图的线的颜色?
The text was updated successfully, but these errors were encountered: