swift - 使用最新的 ioscharts 显示条形图时出现问题

标签 swift ios-charts

我在 2 个月后将 ios-charts 更新为最新代码。当我运行代码时,我看到了很多不同之处。

这是在更新库之前:

enter image description here

更新后:

enter image description here

这是生成图表的代码:

    chart.infoTextColor = UIColor.blackColor()

        chart.backgroundColor = UIColor.whiteColor()
        chart.descriptionText = ""
        chart.noDataText = "Loading..."
        chart.rightAxis.enabled = false
        chart.xAxis.wordWrapEnabled = true

        chart.legend.position = .BelowChartCenter;
        chart.legend.form = .Circle;
        chart.legend.formSize = 10.0;
        chart.legend.formToTextSpace = 10.0;
        chart.legend.xEntrySpace = 4.0;
        chart.legend.yEntrySpace = 2.0
        chart.legend.stackSpace = 5.0
        chart.legend.textColor = UIColor.blueColor()

        chart.xAxis.gridColor = UIColor.blueColor()
//        chart.xAxis.axisLineColor = UIColor.blueColor()

        chart.gridBackgroundColor = UIColor.whiteColor()
        chart.borderColor = UIColor.redColor()

//        chart.xAxis.labelHeight = 18
//        chart.xAxis.labelWidth = 18
        chart.xAxis.labelPosition = .Bottom;
        chart.xAxis.drawGridLinesEnabled = false;

        chart.rightAxis.drawGridLinesEnabled = false;

        //zooming..
        chart.pinchZoomEnabled = false
        chart.doubleTapToZoomEnabled = false
        chart.scaleXEnabled = false
        chart.scaleYEnabled = false

        //new..
        chart.leftAxis.labelPosition = .InsideChart
chartDataSet.barSpace = 0.38

最佳答案

最新版本已弃用 startAtZeroEnabled,这似乎是您的情况。

请尝试设置 customAxisMin 以获得预期范围。例如customAxisMin = 0

记得在调用chartView.data = yourData之前设置,否则需要专门调用chartView.notifyDataSetChanged()

关于swift - 使用最新的 ioscharts 显示条形图时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35798915/

相关文章:

ios - 使用图表创建的条形图上仅出现一个标签

ios - 甚至在我的操作在 main 方法中完成之前就触发了完成 block

swift - iOS 图表饼图大小

ios - 条形图未缩放至 BarChartView 的大小

ios - 在 Swift 的函数中将 NSString 转换为 UInt8?

ios - danielgindi iOS Chart 我可以在组合图表上使用两个不同的 Yaxis 刻度吗

ios - 如何在 ios-charts 中为 BarChartView 添加 XAxis 标签

swift - 捏合手势识别器在第二次捏合缩放时重置图像

ios - TableView : Terminating app due to uncaught exception 'NSInternalInconsistencyException' Error

ios - 自定义 UIbutton 默认颜色 Xcode Swift