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
195
Extra lines appear when creating axis padding
posted

Hello,

I am aware that while there is not a property for setting padding between the x/y axis and the grid, there is a way to create padding by creating an extra axis.  I am implementing in the example below:

 IGNumericYAxis *y2 = [[IGNumericYAxis alloc]initWithKey:@"y2"];
    y2.extent = 10;
    y2.minimum = 0;
    y2.maximum = 1;
    y2.labelBrush = [[IGBrush alloc]initWithColor:[UIColor clearColor]];
    y2.labelsLocation = IGAxisLabelsLocationOutsideLeft;
    [_chart addAxis:y2];


 IGNumericXAxis *x2 = [[IGNumericXAxis alloc]initWithKey:@"x2"];
    x2.extent = 10;
    x2.minimum = 0;
    x2.maximum = 1;
    x2.labelBrush = [[IGBrush alloc]initWithColor:[UIColor clearColor]];
    x2.labelsLocation = IGAxisLabelsLocationOutsideBottom;
    [_chart addAxis:x2];


The padding seems to work, but it creates other issues in the graph.  I am seeing extra lines in the graph for example.  Do you have any ideas on why implementing the padding solution is causing the extra lines to appear?

How it looks when the extra lines appear:

How it looks when it is working normally:


Thanks,

Brett

Parents
No Data
Reply
  • 26458
    Verified Answer
    Offline posted

    Hi Brett,

    Each axis comes with a set of its own major and minor gridlines by default, so any time you add an axis you also get these gridlines showing.

    You can disable those lines by setting majorStroke, minorStroke properties to a clear brush or by setting majorStrokeThickness and minorStrokeThickness properties to 0. These properties are located on the axis itself.

        IGBrush *clearBrush = [[IGBrush alloc]initWithColor:[UIColor clearColor]];
        x.majorStroke = clearBrush;
        x.minorStroke = clearBrush;  

        //or

        x.majorStrokeThickness = 0;
        x.minorStrokeThickness = 0;

Children
No Data