如何使用核心图在图形上绘制虚线,该线表示轴的最大和最小范围。
在AndroidPlot中,ValueMarker是用于在图形上绘制最大和最小水平线的。
请帮我一下。
谢谢
这是我在这种情况下使用的:
@property (nonatomic, retain) CPTScatterPlot *myLine;
@property (nonatomic, retain) CPTGraph *graph;
-(void) configureHorizontalLine
{
// 1 - Create plot space
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) self.graph.defaultPlotSpace;
// 2 - Create the plot
self.myLine = [[CPTScatterPlot alloc] init];
self.myLine.dataSource = self;
self.myLine.identifier = @"myLine";
CPTColor *myPlotColor = [CPTColor redColor];
[self.graph addPlot:self.myLine toPlotSpace:plotSpace];
// 3 - Create styles
CPTMutableLineStyle *myPlotLineStyle = [self.myLine.dataLineStyle mutableCopy];
myPlotLineStyle.dashPattern=[NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:3],[NSDecimalNumber numberWithInt:3],nil]; //dashed line
myPlotLineStyle.lineWidth = 1;
myPlotLineStyle.lineColor = myPlotColor;
self.myLine.dataLineStyle = myPlotLineStyle;
}
同样在CPTPlotDataSource
方法中,您必须进行以下检查以识别线形图:
if ([[plot identifier] isEqual:@"myLine"])