Thanks for the sample code segment and screenshot.
Could you provide a sample Excel file (containing your desired chart in it, you may create/format the chart manually in MS Excel), we will check it soon. Also kindly provide your complete code (runnable) and output Excel file by Aspose.Cells APIs. This will help us evaluate your issue precisely and to consequently figure it out soon.
int index = sheet.Charts.Add(ChartType.BoxWhisker, ColumnHeadersRow, 3, ColumnHeadersRow + 20, 10);
var chart = sheet.Charts[index];
var chartArea = "B" + (ChartDataStartRow + 1 ) + ":" + columnName + numOfCategory;
var categoryData = "A" + (ChartDataStartRow + 1 ) + ":A" + numOfCategory;
chart.SetChartDataRange(chartArea, true);
chart.NSeries.CategoryData = categoryData;
int i = 0;
foreach (var series in chartData.Series)
{
chart.NSeries[i].Name = series.name;
chart.NSeries[i].LayoutProperties.ShowMeanLine = false;
chart.NSeries[i].Area.FillFormat.FillType = FillType.None;
chart.NSeries[i].Border.FormattingType = ChartLineFormattingType.Solid;
chart.NSeries[i].Border.Style = LineType.Solid;
i++;
}
chart.SeriesAxis.AxisBetweenCategories = false;
chart.SecondValueAxis.AxisBetweenCategories = false;
chart.CategoryAxis.AxisBetweenCategories = false;
if (chartConfig.XAxisConfigs != null)
{
chart.CategoryAxis.Title.Text = chartConfig.XAxisConfigs.Title ?? "";
}
chart.CategoryAxis.Title.RotationAngle = 0;
chart.CategoryAxis.AxisLine.IsVisible = false;
if (chartConfig.YAxisConfigs != null)
{
chart.ValueAxis.Title.Text = chartConfig.YAxisConfigs.Title ?? "";
}
chart.ValueAxis.Title.RotationAngle = 0;
chart.ValueAxis.AxisLine.IsVisible = false;
}
On hovering the chart, I am unable to set the series name through the code. But the same works if the chart is created on selecting the data from ms-excel. Please help me to set the series name as well.
Thank you for sample code and Excel sheet. We are afraid to share that this code cannot be used to reproduce the scenario as there are many missing references like LayoutContainer, BoxPlotChartData and ChartConfig. You may please share a complete sample solution which can be executed standalone. Share the output file created by the program and the expected output file created by Excel with differentiation. Also provide some images etc. for exact issue identification.
using System.Collections.Generic;
using Aspose.Cells;
using Aspose.Cells.Charts;
using Aspose.Cells.Drawing;
namespace Test_BoX_whisker
{
class Program
{
static void Main(string[] args)
{
var index = 0;
var sheetName = “BoxwhiskerChart”;
const string excelTemplateRelativePath = @“C:\Test\ReportExcelTemplate.xlsx”;
var templatePath = excelTemplateRelativePath;
var excel = new Workbook(templatePath);
excel.Worksheets.AddCopy(index);
var sheet = excel.Worksheets[index];
var datacell = sheet.Cells[“A” + 1];
datacell.PutValue(“”);
for (int i = 2; i <= 6; i++)
{
datacell = sheet.Cells[“A” + i];
datacell.PutValue(“1-Jan”);
}
for (int i = 7; i <= 11; i++)
{
datacell = sheet.Cells[“A” + i];
datacell.PutValue(“2-Jan”);
}
sheet.Cells[“B2”].PutValue(60);
sheet.Cells[“B3”].PutValue(70);
sheet.Cells[“B4”].PutValue(90);
sheet.Cells[“B5”].PutValue(150);
sheet.Cells[“B6”].PutValue(70);
sheet.Cells[“B7”].PutValue(80);
sheet.Cells[“B8”].PutValue(90);
sheet.Cells[“B9”].PutValue(110);
sheet.Cells[“B10”].PutValue(130);
sheet.Cells[“B11”].PutValue(150);
sheet.Cells[“C2”].PutValue(40);
sheet.Cells[“C3”].PutValue(50);
sheet.Cells[“C4”].PutValue(60);
sheet.Cells[“C5”].PutValue(150);
sheet.Cells[“C6”].PutValue(30);
sheet.Cells[“C7”].PutValue(50);
sheet.Cells[“C8”].PutValue(90);
sheet.Cells[“C9”].PutValue(110);
sheet.Cells[“C10”].PutValue(140);
sheet.Cells[“C11”].PutValue(150);
var chartArea = “B” + 2 + “:” + “C” + 11;
var categoryData = “A” + 2 + “:A” + 11;
int index1 = sheet.Charts.Add(ChartType.BoxWhisker, 0, 3, 0 + 20, 10);
var chart = sheet.Charts[index1];
chart.SetChartDataRange(chartArea, true);
chart.NSeries.CategoryData = categoryData;
var seriesName = new List {“Team 1”, “Team 2”};
int series_index = 0;
foreach (var series in seriesName)
{
chart.NSeries[series_index].Name = series;
chart.NSeries[series_index].LayoutProperties.ShowMeanLine = false;
chart.NSeries[series_index].Area.FillFormat.FillType = FillType.None;
chart.NSeries[series_index].Border.FormattingType = ChartLineFormattingType.Solid;
chart.NSeries[series_index].Border.Style = LineType.Solid;
series_index++;
}
excel.Save(templatePath+“output.xlsx”);
}
}
}
This code creates Box whisker Chart at the specified location. I have attached the desired excel sheet file. The file contains both the charts - generated by the system as well as expected output.
Thank you for the sample code. You are also requested to send us the template file “ReportExcelTemplate.xlsx” file as my own sample files are not creating the desired output through your sample code.
Thanks for providing all the necessary information to reproduce the problem here. We were able to observe the issue but we need to look into it more. We have logged the requirement in our database for investigation and for a solution. Once, we will have some news for you, we will update you in this topic.
We have fixed your issue (logged earlier as “CELLSNET-46568”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.
@ahsaniqbalsidiqui
Is there any planned release date for this issue? Also, I would like to know if we can give custom color for series in line, area, scatter, bar and column chart.
You may expect the fix in the next few days (3-5) in the fix was not delivered today.
Yes, sure, you may do that for other chart types. If you find any issue, give us complete details, sample code (runnable) and template file(s) to show the issue, we will check it soon.
Thanks for the response. It is working fine except that I am unable to get the legend. Can you please look into the issue.
Also, I have attached sample code for line chart where I am not able to set customized series color . The same issue can be replicated for area, scatter, bar and column chart. I have attached Excel Sheet mentioning the expected outcome. Line Chart.zip (19.1 KB)
Please use the line of code (in bold) to set customized series color for your needs:
e.g Sample code:
var index = 0;
List colorList = new List { Color.Red, Color.Black };
const string excelTemplateRelativePath = “E:\test2\setting box whisker\new1\Line Chart\ExcelFolder\ReportExcelTemplate.xlsx”;
var templatePath = excelTemplateRelativePath;
var excel = new Workbook(templatePath);
excel.Worksheets.AddCopy(index);
var sheet = excel.Worksheets[index];
var datacell = sheet.Cells[“A” + 1];
datacell.PutValue("");
Thanks for the solution. It is working fine. Can you please check if legend can be available for BoxPlot chart. I am able to get the series name but it is not showing up in legend.
Good to know the suggested code figures out your issue.
Could you elaborate on it and provide screenshot comparing the output chart (by Aspose.Cells) Vs your desired chart (manually created in MS Excel), we will check it soon.
Thanks for providing sample file. You may please add following code at the end of sample code provided here. It shall create required legend in the chart.
//Set Legend's width and height
Legend legend = chart.Legend;
//Legend is at right side of chart by default.
//If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
//If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.
legend.Y = 1500;
legend.Width = 50;
legend.Height = 50;
//Set legend's position
legend.Position = LegendPositionType.Top;
excel.Save(@"out1.xlsx");
The issues you have found earlier (filed as CELLSNET-46568) have been fixed in Aspose.Cells for .NET v19.2. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi