chartspdfsharp

PdfSharp Charts - Remove Border and Background


I'm using PdfSharp Charts and the chart container have a blue border and a gradient background. I looked for the property that sets those options but no success. I can change multiple things in the chart itself, but not for the container. How can I remove the border and the background?

Thanks!

enter image description here

Again, I looked for the properties of the chart container but no success. Here is the code I have so far:

public static Chart ColumnChart(PdfChartValues pdfChartValues)
        {
            Chart chart = new Chart(ChartType.Column2D);
            chart.Font.Size = 7;
            chart.PlotArea.FillFormat.Color = XColors.White;
            chart.Legend.Docking = DockingType.Bottom;

            XSeries xSeries = chart.XValues.AddXSeries();
            xSeries.Add(pdfChartValues.XSeriesText);

            Series series;
            foreach (var item in pdfChartValues.ChartSeriesValues)
            {
                series = chart.SeriesCollection.AddSeries();
                series.Name = item.SeriesName;
                series.Add(item.SeriesValues);
                series.FillFormat.Color = XColor.FromArgb(item.RedValue, item.GreenValue, item.BlueValue); // Bar color
            }

            chart.XAxis.HasMajorGridlines = false;
            chart.XAxis.MajorTickMark = TickMarkType.None;
            chart.XAxis.Title.Caption = pdfChartValues.TitleCaption;

            chart.YAxis.MajorTickMark = TickMarkType.None;
            chart.YAxis.MajorTick = pdfChartValues.YAxisMajorTick;
            chart.YAxis.HasMajorGridlines = true;
            chart.YAxis.MajorGridlines.LineFormat.Color = XColors.LightGray;

            chart.PlotArea.LineFormat.Color = XColors.LightGray;
            chart.PlotArea.LineFormat.Width = 1;
            chart.PlotArea.LineFormat.Visible = true;

            chart.DataLabel.Type = DataLabelType.Value;
            chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
            chart.DataLabel.Format = pdfChartValues.SetMoneyFormat ? "$0" : "##,#";

            return chart;
        }

Solution

  • It seems the colours are hard-coded in ChartFrame.cs.
    They cannot yet be set using properties.

    Take the PDFsharp source code, change the colours there, and compile.