0
我正在使用雙向選擇欄來選擇最小和最大範圍。MpAndroidChart CandleStick顯示雙搜索欄的範圍?
它在最大範圍下降時起作用,但是當拉出最小範圍時失效。
範圍搜索條OnRangeSekkbarChangedListener
:
RangeSeekBar.OnRangeSeekBarChangeListener<Integer> skListener = new RangeSeekBar.OnRangeSeekBarChangeListener<Integer>() {
@Override
public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
int max = bar.getSelectedMaxValue().intValue();
int min = bar.getSelectedMinValue().intValue();
mChart.resetTracking();
//Hold of actual drawing lists
List<CandleEntry> y = new ArrayList<CandleEntry>();
List<String> x = new ArrayList<String>();
for (int i = min; i < max ; i++){
//get candle entry from
CandleEntry current = yVals.get(i);
String currentDate = xVals.get(i);
y.add(current);
x.add(currentDate);
}
//Show less of the chart and invalidate
CandleDataSet mSet = new CandleDataSet(y, "Price");
mSet.setDecreasingColor(getResources().getColor(R.color.black));
mSet.setIncreasingPaintStyle(Paint.Style.FILL);
mSet.setIncreasingColor(getResources().getColor(R.color.accent));
mSet.setDecreasingPaintStyle(Paint.Style.FILL);
mSet.setShadowColor(getResources().getColor(R.color.black));
mCandledata = new CandleData(x, mSet);
//Don't show value text
mCandledata.setDrawValues(false);
mChart.setData(mCandledata);
mChart.invalidate();
}
};
rangeSeekBar.setOnRangeSeekBarChangeListener(skListener);
結果Sceenshots:
初始加載:
最大範圍拉到接近開頭:
分範圍內拉到接近結束: