标签: core-plot

如何在iPhone上使用Core-Plot折线图实现放大和缩小?

iPhone上可以使用Core-Plot Chart组件实现放大和缩小吗?如果是的话请建议我怎么做?

提前致谢.

iphone charts core-plot

12
推荐指数
2
解决办法
1万
查看次数

核心情节 - 动态刷新图表+ iPad

我有一个graphview.m以这种方式创建coreplotviewcontroller.view

      CorePlotViewController *aCorePlotViewController = [[CorePlotViewController alloc] initWithNibName:@"CorePlotViewController" bundle:nil];
    aCorePlotViewController.view.bounds = CGRectMake(0,0,896,605);
    aCorePlotViewController.view.center = CGPointMake(576, 374.5);
    [aCorePlotViewController.view setTag:99];

    [self.view addSubview:aCorePlotViewController.view];
 [aCorePlotViewController.view release];
Run Code Online (Sandbox Code Playgroud)

现在我通过删除并再次添加图表来刷新图表.

 [[self.view viewWithTag:99]removeFromSuperview];

    CorePlotViewController *aCPView = [[CorePlotViewController alloc] initWithNibName:@"CorePlotViewController" bundle:nil];
    aCPView.view.bounds = CGRectMake(0,0,896,605);
    aCPView.view.center = CGPointMake(576, 374.5);
    [aCPView.view setTag:99];

    [self.view addSubview:aCPView.view];
    [aCPView release];
Run Code Online (Sandbox Code Playgroud)

但这会占用大量内存,最终我无法再为CoreAnimation分配内存(即时记录此错误).

那么我该如何重新创建图表呢?假设在coreplotviewcontroller.m中使用创建方法来重绘图形.我目前的CorePlotViewController.h和.m代码如下

CorePlotViewController.h

#import <UIKit/UIKit.h>
#import "CorePlot-CocoaTouch.h"
#import "GraphView.h"

@interface CorePlotViewController : UIViewController <CPPlotDataSource>

{
CPXYGraph *graph;

NSMutableArray *dataForPlot;
NSMutableArray *dataForPlot2;

NSMutableArray *finalDatas;

NSMutableArray *numofdata;
NSMutableArray *numofdata2;
}

@property(readwrite, retain, nonatomic) NSMutableArray *dataForPlot;
@property(readwrite, retain, nonatomic) …
Run Code Online (Sandbox Code Playgroud)

iphone core-plot ipad

12
推荐指数
1
解决办法
9903
查看次数

如何将CorePlot创建的图形保存为jpg文件

我正在使用CorePlot在我的应用程序中绘制不同的图形.然后,我想将此图保存到jpg文件并发布到某个社交网站(例如,Twitter).

我做了一些文档阅读,并了解以下方法对我有用:

  • CGBitmapContextCreateImage:从位图图形上下文(即我的图形所在的视图或整个屏幕)创建CGImage作为副本 - 我理解对了吗?)

  • CGImageCreateWithImageInRect:如果需要,我可以剪掉图像的某些部分

  • [UIImage imageWithCGImage]:将CGImage转换为UIImage对象

  • UIImageJPEGRepresentation:将我的UIImage对象转换为jpg NSData对象,然后我可以将其分享到我的社交网络

    1. 第一个问题是:我是否理解了为完成任务我必须执行的操作顺序?我会自己尝试一下,但是我遇到了一个导致第二个问题的问题:

    2. 从哪儿可以得到图形上下文的信息传递到CGBitmapContextCreateImage如果我使用CorePlot?对不起,如果这是一个愚蠢的问题,但我不是真的在家里有图形上下文.

非常感谢您提前帮助!如果我在这里得到所有这些,我保证在这里发布我的代码示例.

好吧,多亏了布拉德,这真的很容易,但正如我所承认的那样,我必须发布这些内容:

CPXYGraph *graph=[[CPXYGraph alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];

// setting up the graph
// ...

UIImage *newImage=[graph imageOfLayer];
NSData *newPNG=UIImagePNGRepresentation(newImage); // or you can use JPG or PDF

// For test purposes I write the file to the Documents directory, but you can do whatever you want with your new .png file
NSString *filePath=[NSString stringWithFormat:@"%@/graph.png", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]];

if([newPNG writeToFile:filePath atomically:YES]) 
    NSLog(@"Created new file successfully");
Run Code Online (Sandbox Code Playgroud)

iphone core-plot

12
推荐指数
1
解决办法
3021
查看次数

如何在Core Plot中使用自定义标签打勾?

对于我的应用程序图形(线图),将轴标签格式化为十分之一是没有意义的.在没有提供自定义标签的情况下,似乎没有办法改变这种情况.

我能够根据此答案中的示例代码添加自定义轴标签,但标签没有刻度标记.

这是一个问题(我在这里没有看到任何东西)或者我错过了什么?

iphone core-plot

11
推荐指数
1
解决办法
3975
查看次数

iPhone Multi touch与CorePlot互动

我正在开发一个带有核心图表的iPhone应用程序.在一些教程的帮助下,我设法通过单点触摸和拖动来完成.如何通过多次触摸和拖动来实现?有人请帮帮我吗?

在此输入图像描述

ViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];

    EskPlotTheme *defaultTheme = [[EskPlotTheme alloc] init];
    linePlot = [[EskLinePlot alloc] init];
    linePlot.delegate = self;
    [linePlot renderInLayer:lineHostingView withTheme:defaultTheme]; 
    [defaultTheme release];    
}
Run Code Online (Sandbox Code Playgroud)

