- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在显示一个图表,其中左侧和右侧的 y 轴相同。在我的代码中的某个地方,我已经告诉 x 轴和左 y 轴的轴间隔保持在绘图空间/图形区域之外。
我脑子放屁了,有什么可以说明的吗?
我的代码:
if ((int)[[UIScreen mainScreen] bounds].size.height == 568) {
self.hostView = [(CPTGraphHostingView *) [CPTGraphHostingView alloc] initWithFrame:CGRectMake(0, 190, 320, 265)];
}
else {
self.hostView = [(CPTGraphHostingView *) [CPTGraphHostingView alloc] initWithFrame:CGRectMake(0, 190, 320, 178)];
}
self.hostView.allowPinchScaling = NO;
[self.view addSubview:self.hostView];
graph = [[CPTXYGraph alloc] initWithFrame:self.hostView.bounds];
self.hostView.hostedGraph = graph;
CPTGradient *gradient = [CPTGradient gradientWithBeginningColor:[CPTColor colorWithCGColor:[UIColorFromRGB(0x2468d8)CGColor]]
endingColor:[CPTColor colorWithCGColor:[UIColorFromRGB(0xa4bbe0)CGColor]]];
gradient.angle = 90.0;
graph.plotAreaFrame.fill = [CPTFill fillWithGradient:gradient];
CPTMutableLineStyle *borderLineStyle = [CPTMutableLineStyle lineStyle];
borderLineStyle.lineColor = [CPTColor colorWithCGColor:[UIColorFromRGB(0x717a72)CGColor]];
borderLineStyle.lineWidth = 4.0;
graph.plotAreaFrame.borderLineStyle = borderLineStyle;
graph.plotAreaFrame.cornerRadius = 10.0;
[graph.plotAreaFrame setPaddingLeft:21.0f];
[graph.plotAreaFrame setPaddingRight:21.0f];
[graph.plotAreaFrame setPaddingBottom:18.0f];
graph.paddingLeft = 3.0;
graph.paddingTop = 3.0;
graph.paddingRight = 3.0;
graph.paddingBottom = 3.0;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
[dateFormatter setDateFormat:@"yyy-MM-dd HH:mm:ss"];
NSDate *firstDate = [dateFormatter dateFromString:[[changedArray objectAtIndex:0]objectForKey:@"date"]];
NSDate *lastDate = [dateFormatter dateFromString:[[changedArray objectAtIndex:changedArray.count-1]objectForKey:@"date"]];
NSNumber *difference = [NSDecimalNumber numberWithDouble:[lastDate timeIntervalSinceDate:firstDate]];
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;
plotSpace.allowsUserInteraction = NO;
plotSpace.delegate = self;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat([difference integerValue]*1.05)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat([yMaxValue integerValue]+5)];
plotSpace.globalXRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0) length:CPTDecimalFromFloat([difference integerValue]*1.05)];
plotSpace.globalYRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0) length:CPTDecimalFromDouble([yMaxValue doubleValue]*1.23)];
CPTMutableLineStyle *graphLineStyle = [CPTMutableLineStyle lineStyle];
graphLineStyle.lineCap = kCGLineCapRound;
graphLineStyle.lineColor = [CPTColor whiteColor];
graphLineStyle.lineWidth = 1.0;
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x = axisSet.xAxis;
x.axisLineStyle = graphLineStyle;
x.axisLineStyle = graphLineStyle;
x.axisConstraints = [CPTConstraints constraintWithLowerOffset:0];
x.minorTickLength = 3.0f;
x.majorTickLength = 5.0f;
CPTMutableTextStyle *labelStyle = [CPTMutableTextStyle textStyle];
labelStyle.color = [[CPTColor whiteColor] colorWithAlphaComponent:1];
labelStyle.fontName = @"Helvetica-Bold";
labelStyle.fontSize = 9.0f;
xFirstEntry = [[[changedArray objectAtIndex:0]objectForKey:@"date"] substringFromIndex:11];
xFirstEntry = [xFirstEntry substringToIndex:[xFirstEntry length] - 6];
xLastEntry = [[[changedArray objectAtIndex:changedArray.count-1]objectForKey:@"date"] substringFromIndex:11];
xLastEntry = [xLastEntry substringToIndex:[xLastEntry length] - 6];
NSMutableArray *xMajorLocations = [[NSMutableArray alloc]init];
NSMutableArray *xMinorLocations = [[NSMutableArray alloc]init];
NSMutableArray *xLabels = [[NSMutableArray alloc]init];
int newValue = [xFirstEntry integerValue];
NSNumber *xMajorDataPoint = [NSNumber numberWithInt:(newValue)];
NSNumber *xMinorDataPoint = [NSNumber numberWithInt:(newValue)];
if ([xFirstEntry integerValue] > [xLastEntry integerValue]) {
while (newValue <= 24) {
xMinorDataPoint = @([xMajorDataPoint integerValue] + 1800);
NSNumber *x2LabelValue = [NSNumber numberWithInt:newValue];
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[x2LabelValue stringValue] textStyle:labelStyle];
label.tickLocation = CPTDecimalFromInt([xMajorDataPoint intValue]);
label.offset = 5;
[xLabels addObject:label];
[xMajorLocations addObject:xMajorDataPoint];
[xMinorLocations addObject:xMinorDataPoint];
newValue++;
xMajorDataPoint = @([xMajorDataPoint integerValue] + 3600);
}
newValue = 1;
xMinorDataPoint = @([xMajorDataPoint integerValue] + 1800);
NSNumber *x2LabelValue = [NSNumber numberWithInt:newValue];
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[x2LabelValue stringValue] textStyle:labelStyle];
label.tickLocation = CPTDecimalFromInt([xMajorDataPoint intValue]);
label.offset = 5;
[xLabels addObject:label];
[xMajorLocations addObject:xMajorDataPoint];
[xMinorLocations addObject:xMinorDataPoint];
newValue++;
xMajorDataPoint = @([xMajorDataPoint integerValue] + 3600);
while (newValue <= [xLastEntry integerValue]+1) {
xMinorDataPoint = @([xMajorDataPoint integerValue] + 1800);
NSNumber *x2LabelValue = [NSNumber numberWithInt:newValue];
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[x2LabelValue stringValue] textStyle:labelStyle];
label.tickLocation = CPTDecimalFromInt([xMajorDataPoint intValue]);
label.offset = 5;
[xLabels addObject:label];
[xMajorLocations addObject:xMajorDataPoint];
[xMinorLocations addObject:xMinorDataPoint];
newValue++;
xMajorDataPoint = @([xMajorDataPoint integerValue] + 3600);
}
}
else {
while (newValue <= [xLastEntry integerValue]+1) {
xMinorDataPoint = @([xMajorDataPoint integerValue] + 1800);
NSNumber *xLabelValue = [NSNumber numberWithInt:newValue];
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[xLabelValue stringValue] textStyle:labelStyle];
label.tickLocation = CPTDecimalFromInt([xMajorDataPoint intValue]);
label.offset = 5;
[xLabels addObject:label];
[xMajorLocations addObject:xMajorDataPoint];
[xMinorLocations addObject:xMinorDataPoint];
newValue++;
xMajorDataPoint = @([xMajorDataPoint integerValue] + 3600);
}
}
x.labelingPolicy = CPTAxisLabelingPolicyNone;
x.axisLabels = [NSSet setWithArray:xLabels];
x.majorTickLocations = [NSSet setWithArray:xMajorLocations];
x.minorTickLocations = [NSSet setWithArray:xMinorLocations];
x.majorTickLineStyle = graphLineStyle;
x.minorTickLineStyle = graphLineStyle;
CPTXYAxis *y = axisSet.yAxis;
y.axisLineStyle = graphLineStyle;
y.majorIntervalLength = CPTDecimalFromDouble(10);
y.minorTicksPerInterval = 9;
y.minorTickLength = 3;
y.majorTickLength = 5;
y.labelOffset = 0;
y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(0);
y.labelTextStyle = labelStyle;
y.majorTickLineStyle = graphLineStyle;
y.minorTickLineStyle = graphLineStyle;
NSNumberFormatter *Yformatter = [[NSNumberFormatter alloc] init];
[Yformatter setGeneratesDecimalNumbers:NO];
[Yformatter setNumberStyle:NSNumberFormatterDecimalStyle];
y.labelFormatter = Yformatter;
y.axisConstraints = [CPTConstraints constraintWithLowerOffset:0];
CPTXYAxis *y2 = [(CPTXYAxis *)[CPTXYAxis alloc] initWithFrame:CGRectZero];
y2.coordinate = CPTCoordinateY;
y2.plotSpace = plotSpace;
y2.axisLineStyle = graphLineStyle;
y2.majorIntervalLength = CPTDecimalFromDouble(10);
y2.minorTicksPerInterval = 9;
y2.minorTickLength = 3;
y2.majorTickLength = 5;
y2.labelOffset = -20;
y2.labelTextStyle = labelStyle;
y2.majorTickLineStyle = graphLineStyle;
y2.minorTickLineStyle = graphLineStyle;
y2.labelFormatter = Yformatter;
y2.axisConstraints = [CPTConstraints constraintWithUpperOffset:0];
graph.axisSet.axes = @[x, y, y2];
最佳答案
您可以按如下方式设置刻度线的方向:
y.tickDirection = CPTSignPositive;
您还可以选择 CPTSignNegative
,具体取决于您希望相对于轴放置刻度的方向。
在你的代码中,我认为你看到的是由于
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[x2LabelValue stringValue] textStyle:labelStyle];
label.tickLocation = CPTDecimalFromInt([xMajorDataPoint intValue]);
label.offset = 5;
关于ios - 如何仅在核心图的轴外放置间隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21272650/
语句 1: [2,4,6,7,8].each do |i| (i % 2 == 0) || (puts "Not even" && break) puts i end 声明 2: [2
我有一张正在显示的卡片,上面有一些信息。我想将其包装在SingleChildScrollView中,因为我还有更多项目要添加到卡中,但是当我这样做时,屏幕只是空白吗?我曾尝试将其作为根(脚手架主体)放
我有一个带有窗体的 View ,该窗体显示ViewModel中ObservableCollection中对象的数据。 ObservableCollection使我可以浏览数据。 ObservableC
如何将时间戳附加文件名放在HDFS中? hadoop fs -put topic_2018-12-15%2016:31:15.csv /user/file_structure/ 最佳答案 您只是在运行
我正在寻求一些帮助,以找出为什么以下叠加函数的运行时间会随着每次连续运行而增加。 据我所知,如果缓冲区中的文本保持不变,则运行时间应该是相同的——即,仅向左/向右移动光标应该不会增加运行时间(但它确实
我有一个事件指示器,它显示在中间。如何将其放置在 View 的左上角? var activityIndicator = UIActivityIndicatorView() func show() {
首先,我想提前感谢所有回答这个问题的人。非常感谢您的帮助。这是我第一次在这里发帖,所以如果我发帖不礼貌,请原谅我。 我的问题是关于方法原型(prototype)的: void copySubtree(
我正在开发一个应该是通用的应用程序,一个适用于 iPad 和 iPhone 的应用程序。我想让他们的界面尽可能相似。在 iPhone 应用程序中,我使用的是选项卡栏 Controller ,其中一个选
我目前正在使用 JS 开发 REST API,但遇到以下问题:该代码有效,但如果我尝试删除、放置或修补不存在的条目,它不会返回错误,但会打印成功消息。这是为什么?获取路由完美运行。 app.route
.a{ width:500px; height:500px; background:yellow; border: 3px dashed black; }
首先,请引用下图: 这基本上是我对布局的想法。 我想要的是: 内容 div 成为“主要焦点”,例如当浏览器 调整大小,它应该留在中间; 当浏览器被调整大小时,我希望这两个图像基本上 位于内容 div
我的应用程序需要使用内存映射并发访问数据文件。我的目标是使其在共享内存系统中可扩展。研究了内存映射文件库实现的源码,想不通: 在多个线程中从 MappedByteBuffer 中读取是否合法? get
我有一个 JDesktopPane 并希望以网格样式显示 JInternalFrames 而无需覆盖框架。框架的尺寸会有所不同,因此应动态分配它们的位置。我可以存储最后放置的框架的坐标,但可以移动、最
根据https://isocpp.org/wiki/faq/dtors#placement-new传递给placement-new的地址必须正确对齐。但它给出的例子似乎与此相矛盾。 char memo
我最近一直在查看 Illumos 源代码,发现了一些奇怪的东西。 在他们的源代码中,函数类型是这样写的: static int outdec64(unsigned char *out, unsigne
您好,我目前正在尝试在我的一张图片旁边放置一个图例,但我在放置时遇到了问题。 我想将图例放在图像的左侧或右侧。这是我当前的代码: .my-legend .legend-title { text-a
根据文档, print 之间的唯一区别和 say 似乎是后者添加了 "\n"(并使用 .gist 进行字符串化)。然而, perl6 -e 'print "del\b\b"' 打印“d”,有效地应用转
所以我试图将我的图像标志放在背景上,但我的背景突然被裁剪,出现了一半的黑屏。如图: 我的 main.dart 代码: import 'package:flutter/material.dart'; i
我正在使用 Azure DevOps 构建 python 轮。我想让它尽可能通用,以便团队中的每个人都可以使用相同的管道来构建自己的 python 轮并将它们部署在一些 databricks 工作区中
在构建标准(非 WordPress)网页时,我通常会在正文末尾之前加载所有 javascript 文件,然后包含页面特定 js 代码的部分。 WorPress 建议使用 wp_enqueue_scri
我是一名优秀的程序员,十分优秀!