How to adjust the area of ​​a plot of CorePlot in a graph

I draw a graph using the main graph. I am trying to plot a plot on a plot, but it contains a white background. But I want to build a chart with my own background. This is my code.

// setting frame of graph CGRect frame = [self.hostingView bounds]; self.graph = [[[CPTXYGraph alloc] initWithFrame:frame] autorelease]; // Add some padding to the graph, with more at the bottom for axis labels. self.graph.plotAreaFrame.paddingTop = 10.0f; self.graph.plotAreaFrame.paddingRight = 10.0f; self.graph.plotAreaFrame.paddingBottom = 25.0f; self.graph.plotAreaFrame.paddingLeft = 30.0f; // set background color of plot area by fill property and CPTColor self.graph.plotAreaFrame.plotArea.fill=[(CPTFill *)[CPTFill alloc] initWithColor: [CPTColor colorWithComponentRed:0.8 green:0.8 blue:0.8 alpha:1.0]]; // add graph to hosting view by hostedGraph property of hostingView self.hostingView.hostedGraph = self.graph; 

In the code above, I tried to change the color, but I want to draw horizontal dashed lines for each tick along the y axis.

+4
source share
2 answers

This is my code that I used for above ...

  // create an object of CPTMutableLineStyle and set property of it. CPTMutableLineStyle *dottedStyle=[CPTMutableLineStyle lineStyle]; dottedStyle.dashPattern=[NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:1,[NSDecimalNumber numberWithInt:2],nil]; dottedStyle.patternPhase=0.0f; // set the majorGridLinestyleProperty by this line as. axisSet.yAxis.majorGridLineStyle=dottedStyle; 
+5
source

Set majorGridLineStyle and / or minorGridLineStyle along the y axis to draw horizontal lines in the main and low ticks.

Use the line style dashPattern and patternPhase properties to make a dashed line. For more information on how these properties work, see Apple Quartz 2D docs .

+4
source

Source: https://habr.com/ru/post/1389776/


All Articles