Clustered Column chart with secondary value axis

Dear all,

I would like to create a chart based on the principle described in the following post (using a secondary value axis)

Instead of showing the secondary data series as a line, I would like to use two columns to display both values for each category item. If I comment out the type property of the second data series, the resulting chart contains only one column for each category item. Can you please tell me what’s wrong?

Thanks

Erik

Dear all,

please find attached a sample file the shows how the diagram should look like. It is possible to realize this with Aspose?

Erik

Hi,

If you don’t want to plot the second data series on secondary axis, you may just skip/exclude the code regarding plotting the second series on the secondary axis line.

If you still could not sort it out, kindly create a sample chart in MS Excel manually and post the generated xls file (containing the sample chart) here, we will check and tell you how to create such a chart using the Aspose.Cells for .NET APIs.


Thank you.

Dear all,

Please find attached further information about the mentioned issue. You can use the code and the xls file to create the initial chart. The excel files contains also worksheets showing different results based on the steps described below.

The chart contains 4 data rows (Master1, Master2, Detail1, Detail2). To reach the desired result it is necessary to perform the following steps (Excel)

Edit data row Detail1 à Set axis to Secondary

Edit data row Detail2 à Set axis to Secondary

Edit data row Master 2 à Set color and border to non

Edit data row Detail 1 à Set color and border to non

Now you should get a chart that looks like the one shown on Worksheet “Chart edited excel”

If I try to apply the procedure in my code, I get always a different result (see worksheet “Chart created with Aspose”, I just apply the first tow steps)

chart.NSeries[0].Name = "Master1";

chart.NSeries[1].Name = "Master2";

chart.NSeries[2].Name = "Detail1";

chart.NSeries[2].PlotOnSecondAxis = true;

chart.NSeries[3].Name = "Detail2";

chart.NSeries[3].PlotOnSecondAxis = true;

chart.SecondValueAxis.IsVisible = true;

Can you please tell me how to implement the shown procedure?

Thanks in advance

Erik

Hi,

Thanks for providing us details.

We will get back to you soon if we can guide you through to generate your desired chart.

Thank you.

Hi,

Thank you for considering Aspose.

Please try the following code and check if it fits your requirement.

Workbook wb = new Workbook();

wb.Open(@"C:\ColumnChartDemo.xls");

Worksheet wsChart = wb.Worksheets[0];


//Erzeugen des Diagramms und setzen der wesentlichen Eigenschaften

int chartIndex = wsChart.Charts.Add(ChartType.Column, 1, 1, 25, 10);

Chart chart = wsChart.Charts[chartIndex];

//Hauptgridzeielen einblenden

chart.MajorGridLines.IsVisible = true;

//Grundfarbe weiß

chart.PlotArea.Area.ForegroundColor = System.Drawing.Color.White;

//Kein umschließender Rahmen

chart.ChartArea.Border.IsVisible = false;


//Festlegung der Datenquelle

chart.NSeries.Add("'Data'!B2:B11", true);

chart.NSeries.Add("'Data'!B2:B11", true);

chart.NSeries.Add("'Data'!C2:C11", true);

chart.NSeries.Add("'Data'!C2:C11", true);


chart.NSeries.CategoryData = "'Data'!A2:A11";

chart.NSeries.SecondCatergoryData = "'Data'!A2:A11";


//chart.NSeries[0].PlotOnSecondAxis = true;

chart.NSeries[0].Name = "Master1";

//chart.NSeries[1].PlotOnSecondAxis = true;

chart.NSeries[1].Name = "Master2";

//Edit data row Master 2 Set color and border to non

chart.NSeries[1].Line.IsVisible = false;

chart.NSeries[1].Area.Formatting = FormattingType.None;

chart.NSeries[2].Name = "Detail1";

// Edit data row Detail1 Set axis to Secondary

chart.NSeries[2].PlotOnSecondAxis = true;

//Edit data row Detail 1 Set color and border to non

chart.NSeries[2].Line.IsVisible = false;

chart.NSeries[2].Area.Formatting = FormattingType.None;

//Edit data row Detail2 Set axis to Secondary

chart.NSeries[3].Name = "Detail2";

chart.NSeries[3].PlotOnSecondAxis = true;

chart.SecondValueAxis.IsVisible = true;

//Second value Axis doest not cross at the max.

chart.SecondValueAxis.Crosses = CrossType.Automatic;

//Legende Ausblenden

chart.IsLegendShown = false;


//Platzierung auf der Folie vornehmen

chart.ChartObject.HeightCM = 14;

chart.ChartObject.WidthCM = 25;

chart.ChartObject.UpperLeftColumn = 2;

chart.ChartObject.UpperLeftRow = 7;

chart.Placement = PlacementType.FreeFloating;

wb.Save(@"C:\reportColumnAspose.pdf", FileFormatType.Pdf);

wb.Save(@"C:\reportColumnAspose.xls");

Thank You & Best Regards,

Hi,

thanks a lot. The code shown above generates the desired chart.

Regards

Erik