Color of filled radar chart

How can I set color of filled radar chart?

I tried to set color in the following way:

chart.NSeries[0].HasRadarAxisLabels = true;

chart.NSeries[0].Values = "B2:B7";

chart.NSeries[0].Type = ChartType.RadarFilled;

chart.NSeries[0].XValues = "A2:A7";

chart.NSeries[0].IsColorVaried = true;

chart.NSeries[0].Area.ForegroundColor = Color.Red;

but I did not get the expected result. Diagram is not filled with red color.

Hi,
Well I dont' find the problem you are mentioning about. Following is my code which works fine and attached is the template file with filled radar chart specified with colors:
Workbook workbook = new Workbook();
//Set default font
Style style = workbook.DefaultStyle;
style.Font.Name = "Tahoma";
workbook.DefaultStyle = style;

Worksheet sheet = workbook.Worksheets[0];
//Set the name of worksheet
sheet.Name = "Data";
sheet.IsGridlinesVisible = false;

Cells cells = workbook.Worksheets[0].Cells;
//Put a value into a cell
cells["A1"].PutValue("Brand Name");
cells["B1"].PutValue("Vitamin A");
cells["C1"].PutValue("Vitamin B1");
cells["D1"].PutValue("Vitamin B2");
cells["E1"].PutValue("Vitamin C");
cells["F1"].PutValue("Vitamin D");
cells["G1"].PutValue("Vitamin E");

cells["A2"].PutValue("Brand A");
cells["B2"].PutValue(100);
cells["C2"].PutValue(100);
cells["D2"].PutValue(100);
cells["E2"].PutValue(80);
cells["F2"].PutValue(100);
cells["G2"].PutValue(70);

cells["A3"].PutValue("Brand B");
cells["B3"].PutValue(80);
cells["C3"].PutValue(75);
cells["D3"].PutValue(80);
cells["E3"].PutValue(100);
cells["F3"].PutValue(50);
cells["G3"].PutValue(15);

cells["A4"].PutValue("Brand C");
cells["B4"].PutValue(40);
cells["C4"].PutValue(25);
cells["D4"].PutValue(40);
cells["E4"].PutValue(55);
cells["F4"].PutValue(30);
cells["G4"].PutValue(10);

int sheetIndex = workbook.Worksheets.Add();
Worksheet sheet2 = workbook.Worksheets[sheetIndex];
//Set the name of worksheet
sheet2.Name = "Chart";
//Create chart
int chartIndex = sheet2.Charts.Add(ChartType.RadarFilled,1,1,25,10);
Chart chart = sheet2.Charts[chartIndex];
//Set properties of chart
chart.PlotArea.Border.IsVisible = false;
//Set properties of chart title
chart.Title.Text = "Nutritional Analysis";
chart.Title.TextFont.Color = Color.Black;
chart.Title.TextFont.IsBold = true;
chart.Title.TextFont.Size = 12;
//Set properties of nseries
chart.NSeries.Add("Data!B2:G4",false);
chart.NSeries.CategoryData = "Data!B1:G1";
chart.PlotArea.Area.ForegroundColor = Color.Green;
chart.NSeries[0].Area.ForegroundColor = Color.Red;

for ( int i = 0; i < chart.NSeries.Count; i ++ )
{
chart.NSeries[i].Name = cells["A"+(i+2).ToString()].Value.ToString();
}

workbook.Save("d:\\test\\FilledRadarChart.xls");
Which version of Aspose.Cells you are using, please try the latest version. If the problem still persists, please post your excel file.
Thank you.

Thank you

This code sample works. But I need to convert chart to image, however method chart.ToImage() throw an exception "Parameter is not valid"

How can I solve this problem?

Hi,

It seams that you are using some older version of Aspose.Cells.

Please try the attached version, I tested converting filled radar chart to image and it works fine.

Thank you.

I tried to use new version of Aspose.Cells from attached archive.

The method "chart.ToImage()" did not trow exception.

However when I saved image in JPEG format, chart did'nt appear on the picture. Allthough excel file contained expected chart.

