我刚接触编程和swift,所以我有一个问题...... 如何在 iOS 图表中设置最大缩放?尝试过:
func setBarChart(dataPoints: [String], humidity: [Double], andDays: Int, forTime: String)
{
let formato = BarChartFormatter()
let xaxis = XAxis()
var humidityEntry: [BarChartDataEntry] = []
for i in 0..<dataPoints.count
{
let dataEntry = BarChartDataEntry(x: Double(i), y: humidity[i])
humidityEntry.append(dataEntry)
formato.getNumberOfDays(Double(i), axis: xaxis, andDays: andDays)
}
xaxis.valueFormatter = formato
let barChartDataSet3 = BarChartDataSet(values: humidityEntry, label: "Humidity")
barChartDataSet3.setColor(UIColor.cyan)
barChartDataSet3.barBorderColor = UIColor.blue
barChartDataSet3.valueTextColor = UIColor.lightText
barChartView.leftAxis.labelTextColor = UIColor.white
barChartView.rightAxis.labelTextColor = UIColor.white
barChartView.leftAxis.labelFont = UIFont.systemFont(ofSize: 11)
barChartView.rightAxis.labelFont = UIFont.systemFont(ofSize: 11)
barChartView.scaleYEnabled = false
// barChartView.setVisibleXRange(minXRange: 0.1, maxXRange: 1.1)
// barChartView.autoScaleMinMaxEnabled = true
// barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 1.0)
switch forTime {
case "6months":
barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 3.1)
case "3months":
barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 2.1)
case "1month":
barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 1.5)
case "7days":
barChartView.setVisibleXRange(minXRange: 0.0, maxXRange: 1.0)
default:
break
}
if barChartView.xRange >= 1.0 && barChartView.xRange <= 0
{
barChartView.scaleXEnabled = false
}
// barChartView.setVisibleYRangeMaximum(2.0, axis: YAxis.)
// barChartView.
// if barChartView.scaleX > 1.3
// {
// barChartView.notifyDataSetChanged()
// barChartView.scaleXEnabled = false
// }
// barChartView.notifyDataSetChanged()
// barChartView.scaleXEnabled =
barChartView.highlightFullBarEnabled = false
var dataSets = [IChartDataSet]()
dataSets.append(barChartDataSet3)
let lineChartDataTemp = BarChartData(dataSets: dataSets)
barChartView.legend.font = UIFont.systemFont(ofSize: 14)
barChartView.legend.textColor = UIColor.white
barChartView.xAxis.valueFormatter = xaxis.valueFormatter
barChartView.data = lineChartDataTemp
barChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0)
}
但没有任何效果,有时我可以无限放大,有时它只会显示奇怪的放大图。
最佳答案
嗨,Dumitru Rogojinaru,
barChartView.setVisibleXRange(minXRange: 1, maxXRange: 3)
此方法和说明在图表类文件中的 BarLineChartViewBase.swift 中可用。
/// Limits the maximum and minimum value count that can be visible by pinching and zooming.
/// e.g. minRange=10, maxRange=100 no less than 10 values and no more that 100 values can be viewed
/// at once without scrolling
public func setVisibleXRange(minXRange minXRange: CGFloat, maxXRange: CGFloat)
{
let maxScale = _deltaX / minXRange
let minScale = _deltaX / maxXRange
_viewPortHandler.setMinMaxScaleX(minScaleX: minScale, maxScaleX: maxScale)
}
请引用 - https://github.com/danielgindi/Charts/issues/1820
希望对您有所帮助。
关于ios - 为 iOS 图表设置最大缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40861509/
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
我在使用omniauth/openid时遇到了一些麻烦。在尝试进行身份验证时,我在日志中发现了这一点:OpenID::FetchingError:Errorfetchinghttps://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username:undefinedmethod`io'fornil:NilClass重要的是undefinedmethodio'fornil:NilClass来自openid/fetchers.rb,在下面的代码片段中:moduleNetclass
我正在查看instance_variable_set的文档并看到给出的示例代码是这样做的:obj.instance_variable_set(:@instnc_var,"valuefortheinstancevariable")然后允许您在类的任何实例方法中以@instnc_var的形式访问该变量。我想知道为什么在@instnc_var之前需要一个冒号:。冒号有什么作用? 最佳答案 我的第一直觉是告诉你不要使用instance_variable_set除非你真的知道你用它做什么。它本质上是一种元编程工具或绕过实例变量可见性的黑客攻击
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
我正在玩HTML5视频并且在ERB中有以下片段:mp4视频从在我的开发环境中运行的服务器很好地流式传输到chrome。然而firefox显示带有海报图像的视频播放器,但带有一个大X。问题似乎是mongrel不确定ogv扩展的mime类型,并且只返回text/plain,如curl所示:$curl-Ihttp://0.0.0.0:3000/pr6.ogvHTTP/1.1200OKConnection:closeDate:Mon,19Apr201012:33:50GMTLast-Modified:Sun,18Apr201012:46:07GMTContent-Type:text/plain
我在Rails应用程序中使用CarrierWave/Fog将视频上传到AmazonS3。有没有办法判断上传的进度,让我可以显示上传进度如何? 最佳答案 CarrierWave和Fog本身没有这种功能;你需要一个前端uploader来显示进度。当我不得不解决这个问题时,我使用了jQueryfileupload因为我的堆栈中已经有jQuery。甚至还有apostonCarrierWaveintegration因此您只需按照那里的说明操作即可获得适用于您的应用的进度条。 关于ruby-on-r
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
我正在尝试为我的iOS应用程序设置cocoapods但是当我执行命令时:sudogemupdate--system我收到错误消息:当前已安装最新版本。中止。当我进入cocoapods的下一步时:sudogeminstallcocoapods我在MacOS10.8.5上遇到错误:ERROR:Errorinstallingcocoapods:cocoapods-trunkrequiresRubyversion>=2.0.0.我在MacOS10.9.4上尝试了同样的操作,但出现错误:ERROR:Couldnotfindavalidgem'cocoapods'(>=0),hereiswhy:U