Page 1 of 1

CopyToClipBoard Transparent Polar Graph

Posted: Fri Jul 10, 2020 9:37 pm
by ELBOB
Hello :
Can you please tell me what can be the best way to grab a Polar plot I have in my interface with no background colors (on the chart itself as well on the polar area= Completely transparent "white?") so it become Printer friendly when chart goes from the App to Paper.

This was the best I was able to do (still gradient in the polar, and gray in the background).
Polar.png
Polar.png (126.34 KiB) Viewed 3432 times
This is my current code:
I'm storing the original background before copying to the clipboard, then restoring them back.

Code: Select all


            _PolarPlotHelper.PolarChart.BeginUpdate();
            Color u = _PolarPlotHelper.PolarChart.ChartBackground.Color;
            double OP = _PolarPlotHelper.PolarChart.Background.Opacity;
            
            _PolarPlotHelper.PolarChart.ChartBackground.Color = Color.FromArgb(0, 0, 0, 0);
            _PolarPlotHelper.PolarChart.Background.Opacity = 0;// Color.FromArgb(0, 0, 0, 0);
            _PolarPlotHelper.PolarChart.CopyToClipboard(Arction.Wpf.Charting.ClipboardImageFormat.Png);

            _PolarPlotHelper.PolarChart.ChartBackground.Color = u;
            _PolarPlotHelper.PolarChart.Background.Opacity = OP;// Color.FromArgb(0, 0, 0, 0);          
            _PolarPlotHelper.PolarChart.EndUpdate();
Your help will be appreciated.

Thanks.

Re: CopyToClipBoard Transparent Polar Graph

Posted: Mon Jul 13, 2020 7:04 am
by Arction_LasseP
Hello,

As you mentioned, there is still some gradient in the polar chart. You can disable this as well by setting GradientFill to solid. Also use ChartBackground to change the color of the view background and GraphBackground to change the color of the graph (circular area). Furthermore, modifying Opacity might not have any effect in some cases.

Here is a simple example where background properties are changed when the chart is double-clicked.

Code: Select all

_chart.MouseDoubleClick += _chart_MouseDoubleClick;

private void _chart_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
	_chart.BeginUpdate();

	_chart.ViewPolar.GraphBackground.Color = Color.FromArgb(0, 0, 0, 0);
	_chart.ViewPolar.GraphBackground.GradientFill = GradientFill.Solid;

	_chart.ChartBackground.Color = Color.FromArgb(0, 0, 0, 0);
	_chart.ChartBackground.GradientFill = GradientFill.Solid;

	_chart.Background.Opacity = 0; // Might not be necessary

	_chart.EndUpdate();

	_chart.CopyToClipboard();

	// Change the background back if needed
}
Note that it could be a good idea to call CopyToClipboard (or other similar method like SaveToFile) after the chart has been updated i.e. chart.EndUpdate() has been called. This is to make sure that all of those color changes are actually done when taking/printing the chart image.

Hope this helps.
Best regards,
Lasse