Improve OnChartValueSelectedListener
This commit is contained in:
parent
2b886a463e
commit
dfc0b46f48
19 changed files with 35 additions and 37 deletions
|
@ -258,7 +258,7 @@ public class BarChartActivity extends DemoBase implements OnSeekBarChangeListene
|
|||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
if (e == null)
|
||||
return;
|
||||
|
|
|
@ -269,8 +269,8 @@ public class BarChartActivityMultiDataset extends DemoBase implements OnSeekBarC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
Log.i("Activity", "Selected: " + e.toString() + ", dataSet: " + dataSetIndex);
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("Activity", "Selected: " + e.toString() + ", dataSet: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -210,10 +210,10 @@ public class BubbleChartActivity extends DemoBase implements OnSeekBarChangeList
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -142,10 +142,10 @@ public class DrawChartActivity extends DemoBase implements OnChartValueSelectedL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -146,7 +146,7 @@ public class DynamicalAddingActivity extends DemoBase implements OnChartValueSel
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
|
|
@ -250,13 +250,13 @@ public class HorizontalBarChartActivity extends DemoBase implements OnSeekBarCha
|
|||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
if (e == null)
|
||||
return;
|
||||
|
||||
RectF bounds = mChart.getBarBounds((BarEntry) e);
|
||||
PointF position = mChart.getPosition(e, mChart.getData().getDataSetByIndex(dataSetIndex)
|
||||
PointF position = mChart.getPosition(e, mChart.getData().getDataSetByIndex(h.getDataSetIndex())
|
||||
.getAxisDependency());
|
||||
|
||||
Log.i("bounds", bounds.toString());
|
||||
|
|
|
@ -230,10 +230,10 @@ public class InvertedLineChartActivity extends DemoBase implements OnSeekBarChan
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -433,7 +433,7 @@ public class LineChartActivity1 extends DemoBase implements OnSeekBarChangeListe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("Entry selected", e.toString());
|
||||
Log.i("LOWHIGH", "low: " + mChart.getLowestVisibleX() + ", high: " + mChart.getHighestVisibleX());
|
||||
Log.i("MIN MAX", "xmin: " + mChart.getXChartMin() + ", xmax: " + mChart.getXChartMax() + ", ymin: " + mChart.getYChartMin() + ", ymax: " + mChart.getYChartMax());
|
||||
|
|
|
@ -357,10 +357,10 @@ public class LineChartActivity2 extends DemoBase implements OnSeekBarChangeListe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("Entry selected", e.toString());
|
||||
|
||||
mChart.centerViewToAnimated(e.getX(), e.getY(), mChart.getData().getDataSetByIndex(dataSetIndex).getAxisDependency(), 500);
|
||||
mChart.centerViewToAnimated(e.getX(), e.getY(), mChart.getData().getDataSetByIndex(h.getDataSetIndex()).getAxisDependency(), 500);
|
||||
//mChart.zoomAndCenterAnimated(2.5f, 2.5f, e.getX(), e.getY(), mChart.getData().getDataSetByIndex(dataSetIndex).getAxisDependency(), 1000);
|
||||
//mChart.zoomAndCenterAnimated(1.8f, 1.8f, e.getX(), e.getY(), mChart.getData().getDataSetByIndex(dataSetIndex).getAxisDependency(), 1000);
|
||||
}
|
||||
|
|
|
@ -220,10 +220,10 @@ public class MultiLineChartActivity extends DemoBase implements OnSeekBarChangeL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -247,13 +247,13 @@ public class PieChartActivity extends DemoBase implements OnSeekBarChangeListene
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
if (e == null)
|
||||
return;
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
"Value: " + e.getY() + ", index: " + h.getX()
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -253,13 +253,13 @@ public class PiePolylineChartActivity extends DemoBase implements OnSeekBarChang
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
if (e == null)
|
||||
return;
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -204,7 +204,7 @@ public class RealtimeLineChartActivity extends DemoBase implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("Entry selected", e.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -208,10 +208,10 @@ public class ScatterChartActivity extends DemoBase implements OnSeekBarChangeLis
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -227,7 +227,7 @@ public class StackedBarActivity extends DemoBase implements OnSeekBarChangeListe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
BarEntry entry = (BarEntry) e;
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ public class StackedBarActivityNegative extends DemoBase implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
BarEntry entry = (BarEntry) e;
|
||||
Log.i("VAL SELECTED",
|
||||
|
|
|
@ -649,7 +649,7 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
mSelectionListener.onNothingSelected();
|
||||
else {
|
||||
// notify the listener
|
||||
mSelectionListener.onValueSelected(e, high.getDataSetIndex(), high);
|
||||
mSelectionListener.onValueSelected(e, high);
|
||||
}
|
||||
}
|
||||
// redraw the chart
|
||||
|
|
|
@ -201,7 +201,7 @@ public class Highlight {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Highlight, x: " + mX + "y: " + mY + ", dataSetIndex: " + mDataSetIndex
|
||||
return "Highlight, x: " + mX + ", y: " + mY + ", dataSetIndex: " + mDataSetIndex
|
||||
+ ", stackIndex (only stacked barentry): " + mStackIndex;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,21 +6,19 @@ import com.github.mikephil.charting.highlight.Highlight;
|
|||
/**
|
||||
* Listener for callbacks when selecting values inside the chart by
|
||||
* touch-gesture.
|
||||
*
|
||||
*
|
||||
* @author Philipp Jahoda
|
||||
*/
|
||||
public interface OnChartValueSelectedListener {
|
||||
|
||||
/**
|
||||
* Called when a value has been selected inside the chart.
|
||||
*
|
||||
* @param e The selected Entry.
|
||||
* @param dataSetIndex The index in the datasets array of the data object
|
||||
* the Entrys DataSet is in.
|
||||
* @param h the corresponding highlight object that contains information
|
||||
* about the highlighted position
|
||||
*
|
||||
* @param e The selected Entry
|
||||
* @param h The corresponding highlight object that contains information
|
||||
* about the highlighted position
|
||||
*/
|
||||
void onValueSelected(Entry e, int dataSetIndex, Highlight h);
|
||||
void onValueSelected(Entry e, Highlight h);
|
||||
|
||||
/**
|
||||
* Called when nothing has been selected or an "un-select" has been made.
|
||||
|
|
Loading…
Add table
Reference in a new issue