Skip to content

Commit

Permalink
Added dataIndex param for highlightValue (combined charts)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Jan 22, 2020
1 parent 4e2a51d commit b7681bb
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,18 @@ public void highlightValues(Highlight[] highs) {
invalidate();
}

/**
* Highlights any y-value at the given x-value in the given DataSet.
* Provide -1 as the dataSetIndex to undo all highlighting.
* This method will call the listener.
* @param x The x-value to highlight
* @param dataSetIndex The dataset index to search in
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
*/
public void highlightValue(float x, int dataSetIndex, int dataIndex) {
highlightValue(x, dataSetIndex, dataIndex, true);
}

/**
* Highlights any y-value at the given x-value in the given DataSet.
* Provide -1 as the dataSetIndex to undo all highlighting.
Expand All @@ -575,7 +587,20 @@ public void highlightValues(Highlight[] highs) {
* @param dataSetIndex The dataset index to search in
*/
public void highlightValue(float x, int dataSetIndex) {
highlightValue(x, dataSetIndex, true);
highlightValue(x, dataSetIndex, -1, true);
}

/**
* Highlights the value at the given x-value and y-value in the given DataSet.
* Provide -1 as the dataSetIndex to undo all highlighting.
* This method will call the listener.
* @param x The x-value to highlight
* @param y The y-value to highlight. Supply `NaN` for "any"
* @param dataSetIndex The dataset index to search in
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
*/
public void highlightValue(float x, float y, int dataSetIndex, int dataIndex) {
highlightValue(x, y, dataSetIndex, dataIndex, true);
}

/**
Expand All @@ -587,7 +612,19 @@ public void highlightValue(float x, int dataSetIndex) {
* @param dataSetIndex The dataset index to search in
*/
public void highlightValue(float x, float y, int dataSetIndex) {
highlightValue(x, y, dataSetIndex, true);
highlightValue(x, y, dataSetIndex, -1, true);
}

/**
* Highlights any y-value at the given x-value in the given DataSet.
* Provide -1 as the dataSetIndex to undo all highlighting.
* @param x The x-value to highlight
* @param dataSetIndex The dataset index to search in
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
* @param callListener Should the listener be called for this change
*/
public void highlightValue(float x, int dataSetIndex, int dataIndex, boolean callListener) {
highlightValue(x, Float.NaN, dataSetIndex, dataIndex, callListener);
}

/**
Expand All @@ -598,7 +635,7 @@ public void highlightValue(float x, float y, int dataSetIndex) {
* @param callListener Should the listener be called for this change
*/
public void highlightValue(float x, int dataSetIndex, boolean callListener) {
highlightValue(x, Float.NaN, dataSetIndex, callListener);
highlightValue(x, Float.NaN, dataSetIndex, -1, callListener);
}

/**
Expand All @@ -607,17 +644,30 @@ public void highlightValue(float x, int dataSetIndex, boolean callListener) {
* @param x The x-value to highlight
* @param y The y-value to highlight. Supply `NaN` for "any"
* @param dataSetIndex The dataset index to search in
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
* @param callListener Should the listener be called for this change
*/
public void highlightValue(float x, float y, int dataSetIndex, boolean callListener) {
public void highlightValue(float x, float y, int dataSetIndex, int dataIndex, boolean callListener) {

if (dataSetIndex < 0 || dataSetIndex >= mData.getDataSetCount()) {
highlightValue(null, callListener);
} else {
highlightValue(new Highlight(x, y, dataSetIndex), callListener);
highlightValue(new Highlight(x, y, dataSetIndex, dataIndex), callListener);
}
}

/**
* Highlights any y-value at the given x-value in the given DataSet.
* Provide -1 as the dataSetIndex to undo all highlighting.
* @param x The x-value to highlight
* @param y The y-value to highlight. Supply `NaN` for "any"
* @param dataSetIndex The dataset index to search in
* @param callListener Should the listener be called for this change
*/
public void highlightValue(float x, float y, int dataSetIndex, boolean callListener) {
highlightValue(x, y, dataSetIndex, -1, callListener);
}

/**
* Highlights the values represented by the provided Highlight object
* This method *will not* call the listener.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ public class Highlight {
*/
private float mDrawY;

public Highlight(float x, float y, int dataSetIndex, int dataIndex) {
this.mX = x;
this.mY = y;
this.mDataSetIndex = dataSetIndex;
this.mDataIndex = dataIndex;
}

public Highlight(float x, float y, int dataSetIndex) {
this.mX = x;
this.mY = y;
this.mDataSetIndex = dataSetIndex;
this.mDataIndex = -1;
}

public Highlight(float x, int dataSetIndex, int stackIndex) {
Expand Down

0 comments on commit b7681bb

Please sign in to comment.