Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore.Images;
import androidx.annotation.RequiresApi;
Expand All @@ -25,7 +24,6 @@
import android.view.ViewParent;

import com.github.mikephil.charting.animation.ChartAnimator;
import com.github.mikephil.charting.animation.Easing;
import com.github.mikephil.charting.animation.Easing.EasingFunction;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.components.IMarker;
Expand Down Expand Up @@ -54,6 +52,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Baseclass of all Chart-Views.
Expand Down Expand Up @@ -563,6 +563,12 @@ public void highlightValues(Highlight[] highs) {
invalidate();
}

public void highlightValues(List<Highlight> highs, List<IMarker> markers) {
if (highs.size() != markers.size()) throw new IllegalArgumentException("Markers and highs must be mutually corresponding. High size = " + highs.size() + " Markers size = " + markers.size());
setMarkers(markers);
highlightValues(highs.toArray(new Highlight[0]));
}

/**
* Highlights any y-value at the given x-value in the given DataSet.
* Provide -1 as the dataSetIndex to undo all highlighting.
Expand Down Expand Up @@ -772,15 +778,15 @@ public ChartTouchListener getOnTouchListener() {
/**
* the view that represents the marker
*/
protected IMarker mMarker;
protected List<IMarker> mMarkers;

/**
* draws all MarkerViews on the highlighted positions
*/
protected void drawMarkers(Canvas canvas) {

// if there is no marker view or drawing marker is disabled
if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight())
if (mMarkers == null || !isDrawMarkersEnabled() || !valuesToHighlight())
return;

for (int i = 0; i < mIndicesToHighlight.length; i++) {
Expand All @@ -803,10 +809,12 @@ protected void drawMarkers(Canvas canvas) {
continue;

// callbacks to update the content
mMarker.refreshContent(e, highlight);
int markerIndex = i % mMarkers.size();
IMarker markerItem = mMarkers.get(markerIndex);
markerItem.refreshContent(e, highlight);

// draw the marker
mMarker.draw(canvas, pos[0], pos[1]);
markerItem.draw(canvas, pos[0], pos[1]);
}
}

Expand Down Expand Up @@ -1246,22 +1254,25 @@ public void setTouchEnabled(boolean enabled) {
this.mTouchEnabled = enabled;
}

public void setMarkers(List<IMarker> marker) {
mMarkers = marker;
}

/**
* sets the marker that is displayed when a value is clicked on the chart
*
* @param marker
*/
public void setMarker(IMarker marker) {
mMarker = marker;
setMarkers(Collections.unmodifiableList(Collections.singletonList(marker)));
}

/**
* returns the marker that is set as a marker view for the chart
*
* @return
*/
public IMarker getMarker() {
return mMarker;
public List<IMarker> getMarker() {
return mMarkers;
}

@Deprecated
Expand All @@ -1270,7 +1281,7 @@ public void setMarkerView(IMarker v) {
}

@Deprecated
public IMarker getMarkerView() {
public List<IMarker> getMarkerView() {
return getMarker();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.util.AttributeSet;
import android.util.Log;

import com.github.mikephil.charting.components.IMarker;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BubbleData;
import com.github.mikephil.charting.data.CandleData;
Expand Down Expand Up @@ -236,7 +237,7 @@ public void setDrawOrder(DrawOrder[] order) {
protected void drawMarkers(Canvas canvas) {

// if there is no marker view or drawing marker is disabled
if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight())
if (mMarkers == null || !isDrawMarkersEnabled() || !valuesToHighlight())
return;

for (int i = 0; i < mIndicesToHighlight.length; i++) {
Expand All @@ -262,10 +263,11 @@ protected void drawMarkers(Canvas canvas) {
continue;

// callbacks to update the content
mMarker.refreshContent(e, highlight);
IMarker markerItem = mMarkers.get(i % mMarkers.size());
markerItem.refreshContent(e, highlight);

// draw the marker
mMarker.draw(canvas, pos[0], pos[1]);
markerItem.draw(canvas, pos[0], pos[1]);
}
}

Expand Down