williamsandonz
williamsandonz

Reputation: 16430

Core plot gridLines can't get dotted line working?

Trying to get a simple dotted line for my gridLines but, can't get it to work (is currently block solid line). Not much help on the internet for this!

   CPTMutableLineStyle *gridLineStyle = [CPTMutableLineStyle lineStyle];
        gridLineStyle.lineColor = [self axisGreyClr];
        //gridLineStyle.lineWidth = 1.0f;
        gridLineStyle.dashPattern = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.8f], nil];
        gridLineStyle.patternPhase=0.0f;

Upvotes: 1

Views: 1470

Answers (2)

Chandramani
Chandramani

Reputation: 889

What Eric said above ,Code to get the Dashed Line

CPTMutableLineStyle *gridLineStyle = [CPTMutableLineStyle lineStyle];

gridLineStyle.dashPattern=[NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:1],[NSDecimalNumber numberWithInt:2],[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:4],[NSDecimalNumber numberWithInt:5],[NSDecimalNumber numberWithInt:6],[NSDecimalNumber numberWithInt:7],[NSDecimalNumber numberWithInt:8],nil];

Upvotes: 5

Eric Skroch
Eric Skroch

Reputation: 27381

The dashPattern array should contain at least two values. This is just a wrapper for the CGContextSetLineDash() function. The first value is the length of a painted segment of the line and the second value is length of an unpainted segment. The pattern will repeat as needed to draw the line. You can provide more than two values to make patterns like — - — - —.

Upvotes: 5

Related Questions