We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue in Chart type line and Column stack

Hello,

I am trying to generate chart that include following types

  1. Line Chart - NBP Supplier Volume

  2. Column Stack - Base + Peak load volume

  3. Area - NBP Event volume<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” />

Below is the code to generate the charts and also see the attachment

Generating to excel and gives correct output, please check the attachment ‘ExcelBasePeakLoad.png’

When we convert the chart to image, see the attachment “basePeakConvertTomage.jpg”, we have couple of issues

  1. Line Chart is not clear – it shows zigzag line

  2. Area chart – NBP Event volume is overlapping the Base+peak load volume

Please advise how we can avoid the zigzag in the line and overlapping of area chart

wsVolumeChartData.Charts.Clear();

int chartIndex = 0;

chartIndex =
wsVolumeChartData.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 18, 1, 45,
20);

Aspose.Cells.Charts.Chart chart =
wsVolumeChartData.Charts[chartIndex];

chart.ValueAxis.MajorGridLines.IsVisible = false;

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

chart.ChartArea.Border.IsVisible = false;

if (this.FlexStructure == EnumFlexStructureList.Baseload)

{

chart.NSeries.Add(string.Format("=VolumeChartData!$B$1:$B${0}",
numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$C$1:$C${0}",
numberOfMonths), true);


chart.NSeries.Add(string.Format("=VolumeChartData!$D$1:$D${0}",
numberOfMonths), true);

}<o:p></o:p>

if (this.FlexStructure == EnumFlexStructureList.BaseloadPeakload)

