Column chart Issue

I have attached the chart showing what I am expecting and what I am getting. Can you help with this code?
ColumnChart_A_R (2).zip (32.8 KB)

@sanjeevkumar.v

To assist you with your column chart issue, I recommend reviewing the following example code that demonstrates how to create a column chart using Aspose.Cells. This code snippet initializes a workbook, adds sample data, and creates a column chart based on that data.

using System;
using Aspose.Cells;
using Aspose.Cells.Charts;

namespace Aspose.Cells.Examples
{
    public class CreateColumnChart
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Add sample data to the worksheet
            worksheet.Cells["A1"].PutValue("Category 1");
            worksheet.Cells["A2"].PutValue("Category 2");
            worksheet.Cells["A3"].PutValue("Category 3");
            worksheet.Cells["B1"].PutValue(10);
            worksheet.Cells["B2"].PutValue(20);
            worksheet.Cells["B3"].PutValue(30);

            // Add a column chart to the worksheet
            int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 25, 10);
            Chart chart = worksheet.Charts[chartIndex];

            // Set the data source for the chart
            chart.NSeries.Add("B1:B3", true);
            chart.NSeries[0].Name = "Values";

            // Save the workbook
            workbook.Save("ColumnChartExample.xlsx");
            Console.WriteLine("Column chart created successfully.");
        }
    }
}

Make sure to adjust the data range and chart properties according to your specific requirements. If you are facing a specific issue with the chart’s appearance or data representation, please provide more details so I can assist you further.

For more information on creating and customizing charts, you can refer to the Aspose documentation on chart management here.

Sources:
[1]: Create and Manage Chart - Aspose Documentation

@sanjeevkumar.v,

See the following sample code for your reference (I have updated/added a few lines). You may update it further to accommodate your needs and to draw your desired chart.
e.g.,
Sample code:


    Workbook workbook = new Workbook();
    Worksheet sheet = workbook.Worksheets[0];

    sheet.Cells["A1"].PutValue("Category");
    sheet.Cells["B1"].PutValue("Achieved Score");
    sheet.Cells["C1"].PutValue("Required Score");

    string[] categories = { "Charisma", "Cooperation", "Friendliness", "Humility", "Trustworthiness" };
    double[] achievedScores = { 8.5, 7.1, 6.3, 5.8, 4.7 };
    double[] requiredScore = { 9.0, 9.0, 9.0, 8.5, 8.5 };

    for (int i = 0; i < categories.Length; i++)
    {
        sheet.Cells[i + 1, 0].PutValue(categories[i]);
        sheet.Cells[i + 1, 1].PutValue(achievedScores[i]);
        sheet.Cells[i + 1, 2].PutValue(requiredScore[i]);
    }

    int chartIndex = sheet.Charts.Add(ChartType.ColumnStacked, 5, 0, 25, 10);
    Chart chart = sheet.Charts[chartIndex];

    chart.NSeries.Add("B2:B6", true);
    chart.NSeries.CategoryData = "A2:A6";
    chart.NSeries[0].Name = "Achieved Score";
    chart.NSeries[0].Area.ForegroundColor = System.Drawing.Color.LightBlue;

    chart.NSeries.Add("C2:C6", true);
    chart.NSeries[1].Name = "Required Score";
    chart.NSeries[1].Type = ChartType.Line;
    chart.NSeries[1].Border.IsVisible = false;
    chart.NSeries[1].Marker.MarkerStyle = ChartMarkerType.Dash;
    chart.NSeries[1].Marker.MarkerSize= 19;
    chart.NSeries[1].Marker.BackgroundColor  = System.Drawing.Color.DarkBlue;
    

    chart.NSeries[1].Overlap = 100; 
    chart.NSeries[1].GapWidth = 0;

    chart.Title.Text = "Performance Evaluation";
    chart.Legend.Position = LegendPositionType.Top;

    chart.CategoryAxis.TickLabels.RotationAngle = 45;

    chart.ChartArea.Border.IsVisible = false;
    chart.PlotArea.Border.IsVisible = false;
    chart.ChartArea.Area.FillFormat.FillType = Aspose.Cells.Drawing.FillType.None;
    chart.PlotArea.Area.FillFormat.FillType = Aspose.Cells.Drawing.FillType.None;

    workbook.Save("e:\\test2\\ChartOutput.xlsx");

Hi @amjad.sahi
thank you! This code helped me so much.

@sanjeevkumar.v
Thank you for your feedback. I’m glad the sample code meets your needs. If you have any questions, please feel free to contact us at any time.