Is this behavior correct? How can I get correct image?

Hi,

Could you post your excel file containing the filled radar chart with sample code, we will test the conversion and reply you soon.

Thank you.

There is sample code, excel file attached

TempFileCollection tempFileCollection = new TempFileCollection();

Workbook workbook = new Workbook();

//Set default font

Style style = workbook.DefaultStyle;

style.Font.Name = "Tahoma";

workbook.DefaultStyle = style;

Worksheet sheet = workbook.Worksheets[0];

//Set the name of worksheet

sheet.Name = "Data";

sheet.IsGridlinesVisible = false;

Cells cells = workbook.Worksheets[0].Cells;

//Put a value into a cell

cells["A1"].PutValue("Brand Name");

cells["B1"].PutValue("Vitamin A");

cells["C1"].PutValue("Vitamin B1");

cells["D1"].PutValue("Vitamin B2");

cells["E1"].PutValue("Vitamin C");

cells["F1"].PutValue("Vitamin D");

cells["G1"].PutValue("Vitamin E");

cells["A2"].PutValue("Brand A");

cells["B2"].PutValue(100);

cells["C2"].PutValue(100);

cells["D2"].PutValue(100);

cells["E2"].PutValue(80);

cells["F2"].PutValue(100);

cells["G2"].PutValue(70);

cells["A3"].PutValue("Brand B");

cells["B3"].PutValue(80);

cells["C3"].PutValue(75);

cells["D3"].PutValue(80);

cells["E3"].PutValue(100);

cells["F3"].PutValue(50);

cells["G3"].PutValue(15);

cells["A4"].PutValue("Brand C");

cells["B4"].PutValue(40);

cells["C4"].PutValue(25);

cells["D4"].PutValue(40);

cells["E4"].PutValue(55);

cells["F4"].PutValue(30);

cells["G4"].PutValue(10);

int sheetIndex = workbook.Worksheets.Add();

Worksheet sheet2 = workbook.Worksheets[sheetIndex];

//Set the name of worksheet

sheet2.Name = "Chart";

//Create chart

int chartIndex = sheet2.Charts.Add(ChartType.RadarFilled, 1, 1, 25, 10);

Chart chart = sheet2.Charts[chartIndex];

//Set properties of chart

chart.PlotArea.Border.IsVisible = false;

//Set properties of chart title

chart.Title.Text = "Nutritional Analysis";

chart.Title.TextFont.Color = Color.Black;

chart.Title.TextFont.IsBold = true;

chart.Title.TextFont.Size = 12;

//Set properties of nseries

chart.NSeries.Add("Data!B2:G2", false);

chart.NSeries.CategoryData = "Data!B1:G1";

chart.PlotArea.Area.ForegroundColor = Color.Green;

chart.NSeries[0].Area.ForegroundColor = Color.Red;

workbook.Save("d:\\FilledRadarChart.xls");

Bitmap image = chart.ToImage();

string imageName = tempFileCollection.AddExtension("PDFChart.jpg", true);

image.Save(imageName, ImageFormat.Jpeg);

Here is the result image in attachment

Hi,

Thanks for considering Aspose.

Please change the sequence of your code in the last portion:

E.g.,

Bitmap image = chart.ToImage();

string imageName = tempFileCollection.AddExtension("PDFChart.jpg", true);

image.Save(imageName, ImageFormat.Jpeg);

workbook.Save("d:\\FilledRadarChart.xls");

Thank you.

Thank you

Chart appears on the image

But I was surprised because chart on the image was blue, and chart in the excel file was red!!

How can I get image with the red radar filled chart?

Hi,

Yes, we found the problem related color of the filled radar chart, we will figure out the issue soon.

Thank you.

Hi,

Could you please inform about solve this problem?

We have to implement this feature in our project and we are waiting for solve this problem as soon as possible

Thank you.

Hi,

We have worked a bit on your issue. We will soon attach a fix here

Thank you.

Hi,

Please try this fix.

We have fixed the bug of converting radar chart to image.