(1) When I try to set the Chart Legend font color, it's not being honored. I need the text to be white against a black background.
(2) I'm not sure how to set the the minimum and maximum axis bounds. I messed around with it a bit but like the Chart Legend font color, the values I entered didn't seem to be honored so I removed it.
Any help would be appreciated! Here's my code below:
- Code: Select all
private void AddSlideWithChartData<T>(string title, Scorecard<T> scorecard, Indicator indicator) where T : IConvertible
{
if (scorecard == null) return;
ISlide slide = Presentation.Slides.Append();
slide.SlideBackground.Type = BackgroundType.Custom;
slide.SlideBackground.Fill.FillType = FillFormatType.Solid;
slide.SlideBackground.Fill.SolidColor.Color = Color.Black;
IChart chart = slide.Shapes.AppendChart(ChartType.LineMarkers, new RectangleF(25, 25, Presentation.SlideSize.Size.Width - 50, Presentation.SlideSize.Size.Height - 75));
chart.HasTitle = true;
chart.ChartTitle.TextProperties.Text = title;
chart.ChartTitle.TextProperties.IsCentered = true;
chart.ChartLegend.Position = ChartLegendPositionType.Top;
chart.ChartTitle.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
chart.ChartTitle.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.Color = Color.White;
//NOTE: Here are the two lines I assumed would set the chart legend font color but aren't...
chart.ChartLegend.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
chart.ChartLegend.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.Color = Color.White;
chart.ChartLegend.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
chart.ChartLegend.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.Color = Color.White;
chart.PrimaryCategoryAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
chart.PrimaryCategoryAxis.TextProperties.Paragraphs[0]. DefaultCharacterProperties.Fill.SolidColor.Color = Color.White;
chart.PrimaryValueAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
chart.PrimaryValueAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.Color = Color.White;
chart.ChartData[0, 0].Text = "Month";
chart.ChartData[0, 2].Text = "Dollars";
chart.ChartData[0, 3].Text = "Goal";
chart.ChartData[0, 4].Text = Store.FullName;
chart.ChartData[0, 5].Text = "Baseline";
int rowIndex = 1;
foreach (var record in scorecard.Records)
{
chart.ChartData[rowIndex, 0].Value = record.Month.ToString();
chart.ChartData[rowIndex, 2].Value = double.Parse(record.Metrics[ReportMetric.ActualT12].ToString());
chart.ChartData[rowIndex, 3].Value = double.Parse(record.Metrics[ReportMetric.Goal].ToString());
chart.ChartData[rowIndex, 4].Value = double.Parse(record.Metrics[ReportMetric.Benchmark].ToString());
chart.ChartData[rowIndex, 5].Value = double.Parse(record.Metrics[ReportMetric.Baseline].ToString());
rowIndex++;
}
chart.Series.SeriesLabel = chart.ChartData["C1", "F1"];
chart.Categories.CategoryLabels = chart.ChartData["A2", $"A{rowIndex}"];
var lineColors = new List<Color>() { Color.Blue, Color.Red, Color.HotPink, Color.Green };
for (int i = 0; i < 4; i++)
{
chart.Series[i].Values = chart.ChartData[$"{char.ConvertFromUtf32(i + 67)}2", $"{char.ConvertFromUtf32(i + 67)}{rowIndex}"];
chart.Series[i].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.KnownColor = KnownColors.White;
chart.Series[i].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
chart.Series[i].MarkerStyle = ChartMarkerType.Circle;
}
string imagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $@"img\good-indicators\{indicator}.png");
IEmbedImage image = slide.Shapes.AppendEmbedImage(ShapeType.Rectangle, imagePath, new RectangleF(25, 65, 97.5F, 33));
image.Line.FillType = FillFormatType.None;
}