{

chart.NSeries.Add(string.Format("=VolumeChartData!$B$1:$B${0}", numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$C$1:$C${0}", numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$D$1:$D${0}", numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$E$1:$E${0}", numberOfMonths), ue); }

chart.NSeries.CategoryData = string.Format("=VolumeChartData!$A$1:$A${0}", numberOfMonths);

chart.CategoryAxis.TickLabels.Font.Name = "Arial";

chart.CategoryAxis.TickLabels.Font.Size = 8;

chart.CategoryAxis.TickLabels.RotationAngle = 90;

chart.CategoryAxis.TickLabels.Font.IsBold = true;

chart.NSeries.SecondCatergoryData = string.Format("=VolumeChartData!$A$1:$A${0}",
umberOfMonths);

chart.SecondValueAxis.MinValue = 0;

if (this.FlexStructure == EnumFlexStructureList.Baseload)


{


chart.NSeries[0].Line.IsVisible = true;


chart.NSeries[0].Name = “NBP Event Volume (MWh)”;


chart.NSeries[0].Type = Aspose.Cells.Charts.ChartType.Area;


chart.NSeries[0].Area.ForegroundColor = Color.FromArgb(217, 217, 217);


chart.NSeries[0].Border.IsVisible = false;


chart.NSeries[0].Shadow = true;


}


if (this.FlexStructure == EnumFlexStructureList.Baseload)


{


if (this.FlexStructure == EnumFlexStructureList.Shape)


{


chart.NSeries[1].Name
= “NBP Volume (MWh)”;


}


else


{


chart.NSeries[1].Name = “Baseload Volume (MWh)”;


}


chart.NSeries[1].PlotOnSecondAxis = true;


chart.NSeries[1].Area.ForegroundColor = Color.FromArgb(0, 133, 208);


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


//chart.NSeries[1].DataLabels.Separator = DataLablesSeparatorType.NewLine;


//chart.NSeries[1].Overlap = 100;


}


if (this.FlexStructure == EnumFlexStructureList.Baseload)


{


Series series = chart.NSeries[2];


series.Name = “NBP Supplier Volume (MWh)”;


series.Type = ChartType.Line;


chart.NSeries[2].Area.Formatting = Aspose.Cells.Charts.FormattingType.Automatic;


chart.NSeries[2].Line.Color = System.Drawing.Color.FromArgb(64, 64, 64);


chart.NSeries[2].Line.Style = Aspose.Cells.Drawing.LineType.Solid;


chart.NSeries[2].Line.WeightPt = 2.0;


} <o:p> </o:p>


if
(this.FlexStructure == EnumFlexStructureList.BaseloadPeakload)


{


Series Columnseries = chart.NSeries[0];


Columnseries.Type = Aspose.Cells.Charts.ChartType.Area;


chart.NSeries[0].Line.IsVisible = true;


chart.NSeries[0].Name = “NBP Event Volume (MWh)”;


chart.NSeries[0].Area.ForegroundColor = Color.FromArgb(217, 217, 217);


chart.NSeries[0].Border.IsVisible = false;


chart.NSeries[0].Shadow = true;


Series Stackseries = chart.NSeries[1];


Stackseries.Type =
ChartType.ColumnStacked;

chart.NSeries[1].Area.ForegroundColor
= Color.FromArgb(0, 133, 208);


chart.NSeries[1].Name = “Baseload Volume (MWh)”;


chart.NSeries[2].Area.ForegroundColor = Color.FromArgb(31, 73, 125);


chart.NSeries[2].Name
= “Peakload Volume (MWh)”;<o:p> </o:p>


Series seriesline = chart.NSeries[3];


seriesline.Name = “NBP Supplier Volume (MWh)”;


seriesline.Type = ChartType.Line;


chart.NSeries[3].Area.Formatting =
Aspose.Cells.Charts.FormattingType.Automatic;


chart.NSeries[3].Line.Color = System.Drawing.Color.FromArgb(64, 64, 64);


chart.NSeries[3].Line.Style = Aspose.Cells.Drawing.LineType.Solid;


chart.NSeries[3].Line.WeightPt =
2.0;

}

string ImageRefID =string.empty;

ImageRefID = System.Guid.NewGuid().ToString();


Session[“imageRefID”] = ImageRefID;

chart.ToImage(TemplatePath

“\Images\VolumeChart”
ImageRefID + “.jpeg”);

System.Web.UI.WebControls.Image VolumeChartImg = new System.Web.UI.WebControls.Image();


VolumeChartImg.ID = “VolumeChartImg”;


VolumeChartImg.ImageUrl = “~/Templates/Images/VolumeChart” +
ImageRefID + “.jpeg”;


VolumeChartImg.BorderWidth = 0;


pnl_Volumechart.BorderWidth = 0;


pnl_Volumechart.Controls.Add(VolumeChartImg);

Thanks

Parvati

I am trying to generate chart that include following types

  1. Line Chart - NBP Supplier Volume

  2. Column Stack - Base + Peak load volume

  3. Area - NBP Event volume

Below is the code to generate the charts and also see the attachment

Generating to excel and gives correct output, please check the attachment ‘ExcelBasePeakLoad.png’

When we convert the chart to image, see the attachment “basePeakConvertTomage.jpg”, we have couple of issues

  1. Line Chart is not clear – it shows zigzag line

  2. Area chart – NBP Event volume is overlapping the Base+peak load volume

Please advise how we can avoid the zigzag in the line and overlapping of area chart

wsVolumeChartData.Charts.Clear();

int chartIndex = 0;

chartIndex = wsVolumeChartData.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 18, 1, 45, 20);

Aspose.Cells.Charts.Chart chart = wsVolumeChartData.Charts[chartIndex];

chart.ValueAxis.MajorGridLines.IsVisible = false;

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


chart.ChartArea.Border.IsVisible = false;

if (this.FlexStructure == EnumFlexStructureList.Baseload)

{

chart.NSeries.Add(string.Format("=VolumeChartData!$B$1:$B${0}", numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$C$1:$C${0}", numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$D$1:$D${0}", numberOfMonths), true);

}

if (this.FlexStructure == EnumFlexStructureList.BaseloadPeakload)

{

chart.NSeries.Add(string.Format("=VolumeChartData!$B$1:$B${0}", numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$C$1:$C${0}", numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$D$1:$D${0}", numberOfMonths), true);

chart.NSeries.Add(string.Format("=VolumeChartData!$E$1:$E${0}", numberOfMonths), true); }


chart.NSeries.CategoryData = string.Format("=VolumeChartData!$A$1:$A${0}", numberOfMonths);

chart.CategoryAxis.TickLabels.Font.Name = "Arial";

chart.CategoryAxis.TickLabels.Font.Size = 8;

chart.CategoryAxis.TickLabels.RotationAngle = 90;

chart.CategoryAxis.TickLabels.Font.IsBold = true;

chart.NSeries.SecondCatergoryData = string.Format("=VolumeChartData!$A$1:$A${0}", numberOfMonths);

chart.SecondValueAxis.MinValue = 0;

if (this.FlexStructure == EnumFlexStructureList.Baseload)

{

chart.NSeries[0].Line.IsVisible = true;

chart.NSeries[0].Name = "NBP Event Volume (MWh)";

chart.NSeries[0].Type = Aspose.Cells.Charts.ChartType.Area;

chart.NSeries[0].Area.ForegroundColor = Color.FromArgb(217, 217, 217);

chart.NSeries[0].Border.IsVisible = false;

chart.NSeries[0].Shadow = true;

}


if (this.FlexStructure == EnumFlexStructureList.Baseload)

{

if (this.FlexStructure == EnumFlexStructureList.Shape)

{

chart.NSeries[1].Name = "NBP Volume (MWh)";

}

else

{

chart.NSeries[1].Name = "Baseload Volume (MWh)";

}

chart.NSeries[1].PlotOnSecondAxis = true;

chart.NSeries[1].Area.ForegroundColor = Color.FromArgb(0, 133, 208);

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

//chart.NSeries[1].DataLabels.Separator = DataLablesSeparatorType.NewLine;

//chart.NSeries[1].Overlap = 100;

}

if (this.FlexStructure == EnumFlexStructureList.Baseload)

{

Series series = chart.NSeries[2];

series.Name = "NBP Supplier Volume (MWh)";

series.Type = ChartType.Line;

chart.NSeries[2].Area.Formatting = Aspose.Cells.Charts.FormattingType.Automatic;

chart.NSeries[2].Line.Color = System.Drawing.Color.FromArgb(64, 64, 64);

chart.NSeries[2].Line.Style = Aspose.Cells.Drawing.LineType.Solid;

chart.NSeries[2].Line.WeightPt = 2.0;

}




if (this.FlexStructure == EnumFlexStructureList.BaseloadPeakload)

{


Series Columnseries = chart.NSeries[0];

Columnseries.Type = Aspose.Cells.Charts.ChartType.Area;

chart.NSeries[0].Line.IsVisible = true;

chart.NSeries[0].Name = "NBP Event Volume (MWh)";

chart.NSeries[0].Area.ForegroundColor = Color.FromArgb(217, 217, 217);

chart.NSeries[0].Border.IsVisible = false;

chart.NSeries[0].Shadow = true;


Series Stackseries = chart.NSeries[1];

Stackseries.Type = ChartType.ColumnStacked;

chart.NSeries[1].Area.ForegroundColor = Color.FromArgb(0, 133, 208);

chart.NSeries[1].Name = "Baseload Volume (MWh)";

chart.NSeries[2].Area.ForegroundColor = Color.FromArgb(31, 73, 125);

chart.NSeries[2].Name = "Peakload Volume (MWh)";


Series seriesline = chart.NSeries[3];

seriesline.Name = "NBP Supplier Volume (MWh)";

seriesline.Type = ChartType.Line;

chart.NSeries[3].Area.Formatting = Aspose.Cells.Charts.FormattingType.Automatic;

chart.NSeries[3].Line.Color = System.Drawing.Color.FromArgb(64, 64, 64);

chart.NSeries[3].Line.Style = Aspose.Cells.Drawing.LineType.Solid;

chart.NSeries[3].Line.WeightPt = 2.0;


}


string ImageRefID =string.empty;


ImageRefID = System.Guid.NewGuid().ToString();

Session["imageRefID"] = ImageRefID;

chart.ToImage(TemplatePath + "\\Images\\VolumeChart" + ImageRefID + ".jpeg");



System.Web.UI.WebControls.Image VolumeChartImg = new System.Web.UI.WebControls.Image();

VolumeChartImg.ID = "VolumeChartImg";

VolumeChartImg.ImageUrl = "~/Templates/Images/VolumeChart" + ImageRefID + ".jpeg";

VolumeChartImg.BorderWidth = 0;

pnl_Volumechart.BorderWidth = 0;

pnl_Volumechart.Controls.Add(VolumeChartImg);

Hi,

Thanks for your posting and using Aspose.Cells.

Please try creating the workbook with xlsx format e.g

instead of creating workbook like this

Workbook workbook = new Workbook();

create it like this

Workbook workbook = new Workbook(FileFormatType.Xlsx);

and see if fixes your issue.

Please also download and try the latest version: Aspose.Cells
for .NET v8.0.1.3
to see if it also fix the issue at hand.

If your issue still persists, then please provide your output Excel file or provide your runnable sample project replicating this issue with latest version.

We will look into it and update you asap.

Thanks Shakeel,

When i change my code from

Workbook workbook = new Workbook();

to

Workbook workbook = new Workbook(FileFormatType.Xlsx);

Line chart issue is resolved, now line chart is coming properly.

But Area Chart is overlapping the column stacked chart this issue is not resolved.

Currently we are using 7.3.0.0.

We tried downloading the latest vesrion 8.0.1.0 but it didn't work. Please let us know where we are going wrong.

Thanks

Parvati

Hi Parvati,

Thanks for your feedback and using Aspose.Cells.

Please provide us your output xlsx file containing your chart. We will look into it and see how it converts to image with the latest version and log this issue in our database for a fix.

Thanks for the quick response

Here with Iam attaching the excel sheet with data that generates the graph.

Thanks

Parvati

Hi Parvati,

Thanks for your sample file and using Aspose.Cells.

We were able to reproduce this issue with the following code using the latest version: Aspose.Cells
for .NET v8.0.1.3
. Area Chart is overlapping the column stacked chart in the output image.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-42608.

I have attached the output image for a reference.

C#


Workbook workbook = new Workbook(path);


Worksheet worksheet = workbook.Worksheets[“VolumeChartData”];


Chart ch = worksheet.Charts[0];


Bitmap bmpChart = ch.ToImage();

bmpChart.Save(path + “.out.png”, ImageFormat.Png);

Thanks,

I am looking forward for the solution.

Hi Shakeel,

Any update on this issue.

Hi Parvati,

Thanks for your posting and using Aspose.Cells.

We are afraid, your issue is not yet resolved and there is no update for you at this moment. However, we have logged your comments in our database against this issue and requested the development team to provide some ETA or update relating to it. Once, there is some news or fix for you, we will let you know asap.

Hi Shakeel,

We are eagarly waiting for the reply on the issue, please let us know the updates on this.

Regards,

Parvati

Hi Parvati,

Thanks for your posting and using Aspose.Cells.

We are afraid, there is still no update for you at this moment. However, we have again logged your comments in our database. Once, there is some fix or other update for you, we will let you know asap.

Hi,


Please let us know if there is any update on the issue…

Regards
Parvati

Hi Parvati,

Thanks for your posting and using Aspose.Cells.

Your issue is in progress. However, your issue is not resolved yet. Once, there is some fix or other update for you, we will let you know asap.

Hi Parvati,

Thanks for your using Aspose.Cells.

Please try the new fix for area chart overlap.

Please download and try the latest fix: Aspose.Cells for .NET v8.0.2.3 and let us know your feedback.

Hi Shakeel,

Thanks for your respose on the issue.

I tried to use Apose.cells.net V8.0.2.3. I am glad to say that the issue has been resolved.

But there is a little differnce in the chart generated in excel.

Previously we were using ASPOSE.Cells V7.3.0.0.

I am attaching the excel generated for V7.3.0.0. and V8.0.2.3. for the same .net code. I want to generate the graph simillar to V7.3.0.0.

I may be missing some of the properties, please let me know. our requirement is generating graph simillar to v7.3.0.0

Thanks for all your help

Regards,

Parvati

Hi Parvati,

Thanks for using Aspose.Cells.

Kindly provide us your runnable sample project which you are using to create this chart. We will look into it and see what other properties or code change should be done to achieve the same results as you are getting in 7.3.0.0.

Hi,

Sorry for the delay,here with i am attaching the code and the supporting file for the same.

Please let me know what properties i need to set for Aspose.Cells8.0.2.3+For+.Net2v dll to get same result as v7.3.0.0.

Code

private void ChartGenerartionSample() {

int chartIndex = 0;Workbook wbCostServeData = new Workbook(ConfigurationManager.AppSettings["TemplatePath"].ToString() + "testChart.xlsx");
Worksheet wsPricingAnalysis = wbCostServeData.Worksheets["ChartData"];
int StartRow = 15;
int totalRows = 10;
int StartColum = 0;

chartIndex = wsPricingAnalysis.Charts.Add(Aspose.Cells.Charts.ChartType.Column, StartRow + totalRows + 4, StartColum, StartRow + totalRows + 50, StartColum + 6);
Aspose.Cells.Charts.Chart chart = wsPricingAnalysis.Charts[chartIndex];
chart.ValueAxis.MajorGridLines.IsVisible = true;

Range rngMonth = wsPricingAnalysis.Cells.CreateRange("A2", "A13");

Range rngEventVolume = wsPricingAnalysis.Cells.CreateRange("B2", "B13");

Range rngSupplierVolume = wsPricingAnalysis.Cells.CreateRange("E2", "E13");

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

chart.ChartArea.Border.IsVisible = true;


chart.NSeries.Add(rngEventVolume.RefersTo, true);
chart.NSeries.Add(string.Format("=ChartData!$C$2:$C$13"), true);
chart.NSeries.Add(string.Format("=ChartData!$D$2:$D$12"), true);
chart.NSeries.Add(rngSupplierVolume.RefersTo, true);

chart.NSeries.CategoryData = rngMonth.RefersTo;
chart.CategoryAxis.TickLabels.Font.Name = "Arial";

chart.CategoryAxis.TickLabels.Font.Size = 8;
chart.CategoryAxis.TickLabels.RotationAngle = 90;
chart.CategoryAxis.TickLabels.Font.IsBold = false;


chart.ValueAxis.TickLabels.Font.Name = "Arial";
chart.ValueAxis.TickLabels.Number = 3;

chart.ValueAxis.TickLabels.Font.IsBold = false;

chart.NSeries.SecondCatergoryData = rngMonth.RefersTo;
chart.SecondValueAxis.MinValue = 0;


Series Columnseries = chart.NSeries[0];
Columnseries.Type = Aspose.Cells.Charts.ChartType.Area;
chart.NSeries[0].Line.IsVisible = true;
chart.NSeries[0].Name = "NBP Event Vol (MWh)";
chart.NSeries[0].Area.ForegroundColor = Color.FromArgb(217, 217, 217);
chart.NSeries[0].Border.IsVisible = false;
chart.NSeries[0].Shadow = true;


Series Stackseries = chart.NSeries[1];
Stackseries.Type = ChartType.ColumnStacked;
chart.NSeries[1].Area.ForegroundColor = Color.FromArgb(0, 133, 208);
chart.NSeries[1].Name = "Baseload Volume (MWh)";
chart.NSeries[2].Area.ForegroundColor = Color.FromArgb(31, 73, 125);
chart.NSeries[2].Name = "Peakload Volume (MWh)";

Series seriesline = chart.NSeries[3];
seriesline.Name = "NBP Supplier Vol (MWh)";
seriesline.Type = ChartType.Line;
chart.NSeries[3].Area.Formatting = Aspose.Cells.Charts.FormattingType.Automatic;
chart.NSeries[3].Line.Color = System.Drawing.Color.FromArgb(64, 64, 64);
chart.NSeries[3].Line.Style = Aspose.Cells.Drawing.LineType.Solid;
chart.NSeries[3].Line.WeightPt = 2.0;

Legend legend = chart.Legend;
legend.Y = 1500;

legend.Width = 50;
legend.Height = 50;
legend.Border.IsVisible = false;

//Set legend's position
legend.Position = LegendPositionType.Top;
chart.ShowLegend = true;
legend.Font.Name = "Arial";

legend.Font.Size = 8;
legend.Font.IsBold = false;
chart.ChartObject.Width = 576;
chart.ChartObject.Height = 285;

chart.ChartObject.Left = 4;
string filepath = ConfigurationManager.AppSettings["TemplatePath"].ToString() + "helloV7.3.0.xlsx";
chart.ChartObject.Top = 2;
wbCostServeData.Save(filepath);
}

ThanksParvati

Hi Parvati,

Thanks for your posting and using Aspose.Cells.

I have run your exact code with 8.1.0.0 and 7.3.0.1, both generated the correct results.

Kindly download and try the latest version: Aspose.Cells for .NET 8.1.0 at your end. I have attached both output files for your reference.

This is the sample code I used for testing, it is same code as yours except I have highlighted the changes in red.

Please note, I am loading in xlsx format and saving it in xlsx format.

C#
private void ChartGenerartionSample()
{
string filePath = @“F:\Shak-Data-RW\Downloads\testChart.xlsx”;

int chartIndex = 0; Workbook wbCostServeData = new Workbook(filePath);
Worksheet wsPricingAnalysis = wbCostServeData.Worksheets[“ChartData”];
int StartRow = 15;
int totalRows = 10;
int StartColum = 0;

chartIndex = wsPricingAnalysis.Charts.Add(Aspose.Cells.Charts.ChartType.Column, StartRow + totalRows + 4, StartColum, StartRow + totalRows + 50, StartColum + 6);
Aspose.Cells.Charts.Chart chart = wsPricingAnalysis.Charts[chartIndex];
chart.ValueAxis.MajorGridLines.IsVisible = true;

Range rngMonth = wsPricingAnalysis.Cells.CreateRange(“A2”, “A13”);

Range rngEventVolume = wsPricingAnalysis.Cells.CreateRange(“B2”, “B13”);

Range rngSupplierVolume = wsPricingAnalysis.Cells.CreateRange(“E2”, “E13”);



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

chart.ChartArea.Border.IsVisible = true;


chart.NSeries.Add(rngEventVolume.RefersTo, true);
chart.NSeries.Add(string.Format("=ChartData!$C$2:$C$13"), true);
chart.NSeries.Add(string.Format("=ChartData!$D$2:$D$12"), true);
chart.NSeries.Add(rngSupplierVolume.RefersTo, true);

chart.NSeries.CategoryData = rngMonth.RefersTo;
chart.CategoryAxis.TickLabels.Font.Name = “Arial”;

chart.CategoryAxis.TickLabels.Font.Size = 8;
chart.CategoryAxis.TickLabels.RotationAngle = 90;
chart.CategoryAxis.TickLabels.Font.IsBold = false;


chart.ValueAxis.TickLabels.Font.Name = “Arial”;
chart.ValueAxis.TickLabels.Number = 3;

chart.ValueAxis.TickLabels.Font.IsBold = false;

chart.NSeries.SecondCatergoryData = rngMonth.RefersTo;
chart.SecondValueAxis.MinValue = 0;


Series Columnseries = chart.NSeries[0];
Columnseries.Type = Aspose.Cells.Charts.ChartType.Area;
chart.NSeries[0].Line.IsVisible = true;
chart.NSeries[0].Name = “NBP Event Vol (MWh)”;
chart.NSeries[0].Area.ForegroundColor = Color.FromArgb(217, 217, 217);
chart.NSeries[0].Border.IsVisible = false;
chart.NSeries[0].Shadow = true;


Series Stackseries = chart.NSeries[1];
Stackseries.Type = ChartType.ColumnStacked;
chart.NSeries[1].Area.ForegroundColor = Color.FromArgb(0, 133, 208);
chart.NSeries[1].Name = “Baseload Volume (MWh)”;
chart.NSeries[2].Area.ForegroundColor = Color.FromArgb(31, 73, 125);
chart.NSeries[2].Name = “Peakload Volume (MWh)”;

Series seriesline = chart.NSeries[3];
seriesline.Name = “NBP Supplier Vol (MWh)”;
seriesline.Type = ChartType.Line;
chart.NSeries[3].Area.Formatting = Aspose.Cells.Charts.FormattingType.Automatic;
chart.NSeries[3].Line.Color = System.Drawing.Color.FromArgb(64, 64, 64);
chart.NSeries[3].Line.Style = Aspose.Cells.Drawing.LineType.Solid;
chart.NSeries[3].Line.WeightPt = 2.0;

Legend legend = chart.Legend;
legend.Y = 1500;

legend.Width = 50;
legend.Height = 50;
legend.Border.IsVisible = false;

//Set legend’s position
legend.Position = LegendPositionType.Top;
chart.ShowLegend = true;
legend.Font.Name = “Arial”;

legend.Font.Size = 8;
legend.Font.IsBold = false;
chart.ChartObject.Width = 576;
chart.ChartObject.Height = 285;

chart.ChartObject.Left = 4;
chart.ChartObject.Top = 2;
wbCostServeData.Save(filePath + “_” + CellsHelper.GetVersion() + “.out.xlsx”);
}