Change background & border of chart


#1

Hi,

I want to make the background and border of my chart transparent, but the folllowing doesn’t work:

            _donutChart.Theme.ChartStyle.BackgroundColor = UIColor.Clear;
            _donutChart.Theme.ChartStyle.BorderColor = UIColor.Clear;
            _donutChart.ApplyTheme();

I’m using MonoTouch/Xamarin.IOS but the Objective-C code should be comparable.

Any idea?


#2

Hi Boo-lee,

I managed to get my chart to be completely transparent by doing the following:

_chart.BackgroundColor = UIColor.Clear;
_chart.PlotAreaBackgroundColor = UIColor.Clear;
_chart.CanvasAreaBackgroundColor = UIColor.Clear;

_chart.BorderColor = UIColor.Clear;
_chart.BorderThickness = NSNumber.FromFloat(0.f);

_chart.PlotAreaBorderColor = UIColor.Clear;
_chart.PlotAreaBorderThickness = 0.f;

Ensure that you do the above after you have called _chart.applyTheme() as that will cause the chart’s current theme to be applied again, overwriting any direct changes you made to your charts styling.

Just to explain a little bit about the chart’s structure, the chart’s background colour is the background colour of the UIView the chart is rendered into, in other words it is the whole frame that you gave your chart. The plot area is just the GL area that your data is actually rendered within.

I hope the above helped!

Jan


#3

Hi Jan, 

Your code works perfectly.

Thank you very much!