I have the latest v6 dll and when I create a bar chart and attempt to set the data label colors for the bars, there is no effect on the appearance of the individual labels:
series.Points[0].Area.ForegroundColor = Color.Red;
series.Points[0].DataLabels.TextFont.Color = Color.Blue;
however, if I set the whole series, it works fine:
series.DataLabels.Area.ForegroundColor = Color.Red;
series.DataLabels.TextFont.Color = Color.Blue;
Is this a bug or am I doing something wrong?
Hi,
I found the latest version is working fine. Please download:
Aspose.Cells
for .NET v6.0.1.6
Please see the code below and the output file and screenshot.
C#
string path = @“F:\Shak-Data-RW\Downloads\source.xlsx”;
Workbook workbook = new Workbook(path);
Worksheet worksheet = workbook.Worksheets[0];
Chart chart = worksheet.Charts[0];
Series series = chart.NSeries[0];
series.Points[9].Area.ForegroundColor = Color.Green;
workbook.Save(path + “.out.xlsx”, SaveFormat.Xlsx);
Screenshot:
It’s still not working for me although now I get a different result. If I include this line:
series.Points[0].DataLabels.Area.ForegroundColor = Color.Orange;
I get no label on that point at all. Omit this line and it shows normally. Oddly if I open it in excel and check the box to show series name, it does show the series name on orange background, but still no value.
this is how my series is setup, note its on a secondary axis with transparent bars so only the labels show since the real data is on the primary axis:
series.PlotOnSecondAxis = true;
series.Name = “Delta”;
series.Area.FillFormat.SetType= FormatSetType.None;
series.Area.Formatting = FormattingType.None;
series.Area.Transparency = 1.0;
series.Area.InvertIfNegative = true;
series.Line.Color = Color.Blue;
series.Line.Transparency = 1.0;
series.DataLabels.IsCategoryNameShown = false;
series.DataLabels.IsValueShown = true;
series.DataLabels.IsSeriesNameShown = false;
series.DataLabels.Area.ForegroundColor = Color.White;
series.DataLabels.Border.IsVisible = true;
series.DataLabels.Border.Style = LineType.Solid;
series.DataLabels.Border.Weight = WeightType.WideLine;
series.DataLabels.Border.Color = Color.White;
series.DataLabels.Separator = DataLablesSeparatorType.NewLine;
series.DataLabels.Postion = LabelPositionType.InsideBase;
series.Overlap = 100;
chart.SecondValueAxis.IsPlotOrderReversed = true;
Hi,
Please send me your sample C# project replicating this issue. We will look into it.
Using the code I previously sent you, here is a complete example along with an attachment showing what I see when I open it with Excel. I’m using v6.0.1.6
xls.Worksheets.Add();
wks = xls.Worksheets[xls.Worksheets.Count - 1];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 10; j++)
wks.Cells[j, i].PutValue((i+1) * j);
Chart c = wks.Charts[wks.Charts.Add(ChartType.Column, 10, 0, 30, 10)];
c.NSeries.Add(“A1:B10”, true);
//add third series on secondary axis
c.NSeries.Add(“C1:C10”, true);
Series series = c.NSeries[c.NSeries.Count - 1];
series.PlotOnSecondAxis = true;
series.Name = “Delta”;
series.Area.FillFormat.SetType = FormatSetType.None;
series.Area.Formatting = FormattingType.None;
series.Area.Transparency = 1.0;
series.Area.InvertIfNegative = true;
series.Line.Color = Color.Blue;
series.Line.Transparency = 1.0;
series.DataLabels.IsCategoryNameShown = false;
series.DataLabels.IsValueShown = true;
series.DataLabels.IsSeriesNameShown = false;
series.DataLabels.Area.ForegroundColor = Color.White;
series.DataLabels.Border.IsVisible = true;
series.DataLabels.Border.Style = LineType.Solid;
series.DataLabels.Border.Weight = WeightType.WideLine;
series.DataLabels.Border.Color = Color.White;
series.DataLabels.Separator = DataLablesSeparatorType.NewLine;
series.DataLabels.Postion = LabelPositionType.InsideBase;
series.Overlap = 100;
c.SecondValueAxis.IsPlotOrderReversed = true;
//applying colors to a data point makes it disappear:
series.Points[5].DataLabels.Area.ForegroundColor = Color.Red;
series.Points[5].DataLabels.TextFont.Color = Color.Green;
xls.Save(xlsFilename, FileFormatType.Excel2007Xlsx);
I’ve simplified it and it still doesn’t work on a basic chart while the DataLabel position is InsideBase. If I remove setting the Position, it works:
xls.Worksheets.Add();
wks = xls.Worksheets[xls.Worksheets.Count - 1];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 10; j++)
wks.Cells[j, i].PutValue((i+1) * j);
Chart c = wks.Charts[wks.Charts.Add(ChartType.Column, 10, 0, 30, 10)];
c.NSeries.Add(“A1:B10”, true);
c.NSeries.Add(“C1:C10”, true);
Series series = c.NSeries[c.NSeries.Count - 1];
series.DataLabels.IsValueShown = true;
series.DataLabels.Postion = LabelPositionType.InsideBase;
//applying colors to a data point makes it disappear:
series.Points[5].DataLabels.Area.ForegroundColor = Color.Red;
series.Points[5].DataLabels.TextFont.Color = Color.Green;
Turns out, if I set DataLabels Seperator, it doesn’t work either, even if I don’t specify position:
xls.Worksheets.Add();
wks = xls.Worksheets[xls.Worksheets.Count - 1];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 10; j++)
wks.Cells[j, i].PutValue((i+1) * j);
Chart c = wks.Charts[wks.Charts.Add(ChartType.Column, 10, 0, 30, 10)];
c.NSeries.Add(“A1:B10”, true);
//add third series on secondary axis
c.NSeries.Add(“C1:C10”, true);
Series series = c.NSeries[c.NSeries.Count - 1];
series.DataLabels.IsValueShown = true;
series.DataLabels.Separator = DataLablesSeparatorType.NewLine;
//applying colors to a data point makes it disappear:
series.Points[5].DataLabels.Area.ForegroundColor = Color.Red;
series.Points[5].DataLabels.TextFont.Color = Color.Green;
Hi,
The issues you have found earlier (filed as 29828) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.