I want to display the invisible bar for the column chart along with Labels.
And I want to display Labels on SecondaryHorizontalAxis, it is getting displayed,
but SecondaryHorizontalAxis is not starting from Top, it is starting after some gap, due to which it is not aligned.
Please help me out with this thanks.
Please zip and attach the following resource files:
- Your input Excel file (if any)
- Output Excel file containing your undesired chart
- Excel file with your expected chart in it, you may create/update the chart in MS Excel manually to save the Excel file
- Your current sample code (runnable without compile time errors) to generate the output Excel file containing your undesired chart in it.
After getting the above resource files, we will start evaluating your issue/requirements and assist you accordingly.
To start with, I am attaching the excel file which @Rohan_Wankar has mentioned. In the attached excel, there is a secondary horizontal axis, which is not starting from the top of the y axis, instead there is a space as shown below :
image.png (22.7 KB)
Could you please help us in pushing this axis from the top of yaxis first manually in the excel file? then we can go with programmatical approach. attaching the excel as well. MultibarVertical+Label.zip (10.9 KB)
Thanks in advance!
I am sorry but we could not understand your needs precisely, so do not know how to accomplish the task in MS Excel manually. As requested kindly perform your task in MS Excel manually for your chart’s desired display/formatting and save the file to provide us here, we will check on how to do it via Aspose.Cells APIs.
@Thilakbabu attached the zipped archive in his post but it does not have his expected chart in the file “MultibarVertical+Label.xlsx” rather he asked me to do it manually in MS Excel:
I tried but could not accomplish the task in MS Excel manually, so I asked him to provide your expected chart (created in MS Excel manually) in the file.
Anyways, is the chart in “MultibarVertical+Label.xlsx” your expected chart, please confirm? We will devise a code segment via Aspose.Cells APIs after your confirmation.
See the following sample code to accomplish your task. You may refer to the code segment and update or write your code for your custom needs accordingly. I used your file for chart’s data source and generate the custom chart in a new sheet.
Workbook workbook = new Workbook("e:\\test2\\MultibarVertical+Label.xlsx"); Worksheet worksheet = workbook.Worksheets["DataSheet"]; Worksheet sheet = workbook.Worksheets[workbook.Worksheets.Add()]; int chartIndex = sheet.Charts.Add(ChartType.Column, 5, 2, 21, 15); //Accessing the instance of the newly added chart Chart chart = sheet.Charts[chartIndex]; chart.NSeries.Add("=((DataSheet!$C$2,DataSheet!$C$4),DataSheet!$C$6,DataSheet!$C$8)", true); chart.NSeries.Add("=((DataSheet!$C$3,DataSheet!$C$5),DataSheet!$C$7,DataSheet!$C$9)", true); //Add category data for the primary series. chart.NSeries.CategoryData = "=(DataSheet!$A$2,DataSheet!$A$4,DataSheet!$A$6,DataSheet!$A$8)"; chart.NSeries.Name = "Coffee"; chart.NSeries.Name = "Tea"; chart.NSeries.Add("=((DataSheet!$D$2,DataSheet!$D$4),DataSheet!$D$6,DataSheet!$D$8)", true); chart.NSeries.Add("=((DataSheet!$D$3,DataSheet!$D$5),DataSheet!$D$7,DataSheet!$D$9)", true); chart.NSeries.PlotOnSecondAxis = true; chart.NSeries.Name = "Coffee"; chart.NSeries.DataLabels.ShowValue = true; chart.NSeries.DataLabels.Position = LabelPositionType.InsideBase; chart.NSeries.PlotOnSecondAxis = true; chart.NSeries.Name = "Tea"; chart.NSeries.DataLabels.ShowValue = true; chart.NSeries.DataLabels.Position = LabelPositionType.InsideBase; chart.NSeries.Area.FillFormat.FillType = FillType.None; chart.NSeries.Area.FillFormat.FillType = FillType.None; chart.SecondValueAxis.IsVisible = true; chart.PlotArea.Area.ForegroundColor = Color.White; chart.Legend.Position = LegendPositionType.Bottom; chart.Legend.LegendEntries.IsDeleted = true; chart.Legend.LegendEntries.IsDeleted = true; workbook.Save("e:\\test2\\out1.xlsx");
Hope, this helps a bit.
I want to display another chart with an invisible bar from the top. But SecondaryHorizontal axes position is still not getting changed.
I tried setting the series for other chart plotOnSecondAxis to true.
But no success.
Can you help in plotting the invisible bar from the top of the SecondaryHorizontal axis?
Please provide the following artifacts and resource files, so we could evaluate your task:
- Current output Excel file by Aspose.Cells APIs containing your undesired custom chart.
- An Excel file containing your desired chart (invisible bar plotted from the top of the SecondaryHorizontal axis), you may create the chart in MS Excel manually.
- Your current sample code that you are using that creates your undesired chart.
Please note, Aspose.Cells follows MS Excel standards and specifications when creating or manipulating charts. So, if MS Excel cannot accomplish your task manually, Aspose.Cells cannot do it as well.