使用最新的 ioscharts 显示条形图时出现问题
Issue in display of barchart with latest ioscharts
我在 2 个月后将 ios-charts 更新为最新代码。当我 运行 代码时,我看到了很多差异。
这是在更新库之前:
更新后:
这是生成图表的代码:
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()
我在 2 个月后将 ios-charts 更新为最新代码。当我 运行 代码时,我看到了很多差异。
这是在更新库之前:
更新后:
这是生成图表的代码:
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()