我正在使用MPAndroidChart绘制包含大约1400条记录的烛台(ohlc)图表。我试图确保每当用户滚动时,Y轴都会自动缩放。这些是我的图表设置:
chart.setDrawBorders(false)
chart.setPinchZoom(false)
chart.axisRight.setDrawAxisLine(false)
chart.xAxis.setDrawAxisLine(false)
chart.xAxis.position = XAxis.XAxisPosition.BOTTOM
chart.xAxis.setDrawGridLines(false)
chart.axisRight.setDrawGridLines(false)
chart.axisLeft.isEnabled = false
chart.legend.isEnabled = false
chart.isAutoScaleMinMaxEnabled = true
var candles = it.data!!
var candleEntries = candles.mapIndexed { i, c -> c.toCandleEntry(i) }
var dataSet = CandleDataSet(candleEntries, market.id)
dataSet.setColor(Color.rgb(80, 80, 80));
dataSet.shadowColorSameAsCandle = true
dataSet.setShadowWidth(0.8f);
dataSet.setDecreasingColor(Color.RED);
dataSet.setDecreasingPaintStyle(Paint.Style.FILL);
dataSet.setIncreasingColor(Color.GREEN);
dataSet.setIncreasingPaintStyle(Paint.Style.FILL);
dataSet.setNeutralColor(Color.LTGRAY);
dataSet.setDrawValues(false);
dataSet.axisDependency = chart.axisRight.axisDependency
dataSet.barSpace = .25f
chart.data = CandleData(dataSet)
chart.setVisibleXRangeMaximum(40.toFloat())
chart.moveViewToX(candleEntries.size - 40f)
问题是,每当用户滚动时,图表就可能在某些y值之间并开始出现毛刺,如下所示:
有人知道为什么会这样吗?