Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1615
Axis Font
posted

How do we adjust the font for the axis. I have a chart that looks ok on the iPad but on the iPhone needs to show smaller font so that the X Axis is formatted better.

The x-Axis is dates (MMM-yy). I tried changing an extent and it makes it a bit better but would need to adjust font size as well to really make it look good. 

  • 48586
    posted

    Hello, ­­­­­

     

    I am just checking about the progress of this issue. Let me know If you need my further assistance on this  matter?

     

    Thank you for using Infragistics Components.

     

     

  • 26458
    Suggested Answer
    Offline posted

    The chart's theme has control over axis font, so in order to change the font you'll have to create a custom theme. Here's an example of a custom theme. It's a copy of our IG theme. If you don't need series brushes to come from a theme, you don't have to include any of the IGChartPaletteItems; they're just the default series brushes.

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    {
       _chartView.theme = [CustomChartTheme IPhoneTheme];
    }

    @implementation CustomChartTheme
    +(IGChartThemeDefinition*)IPhoneTheme
    {

    IGChartThemeDefinition* def = [[IGChartThemeDefinition alloc]init];
    def.name = @"IGChartIGTheme";
    def.font = [UIFont fontWithName:@"Helvetica" size:12];
    def.fontColor = [[IGBrush alloc] initWithR:0 andG:0 andB:0 andA:1];
    def.backgroundColor = [UIColor whiteColor];

    def.legendFont = [UIFont fontWithName:@"Helvetica" size:12];
    def.legendFontColor = [[IGBrush alloc] initWithR:0 andG:0 andB:0 andA:1];
    def.legendBorderThickness = 1;
    def.legendPalette = [[IGChartPaletteItem alloc]init];
    def.legendPalette.name = @"legend";
    def.legendPalette.color = [[IGBrush alloc] initWithR:0.9 andG:0.9 andB:0.9 andA:1];
    def.legendPalette.outlineColor = [[IGBrush alloc] initWithR:0.7 andG:0.7 andB:0.7 andA:1];

    IGChartPaletteItem* item1 = [[IGChartPaletteItem alloc] init];
    item1.name = @"item1";
    item1.outlineColor = [[IGBrush alloc] initWithR:0.14 andG:0.50 andB:0.66 andA:1];
    item1.color = [[IGBrush alloc] initWithR:0.27 andG:0.67 andB:0.84 andA:1];
    [def.seriesPalettes addObject:item1];

    IGChartPaletteItem* item2 = [[IGChartPaletteItem alloc] init];
    item2.name = @"item2";
    item2.outlineColor = [[IGBrush alloc] initWithR:0.2 andG:0.2 andB:0.2 andA:1];
    item2.color = [[IGBrush alloc] initWithR:0.29 andG:0.29 andB:0.29 andA:1];
    [def.seriesPalettes addObject:item2];

    IGChartPaletteItem* item3 = [[IGChartPaletteItem alloc] init];
    item3.name = @"item3";
    item3.outlineColor = [[IGBrush alloc] initWithR:0.5 andG:.5 andB:.5 andA:1];
    item3.color = [[IGBrush alloc] initWithR:.66 andG:.66 andB:.66 andA:1];
    [def.seriesPalettes addObject:item3];

    IGChartPaletteItem* item4 = [[IGChartPaletteItem alloc] init];
    item4.name = @"item4";
    item4.outlineColor = [[IGBrush alloc] initWithR:.09 andG:.32 andB:.44 andA:1];
    item4.color = [[IGBrush alloc] initWithR:.13 andG:.43 andB:0.6 andA:1];
    [def.seriesPalettes addObject:item4];

    IGChartPaletteItem* item5 = [[IGChartPaletteItem alloc] init];
    item5.name = @"item5";
    item5.outlineColor = [[IGBrush alloc] initWithR:.53 andG:.6 andB:.13 andA:1];
    item5.color = [[IGBrush alloc] initWithR:.64 andG:.73 andB:.16 andA:1];
    [def.seriesPalettes addObject:item5];

    IGChartPaletteItem* axis = [[IGChartPaletteItem alloc] init];
    axis.name = @"axis";
    axis.outlineColor = [[IGBrush alloc] initWithR:0.60 andG:0.62 andB:0.64 andA:1];
    axis.color = [[IGBrush alloc] initWithR:0.60 andG:0.62 andB:0.64 andA:1];
    def.axisPalette = axis;

    return def;
    }
    @end 

    Hope this helps you.