5252import java .io .IOException ;
5353import java .io .OutputStream ;
5454import java .util .ArrayList ;
55-
56- import androidx . annotation . NonNull ;
55+ import java . util . Collections ;
56+ import java . util . List ;
5757
5858/**
5959 * Baseclass of all Chart-Views.
@@ -172,11 +172,6 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
172172 */
173173 private float mExtraTopOffset = 0.f , mExtraRightOffset = 0.f , mExtraBottomOffset = 0.f , mExtraLeftOffset = 0.f ;
174174
175- /**
176- * Tag for logging accessibility related content
177- */
178- private String TAG = "abilityTag" ;
179-
180175 /**
181176 * Additional data on top of dynamically generated description. This can be set by the user.
182177 */
@@ -543,12 +538,17 @@ public void highlightValues(Highlight[] highs) {
543538 invalidate ();
544539 }
545540
546- /**
547- * Highlights any y-value at the given x-value in the given DataSet.
548- * Provide -1 as the dataSetIndex to undo all highlighting.
549- * This method will call the listener.
550- *
551- * @param x The x-value to highlight
541+ public void highlightValues (List <Highlight > highs , List <IMarker > markers ) {
542+ if (highs .size () != markers .size ()) throw new IllegalArgumentException ("Markers and highs must be mutually corresponding. High size = " + highs .size () + " Markers size = " + markers .size ());
543+ setMarkers (markers );
544+ highlightValues (highs .toArray (new Highlight [0 ]));
545+ }
546+
547+ /**
548+ * Highlights any y-value at the given x-value in the given DataSet.
549+ * Provide -1 as the dataSetIndex to undo all highlighting.
550+ * This method will call the listener.
551+ ** @param x The x-value to highlight
552552 * @param dataSetIndex The dataset index to search in
553553 * @param dataIndex The data index to search in (only used in CombinedChartView currently)
554554 */
@@ -747,19 +747,21 @@ public ChartTouchListener getOnTouchListener() {
747747 /**
748748 * the view that represents the marker
749749 */
750- protected IMarker mMarker ;
750+ protected List < IMarker > mMarkers = new ArrayList <>() ;
751751
752752 /**
753753 * draws all MarkerViews on the highlighted positions
754754 */
755755 protected void drawMarkers (Canvas canvas ) {
756756
757757 // if there is no marker view or drawing marker is disabled
758- if (mMarker == null || !isDrawMarkersEnabled () || !valuesToHighlight ()) {
758+ if (mMarkers == null || !isDrawMarkersEnabled () || !valuesToHighlight ()) {
759759 return ;
760760 }
761761
762- for (Highlight highlight : mIndicesToHighlight ) {
762+ for (int i = 0 ; i < mIndicesToHighlight .length ; i ++) {
763+
764+ Highlight highlight = mIndicesToHighlight [i ];
763765
764766 // When changing data sets and calling animation functions, sometimes an erroneous highlight is generated
765767 // on the dataset that is removed. Null check to prevent crash
@@ -771,7 +773,7 @@ protected void drawMarkers(Canvas canvas) {
771773 Entry e = mData .getEntryForHighlight (highlight );
772774
773775 // make sure entry not null before using it
774- if (e == null || set == null ) {
776+ if (e == null ) {
775777 continue ;
776778 }
777779
@@ -789,10 +791,12 @@ protected void drawMarkers(Canvas canvas) {
789791 }
790792
791793 // callbacks to update the content
792- mMarker .refreshContent (e , highlight );
794+ int markerIndex = i % mMarkers .size ();
795+ IMarker markerItem = mMarkers .get (markerIndex );
796+ markerItem .refreshContent (e , highlight );
793797
794798 // draw the marker
795- mMarker .draw (canvas , pos [0 ], pos [1 ]);
799+ markerItem .draw (canvas , pos [0 ], pos [1 ]);
796800 }
797801 }
798802
@@ -1136,18 +1140,22 @@ public void setTouchEnabled(boolean enabled) {
11361140 this .mTouchEnabled = enabled ;
11371141 }
11381142
1139- /**
1140- * sets the marker that is displayed when a value is clicked on the chart
1141- */
1142- public void setMarker (IMarker marker ) {
1143- mMarker = marker ;
1144- }
1143+ public void setMarkers (List <IMarker > marker ) {
1144+ mMarkers = marker ;
1145+ }
11451146
1146- /**
1147+ /**
1148+ * sets the marker that is displayed when a value is clicked on the chart
1149+ */
1150+ public void setMarker (IMarker marker ) {
1151+ setMarkers (Collections .singletonList (marker ));
1152+ }
1153+ /**
11471154 * returns the marker that is set as a marker view for the chart
1155+
11481156 */
1149- public IMarker getMarker () {
1150- return mMarker ;
1157+ public List < IMarker > getMarker () {
1158+ return mMarkers ;
11511159 }
11521160
11531161 @ Deprecated
@@ -1156,7 +1164,7 @@ public void setMarkerView(IMarker v) {
11561164 }
11571165
11581166 @ Deprecated
1159- public IMarker getMarkerView () {
1167+ public List < IMarker > getMarkerView () {
11601168 return getMarker ();
11611169 }
11621170
@@ -1690,7 +1698,7 @@ public void setAccessibilitySummaryDescription(String accessibilitySummaryDescri
16901698 public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event ) {
16911699
16921700 boolean completed = super .dispatchPopulateAccessibilityEvent (event );
1693- Log .d (TAG , "Dispatch called for Chart <View> and completed as " + completed );
1701+ Log .d (LOG_TAG , "Dispatch called for Chart <View> and completed as " + completed );
16941702
16951703 event .getText ().add (getAccessibilityDescription ());
16961704
0 commit comments