Search code examples
c#visual-studio-2010chartfx

ChartFX export chart cuts the borders


I have a problem with exporting a chart. I use the ChartFX chart with

chart.ExportImageSize = new Size(600, 450);

and if the size of the image is larger than this (1127, 537), it cuts the right and the bottom border in the exported image.

For exporting, I use simple

chart.Export(FileFormat.Bitmap);

No custom controls are used in exporting the chart, and the chart looks normal in the application (borders all around, and I use simple black border).


Solution

  • Few interesting things I realized trying to solve this. First I have no border

    chart.Border = new SimpleBorder(SimpleBorderType.None, cOffice2007BackColor);
    

    Than, I add the new border object just to export the chart with the border.

    chart.Border = new SimpleBorder(SimpleBorderType.Color, Color.Black);
    chart.Export(FileFormat.Bitmap);
    

    Than I revert the border. And, it exports the chart with the new border, but it doesn't resize the border. If it's larger than ExportImageSize, I see only left and top border, and if it's smaller, I get a part of the chart that goes outside the borders.

    So, I set the the border to begin with, and only change the color for the exporting.

    One more realization, explicitly setting the ExportImageSize can lead to some interesting side-effects. Even dough your plot looks really good, it sometimes cuts the legend, if it is to large