gpt4 book ai didi

ios - Coreplot iOS - 删除饼图周围的边框线

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:47:53 27 4
gpt4 key购买 nike

我通过 Coreplot 生成了一个饼图。它在图表周围和所有部分都画了一条黑线,如下所示:

Coreplot example

我使用以下代码生成图表:

-(CPTFill *)sliceFillForPieChart:(CPTPieChart *)pieChart recordIndex:(NSUInteger)index
{
CPTFill *areaGradientFill ;

if (index==0)
return areaGradientFill= [CPTFill fillWithColor:[CPTColor colorWithComponentRed:0.0f/255.0f green:111.0f/255.0f blue:115.0f/255.0f alpha:1.0f]];
else if (index==1)
return areaGradientFill= [CPTFill fillWithColor:[CPTColor colorWithComponentRed:171.0f/255.0f green:213.0f/255.0f blue:199.0f/255.0f alpha:1.0f]];
else if (index==2)
return areaGradientFill= [CPTFill fillWithColor:[CPTColor yellowColor]];

return areaGradientFill;
}

-(void)constructPieChart:(NSString *)datain;
{

NSArray *strings = [datain componentsSeparatedByString:@","];

dataforcharts = [datain componentsSeparatedByString:@","];

NSLog(@"dataforcharts: %@", dataforcharts);

// Create pieChart from theme
pieGraph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTPlainWhiteTheme];
[pieGraph applyTheme:theme];
pieChartView.hostedGraph = pieGraph;
pieGraph.plotAreaFrame.borderLineStyle = nil;
pieGraph.plotAreaFrame.masksToBorder = NO;

pieGraph.paddingLeft = 20.0;
pieGraph.paddingTop = 20.0;
pieGraph.paddingRight = 20.0;
pieGraph.paddingBottom = 20.0;

pieGraph.axisSet = nil;

// Prepare a radial overlay gradient for shading/gloss
CPTGradient *overlayGradient = [[CPTGradient alloc] init];
overlayGradient.gradientType = CPTGradientTypeRadial;
overlayGradient = [overlayGradient addColorStop:[[CPTColor blackColor] colorWithAlphaComponent:0.0] atPosition:0.0];
overlayGradient = [overlayGradient addColorStop:[[CPTColor blackColor] colorWithAlphaComponent:0.3] atPosition:0.9];
overlayGradient = [overlayGradient addColorStop:[[CPTColor blackColor] colorWithAlphaComponent:0.7] atPosition:1.0];

// Add pie chart
piePlot = [[CPTPieChart alloc] init];
piePlot.dataSource = self;
piePlot.pieRadius = 100.0;
piePlot.pieInnerRadius = 50.0;
piePlot.identifier = @"Pie Chart 1";
piePlot.startAngle = M_PI_4;

// piePlot.sliceDirection = CPTPieDirectionCounterClockwise;
piePlot.borderLineStyle = [CPTLineStyle lineStyle];
piePlot.labelOffset = -40.0;
piePlot.overlayFill = [CPTFill fillWithGradient:overlayGradient];
[pieGraph addPlot:piePlot];

CPTMutableTextStyle *textStyle = [CPTMutableTextStyle textStyle];
textStyle.color = [CPTColor blackColor];
textStyle.fontName = @"Helvetica-Bold";
textStyle.fontSize = 16.0f;

pieGraph.title=@"Chart1";

pieGraph.titleTextStyle = textStyle;
pieGraph.titlePlotAreaFrameAnchor = CPTRectAnchorTop;
pieGraph.titleDisplacement = CGPointMake(0.0f, -1.0f);

int i = [[strings objectAtIndex:0] intValue];
int f = [[strings objectAtIndex:1] intValue];

NSLog(@"Int1: %i", i);
NSLog(@"Int2: %i", f);

// Add some initial data
NSMutableArray *contentArray = [NSMutableArray arrayWithObjects:[NSNumber numberWithDouble:i], [NSNumber numberWithDouble:f], nil];
self.dataForChart = contentArray;

CPTLegend *theLegend = [CPTLegend legendWithGraph:pieGraph];
theLegend.numberOfColumns = 2;
theLegend.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
theLegend.borderLineStyle = [CPTLineStyle lineStyle];
theLegend.cornerRadius = 5.0;

pieGraph.legend = theLegend;

pieGraph.legendAnchor = CPTRectAnchorBottom;
pieGraph.legendDisplacement = CGPointMake(0.0, -0.0);
}

我想删除图表周围的黑线。我已经尝试将 borderLineStyle 设置为 nil 但这似乎没有任何效果。

感谢任何帮助。

谢谢!

亚当

最佳答案

使用它并再次调试,它正在工作。

piePlot.borderLineStyle = nil;

关于ios - Coreplot iOS - 删除饼图周围的边框线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17697300/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com