Change font size and text color for x axis


#1

Hello, I am trying to change the font size and text color of the x axis to a chart with no luck, does somebody knows how to do this?, this is the code I have used:

//   Create   the_ chart_
ShinobiChart chart = new ShinobiChart (new RectangleF(0, 0, 453, 458) {
Title = “”,AutoresizingMask=UIViewAutoresizing.None,LicenseKey = "my license"};

//__ Some chart properties I have
chart.UserInteractionEnabled = true;
chart.AnimateZoomGesture = true;
chart.AnimateBoxGesture = true;
chart.GestureDoubleTapEnabled = true;
chart.GestureDoubleTapResetsZoom = true;
chart.GesturePinchAspectLock = false;

//__ X axis
SChartCategoryAxis xAxis = new SChartCategoryAxis ();
xAxis.Style.InterSeriesPadding = 0.1;
xAxis.EnableGesturePanning = true;
xAxis.EnableGestureZooming = true;
xAxis.Style.InterSeriesPadding = 0.5;

//__ The code I have tried to change the font and color:
xAxis.Style.TitleStyle.Font = UIFont.FromName(“HDI-GerlingSans-Regular”, 16);
xAxis.Style.TitleStyle.TextColor = UIColor.FromRGB (120, 120, 120);
xAxis.Style.TitleStyle.BackgroundColor = UIColor.Red;

xAxis.TitleLabel.Font = UIFont.FromName(“HDI-GerlingSans-Regular”, 16);
xAxis.TitleLabel.TextColor = UIColor.FromRGB (120, 120, 120);
xAxis.TitleLabel.BackgroundColor = UIColor.Red;

chart.XAxis = xAxis;

//__ Some other code to change the font and color:
chart.XAxis.TitleLabel.Font = UIFont.FromName(“HDI-GerlingSans-Regular”, 30);
chart.XAxis.TitleLabel.TextColor = UIColor.FromRGB (120, 120, 120);
chart.XAxis.TitleLabel.BackgroundColor = UIColor.Red;
chart.XAxis.AxisLabelsAreFixed = true;

//__ There is code for a y axis and two other y axis

//   Set   the   data_ source_
chart.DataSource = new myDataSource (mySource);
chart.RedrawChart();

//   Show   the   legend
chart.Legend.Hidden = false;
// chart. Legend. AutosizeLabels   =   true ;
chart.Legend.Position = SChartLegendPosition.TopMiddle;

//   Add   the   the_ view_
myView.AddSubview (chart);

I want to change the x axis font size, please let me know if you know of a solution, thanks.

By the way, am using Xamarin IOS.


#2

Hi RugalKain:

I was just wrestling with this myself.  Have you tried the following?

chart.xAxis.style.majorTickStyle.labelFont = [UIFont fontWithName:@"YourFont" size:YourSize];
    chart.xAxis.style.majorTickStyle.labelColor = [UIColor yourColor];

#3

Thanks a lot ascendancy05, this was indeed the solution.