Make Seekbar follow chart maxValue
Opened this issue · 3 comments
prasetyoandi commented
hi @hadiidbouk, I'm working with your library. so, what functions are used so that the chart changes according to the seekbar movement like this? (see picture)
hadiidbouk commented
Hello @prasetyoandi,
You should add a listener to your seekbar, then when you detect a new value you need to use these two functions :
selectBar(int index) : to select a bar like a click
deselectBar(int index) : to deselect a bar
You can filter the barData to get the index based on your value.
prasetyoandi commented
can you give an example with this code?
public class MainActivity extends AppCompatActivity {
private ChartProgressBar mChart;
private BubbleSeekBar bubbleSeekBar;
private TextView textView;
int min = 0, max = 9, current = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<BarData> dataList = new ArrayList<>();
BarData data = new BarData("Sep", 3, "3€");
dataList.add(data);
data = new BarData("Oct", 8, "8€");
dataList.add(data);
data = new BarData("Nov", 1, "1€");
dataList.add(data);
data = new BarData("Dec", 7, "7€");
dataList.add(data);
data = new BarData("Jan", 6, "6€");
dataList.add(data);
data = new BarData("Feb", 3, "3€");
dataList.add(data);
mChart = (ChartProgressBar) findViewById(R.id.ChartProgressBar);
mChart.setDataList(dataList);
mChart.build();
bubbleSeekBar = (BubbleSeekBar) findViewById(R.id.seek_bar_1);
textView = (TextView) findViewById(R.id.progress_text_1);
bubbleSeekBar.setProgress(max - min);
bubbleSeekBar.setProgress(current);
textView.setText("" + current);
bubbleSeekBar.setOnProgressChangedListener(new BubbleSeekBar.OnProgressChangedListener() {
@Override
public void onProgressChanged(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat) {
current = progress + min;
textView.setText("" + current);
}
@Override
public void getProgressOnActionUp(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat) {
}
@Override
public void getProgressOnFinally(BubbleSeekBar bubbleSeekBar, int progress, float progressFloat) {
}
});
}
}
hadiidbouk commented
Any update on this ?