Need a sample aspose program to plot combo chart in excel with clustered column and stacked column on secondary axis

Need a sample aspose program to plot combo chart in excel with clustered column on primary and stacked column on secondary axis. Both chart should be plotted from bottom horizontal x axis.

@VaradS,

See the document with example code on how to create a combo chart for your reference.
https://docs.aspose.com/cells/java/create-combo-chart/

Moreover, you may use Series.PlotOnSecondAxis attribute to set to true to plot a series on secondary axis. See the document to learn and work with primary and secondary axes via Aspose.Cells.
https://docs.aspose.com/cells/java/primary-and-second-axis/

Please refer to the example and then write your code using Aspose.Cells for your requirements. If you encounter any issues, please provide your current sample (runnable) code and Excel file(s). Additionally, include a sample Excel file containing your expected chart. You may create your desired chart in MS Excel manually. We will review and assist you in achieving the same result using Aspose.Cells API.

PS. please zip the Excel files prior attaching here.

Hi @VaradS
According to the documentation, we have provided you with the following code for your reference, hope to be helpful:

        // Create an instance of Workbook
        Workbook workbook = new Workbook();
        // Access the first worksheet.
        Worksheet worksheet = workbook.Worksheets[0];
        // Put the sample values used in a chart
        worksheet.Cells["A1"].PutValue("Region");
        worksheet.Cells["A2"].PutValue("Peking");
        worksheet.Cells["A3"].PutValue("New York");
        worksheet.Cells["A4"].PutValue("Paris");
        worksheet.Cells["B1"].PutValue("Sales Volume");
        worksheet.Cells["C1"].PutValue("Growth Rate");
        worksheet.Cells["B2"].PutValue(100);
        worksheet.Cells["B3"].PutValue(80);
        worksheet.Cells["B4"].PutValue(140);
        worksheet.Cells["C2"].PutValue(0.7);
        worksheet.Cells["C3"].PutValue(0.8);
        worksheet.Cells["C4"].PutValue(1.0);
        // Create a Scatter chart 
        int pieIdx = worksheet.Charts.Add(ChartType.Column, 6, 6, 15, 11);
        // Retrieve the Chart object
        Chart chart = worksheet.Charts[pieIdx];
        // Add Series
        chart.NSeries.Add("B2:C4", true);
        // Set the category data
        chart.NSeries.CategoryData = "=Sheet1!$A$2:$A$4";
        // Set the Second-Axis 
        chart.NSeries[1].PlotOnSecondAxis = true;
        // Show the Second-Axis
        chart.SecondValueAxis.IsVisible = true;
        // Set the second series ChartType to line
        chart.NSeries[1].Type = Aspose.Cells.Charts.ChartType.ColumnStacked;
        // Set the series name 
        chart.NSeries[0].Name = "Sales Volume";
        chart.NSeries[1].Name = "Growth Rate";
        // Set the Legend at the bottom of the chart area
        chart.Legend.Position = LegendPositionType.Bottom;
        // Fill the PlotArea area with nothing 
        chart.PlotArea.Area.FillFormat.FillType = FillType.None;
        // Save the file
        workbook.Save(path + "Output.xlsx");

Hi Team, thanks for your quick response. Your provided documents help me to achieve for some extend but need your help to achieve it fully. I’m attaching the excel sheet here where I have added a desired combo chart. Could you please help me to draw that with aspose.
DualAxisComboAs.zip (12.2 KB)

Hi @VaradS
Please check the following code, “Data.xlsx” is the data in you sample file.

        Workbook workbook = new Workbook(path + "Data.xlsx");
        Worksheet worksheet = workbook.Worksheets[0];
        int pieIdx = worksheet.Charts.Add(ChartType.Column, 6, 6, 25, 21);
        Chart chart = worksheet.Charts[pieIdx];
        chart.Title.Text = "Dual Axis Combo";
        chart.NSeries.Add("C3:F10", true);
        chart.NSeries.CategoryData = "=Sheet1!$B$3:$B$10";
        chart.SecondValueAxis.IsVisible = true;
        chart.NSeries[2].PlotOnSecondAxis = true;
        chart.NSeries[3].PlotOnSecondAxis = true;
        chart.NSeries[2].Type = Aspose.Cells.Charts.ChartType.ColumnStacked;
        chart.NSeries[3].Type = Aspose.Cells.Charts.ChartType.ColumnStacked;
        chart.NSeries[0].Name = "=Sheet1!$C$2";
        chart.NSeries[1].Name = "=Sheet1!$D$2";
        chart.NSeries[2].Name = "=Sheet1!$E$2";
        chart.NSeries[3].Name = "=Sheet1!$F$2";
        chart.Legend.Position = LegendPositionType.Bottom; 
        chart.PlotArea.Area.FillFormat.FillType = FillType.None;
        workbook.Save(path + "Output2.xlsx");

Data.zip (7.0 KB)