- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我通过 Coreplot 生成了一个饼图。它在图表周围和所有部分都画了一条黑线,如下所示:
我使用以下代码生成图表:
-(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/
有人知道如何在 CorePlot 图形中去掉绘图区域框的外边距吗?我的 iPhone 应用程序中没有太多可用空间来显示它,因此我希望绘图区域框架与整个 View 尺寸相匹配。 考虑到: 修改填充不会影
我有一个带有 CorePlot 图表的 iPhone 应用程序。我希望用户能够像默认功能一样放大和缩小图表,除了一件事: 当用户水平捏合时 -> 缩放 x 轴。 垂直 -> 缩放 y 轴。 对角线 -
在 iPhone 应用程序中,我使用核心 Plot 垂直条形图。 如何消除竖条中的阴影效果? 这里如图所示,条形图显示有阴影 这是代码: CPBarPlot *barPlot = [CPBarPlot
我正在 iPhone 上使用 CorePlot。我可以做一个简单的图表。但我想做的是让 y 轴从 0 到 100,x 轴从 1998 年到 2007 年。如果可能的话,我想保留这个数字(不是基于自定义
我有 OS X 应用程序的图表,可以随窗口调整大小。我预计当宽度减小得足够多时,图例将被截断或剪裁。然而,它溢出到绘图区域之外,如下所示。理想情况下,我希望图例截断或至少剪辑内容。如何做到这一点? 我
我想编写一个自动滚动的绘图,因此实际时间位于右侧。 (标记为红色) 数据按时间间隔不规则地添加。我怎样才能做到这一点?我已经有一个滚动图(基于 coreplot 提供的示例代码)。但它并不完全准确并且
我在当前的项目中使用CorePlot及其惊人功能。 我遇到的唯一问题是轴和网格的长度。 我只使用左侧和底部带有标签的正坐标系。 我的问题是轴和网格在标签方向上的长度。 我尝试使用: axisSet.x
我试图绘制一个散点图,经过一段时间的探索后,轴标签正确了。我将标签策略设置为none,并添加了自己的自定义标签。但是由于某种原因,即使我使用了不同的示例数据,它也只能画一条直线。这是模拟器的图形图片
我整天都在研究这个,但仍然毫 headless 绪。我制作了两个数据集并将它们放入字典中,然后将其用作绘图的数据源。一切都应该工作,但它仍然只显示一个图表。 有趣的是,如果我更改 PLOT_IDENT
我正在尝试使用 CorePlot 绘制 iPhone 上传感器收集的数据,我几乎完成了它,但是 Coreplot 的初始化非常非常慢。这是我在 viewDidLoad 方法中的代码: CPTG
在我的应用程序中,我有一个 CorePlot,它托管三个散点图,我还配置如下, let borderStyle = CPTMutableLineStyle() border
在我的应用程序中,我使用 Core-plot 库来绘制垂直条形图。当用户点击栏时,它应该导航到另一个 View Controller 。 (它将离开同一 View Controller 的实例)。当我
我希望捕获 CorePlot 中轴标签的触摸事件。我知道现有的 plot:dataLabelWasSelectedAtRecordIndex: 方法,该方法类似,但不完全是我所希望的(我想要标签,而不
我正在使用 CorePlot 的 ScatterPlot 并想创建一个图例。图例应包含一个小于等于 符号。有什么办法吗? 最佳答案 将绘图的 title 或 attributedTitle 属性设置为
我正在尝试在 CorePlot 中的 y 轴上创建水平渐变: CPTGradient *axisGradient = [CPTGradient gradientWithBeginningColor:[
有什么方法可以根据片段的大小缩放片段的文本标签/图例。例如,如果它们的分段非常小,则标签的大小/比例会减小,以免被分隔符切断。 示例: 谢谢! 最佳答案 绘图不会自动调整标签,但您可以使用自定义数据标
这是一张我认为可以快速说明问题的图片。您只需从 git hub 下载示例,转到曲线散点图示例并点击一个点即可显示点注释,然后只需滚动图表即可将点移出图表。 所以通常我们希望注释 float 在所有内容
我正在使用 coreplot 绘制这样的散点图: 我使用了 4 个不同的图(按颜色显示),并通过在每个“条形”的开头/结尾添加 0 值点来创建“类似条形”的感觉。我想确定用户选择了哪个栏,然后更改其他
我正在尝试使用 NSAttributedString 为 coreplot 创建自定义标签。当我的字符串只有 1 行时一切正常。 当我想使用代码有 2 行字符串时出现问题: NSMutableAttr
我在 x 轴上使用日期标签,并希望使用自定义 View 突出显示特定日期。我计划使用 axis:labelWasSelected: ,将annotationFrame移动到标签位置并在轴范围更改时滚动
我是一名优秀的程序员,十分优秀!