EskLinePlot.m

- (id)init
{
    self = [super init];
    if (self) 
    {
        // setting up the sample data here.
        sampleData = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:6000],
                                                      [NSNumber numberWithInt:3000],
                                                      [NSNumber numberWithInt:2000],
                                                      [NSNumber numberWithInt:5000],
                                                      [NSNumber numberWithInt:7000],
                                                      [NSNumber numberWithInt:8500],
                                                      [NSNumber numberWithInt:6500], nil];

    }
    return self;
}

- (void)renderInLayer:(CPTGraphHostingView *)layerHostingView withTheme:(CPTTheme *)theme
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c core-plot

11
推荐指数
1
解决办法
2468
查看次数

OBJ-C:获取NSMutableArray中的最小/最大值

我想得到一个NSMutableArray的最大值和最小值,这样我就可以根据这些最大值和最小值创建一个核心图绘图空间和图形.

我的代码如下:

NSMutableArray *contentArray = [NSMutableArray arrayWithCapacity:100];
NSUInteger i;
for (i=0; i<60; i++){
id x = [NSNumber numberWithFloat:i*0.05];
id y = [NSNumber numberWithFloat:1.2*rand()/(float)RAND_Max + 0.6];
[contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x, @"x", y, @"y", nil]];
}

self.dataForPlot = contentArray;

CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat() length:CPDecimalFromFloat()];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat() length:CPDecimalFromFloat()];
Run Code Online (Sandbox Code Playgroud)

如果我希望图形只跨越contentArray中指定的空间,我应该填写xRange和yRange赋值的空白?

iphone plot objective-c core-plot

10
推荐指数
2
解决办法
1万
查看次数

Core-Plot PieChart切片颜色

我在我的一个iPhone项目中使用核心情节.是否可以更改饼图中所选切片的颜色(使用CPPieChartDataSource,CPPieChartDelegate)?

iphone core-plot

10
推荐指数
2
解决办法
5471
查看次数

核心情节定制主题?

我在iPhone应用程序中使用Core-Plot作为趋势图,但还没有找到如何自定义背景.我可以使用内置主题创建主题,如kCPPlainWhiteTheme,但我该如何更改它们?还是创建一个新的?

我基本上需要做的是使背景透明.

编辑/更新

我测试了这段代码,但它似乎不起作用:

    //CPTheme *theme = [CPTheme themeNamed:kCPPlainWhiteTheme];
    CPTheme *theme = [[CPTheme alloc]init];
    chartTrend5 = (CPXYGraph *)[theme newGraph];    
    chartView.hostedGraph = chartTrend5;
    chartTrend5.paddingLeft = 0.0;
    chartTrend5.paddingTop = 0.0;
    chartTrend5.paddingRight = 0.0;
    chartTrend5.paddingBottom = 0.0;
    chartTrend5.fill = nil;
    chartTrend5.borderLineStyle = nil;
    chartView.hostedGraph.fill = nil;

    chartTrend5PlotSpace = (CPXYPlotSpace *)chartTrend5.defaultPlotSpace;
    chartTrend5PlotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
                                                              length:CPDecimalFromFloat(5)];

    // range is 0-125, but since the frame heights is 90, 
    // we need to convert the points to this adjusted scale. The factor is 0.72 => (90/125) …
Run Code Online (Sandbox Code Playgroud)

iphone core-plot

10
推荐指数
2
解决办法
7249
查看次数

如何避免这种程度的弧度误差?

在使用核心图创建饼图时,我为给定代码添加了动画

    CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform"];
   CATransform3D transform = CATransform3DMakeRotation(DegreesToRadians(360), 0, 0, 1);
   rotation.toValue = [NSValue valueWithCATransform3D:transform];  
    rotation.duration = 10.0f;
    [pieChart addAnimation:rotation forKey:@"rotation"];    
Run Code Online (Sandbox Code Playgroud)

此代码提供以下错误语义问题:

Implicit declaration of function 'DegreesToRadians' is invalid in C99
Run Code Online (Sandbox Code Playgroud)

我能做些什么来避免这种情况?

并且运行时它会产生以下错误:

Apple_o  Linker id error  "_DegreesToRadians", referenced from:
Run Code Online (Sandbox Code Playgroud)

感谢致敬

维贾雅库马尔

Rhytha的iOS开发人员

https://rhytha.com/

iphone core-animation core-plot pie-chart

10
推荐指数
1
解决办法
8115
查看次数

在Xcode 5项目中使用Core Plot 2

我正在使用这里的说明将Core Plot集成到我的iOS Xcode 5项目中,并且没有任何问题.

我尝试使用静态库安装,但似乎这是指1.4,因为没有目录调用,CorePlotHeaders但如果我尝试使用1.4我遇到运行时问题.

然后我尝试CorePlot-CocoaTouch.xcodeproj按照从属项目安装中的描述拖动它,但这只会复制它,就好像它是一个文件而不是整个项目.

是否有更多当前使用它作为静态库的说明或如何将项目错误地复制到我的项目中?

core-plot ios xcode5

10
推荐指数
2
解决办法
6231
查看次数

标签 统计

core-plot ×10

iphone ×9

objective-c ×2

charts ×1

core-animation ×1

ios ×1

ipad ×1

pie-chart ×1

plot ×1

xcode ×1

xcode5 ×1