Change axis title font and color


#1

I unsuccessfully try to change the font and color of the X axis label.

I already tried to xAxis.titleLabel.textColor as well as xAxis.style.titleStyle.font and xAxis.style.titleStyle.textColor. None of them have any effect.

Any advice?


#2

Try using xAxis.style.titleStyle.font instead.


#3

Tried that as well. Also doesn’t work. I set it to a clearly different font and also different color but the X axis label stays gray and Arial.


#4

@kalle any resolution? I tried the [[UILabel appearance] setFont:[UIFont fontWithName:@“myCustom” andSize:15]];.

The above works but not for the shinobi charts at least. I have also tried the appearanceWhenContainedIn [ShinobicChart class]. No success.
The overall outcome seems really undertministic - i think i got it working on the axis but the annotations were blank - dont know why. Then i got the annotationsWithText working by setting the font by hand. But then the axis were back.

I tried setting the charts font explicitly via “kalle” methods ( like i said for the annotations this method worked) but it does work only on the legend. The setting of the title on the axis does not work. Have you got any solution? I will try to do an demo app just for testing the fonts. Thank you in advance.Thx.


#5

No, I do not have any solution for this problem yet. The styling works fine for the Y axis label but it simply doesn’t work for the X axis.

In my opinion this is a bug in the library. Any comment from a Shinobi ninja?


#6

Hi Kalle,

Have you tried setting the font and text color properties on the x axis of your chart like this:

chart.xAxis.titleLabel.font = [UIFont fontWithName:@"ChalkboardSE-Bold" size:20];
chart.xAxis.titleLabel.textColor = [UIColor redColor];

Kind regards,

Daniel Allsop


#7

Ok, that works. This is definitely a bug in the library.

If I call the code on the axis directly BEFORE I add it to the chart, the color and font is not applied. If I do it AFTER adding the axis to the chart, it works.


#8

Hi Kalle,

We know about this issue and it’s currently under investigation. This should be fixed in a future release.

Kind regards,

Daniel Allsop


#9

HI There, 

I just download the 2015 Trail package for the Suite. Playing around with the chart demo, in the getting start guide. I followed your advice on setting properties after adding the axis but this is not working, still ?

m_dailyChart.xAxis = xAxis;

    m_dailyChart.xAxis.enableGesturePanning = YES;

    m_dailyChart.xAxis.enableGestureZooming = YES;

    m_dailyChart.xAxis.title = @“Date/Time”;

    m_dailyChart.xAxis.titleLabel.textColor = [UIColorredColor];

    m_dailyChart.xAxis.titleLabel.text = @“Date/Time”;

    

    SChartNumberAxis *yAxis = [[SChartNumberAxisalloc] init];

    

    m_dailyChart.yAxis = yAxis;

    m_dailyChart.yAxis.enableGesturePanning = YES;

    m_dailyChart.yAxis.enableGestureZooming = YES;

    m_dailyChart.yAxis.rangePaddingLow = @(0.1);

    m_dailyChart.yAxis.rangePaddingHigh = @(0.1);

    m_dailyChart.yAxis.title = @“mg/dl”;

    m_dailyChart.yAxis.titleLabel.textColor = [UIColorredColor];

    m_dailyChart.yAxis.titleLabel.text = @“temp”;

Also if I try to set the m_dailyChart.chartBackgroundColor , I get a compiler error saying there is no setting for this property. 

I am working in Xcode 6.2(beta )

Thanks for your help !


#10

Hi,

To style components of the chart we use style objects. This also applies to the axis title labels with the attributes being set using SChartTitleStyle.

So rather than setting the properties directly on the label itself, you can do the following:

yAxis.style.titleStyle.textColor = [UIColor redColor];
yAxis.style.titleStyle.font = [UIFont systemFontOfSize:30.f];

 In your case, you were setting attributes on the label which were then being overwritten by the default values for SChartTitleLabelStyle.

I hope that solves your issue!

Sam