有什么方法可以生成具有两个Y轴的Chart,谢谢

我看官网的例子里只有一个Y轴,我现在的需求是要有2个Y轴,请问我应该调用什么方法或设置什么属性,谢谢。附件图片是我想达到的效果:
image.png (14.9 KB)

@zzy0471,

感谢您的查询和屏幕截图。

使用Aspose.Cells API,您可以在电子表格/工作簿中创建MS Excel图表(标准,高级和自定义)。请参阅关于如何在Excel文件中创建自定义图表的文档主题:

关于生成带有两个y轴的图表,您可以根据需要尝试使用Series.PlotOnSecondAxis布尔属性。我已经编写了一个关于如何创建一个带有两个y轴的自定义图表的示例代码,供您参考。请参考它,您可以根据您的要求编写自己的代码:
e.g
Sample code:

     //Instantiating a Workbook object
    Workbook workbook = new Workbook();
    //Get the first worksheet in the workbook
    Worksheet worksheet = workbook.Worksheets[0];
    //Adding a sample value to "A1" cell
    worksheet.Cells["A1"].PutValue(50);
    //Adding a sample value to "A2" cell
    worksheet.Cells["A2"].PutValue(100);
    //Adding a sample value to "A3" cell
    worksheet.Cells["A3"].PutValue(150);
    //Adding a sample value to "A4" cell
    worksheet.Cells["A4"].PutValue(200);
    //Adding a sample value to "B1" cell
    worksheet.Cells["B1"].PutValue(60);
    //Adding a sample value to "B2" cell
    worksheet.Cells["B2"].PutValue(32);
    //Adding a sample value to "B3" cell
    worksheet.Cells["B3"].PutValue(50);
    //Adding a sample value to "B4" cell
    worksheet.Cells["B4"].PutValue(40);
    //Adding a chart to the worksheet
    int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 2, 21, 15);
    //Accessing the instance of the newly added chart
    Chart chart = worksheet.Charts[chartIndex];
    //Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B4"
    chart.NSeries.Add("A1:B4", true);
    //Setting the chart type of 2nd SeriesCollection to display as line chart
    chart.NSeries[1].Type = ChartType.Line; 
    chart.NSeries[1].PlotOnSecondAxis = true;
    chart.SecondValueAxis.IsVisible = true;

    chart.PlotArea.Area.ForegroundColor = Color.White;
    
    workbook.Save("e:\\test2\\out1.xlsx");

希望,这有帮助。

非常感谢您的回复。我忘记说明我想生成的是word文档,不好意思,用aspose.words api可以生成这样的文档吗,谢谢。docDemo.zip (24.1 KB)

@zzy0471

感谢您分享示例文档。请注意,目前Aspose.Words不支持创建组合图表。我们已经在我们的问题跟踪系统中登录了一张门票 WORDSNET-12769 来实现此功能。我们将您的帖子与问题ID相关联,并在实施后立即通知您。

谢谢回复。祝你工作顺利,万事如意

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan

The issues you have found earlier (filed as WORDSNET-12769) have been fixed in this Aspose.Words for .NET 24.5 update also available on NuGet.