2525import com .github .mikephil .charting .interfaces .datasets .IDataSet ;
2626import com .github .mikephil .charting .listener .OnChartValueSelectedListener ;
2727import com .github .mikephil .charting .utils .ColorTemplate ;
28+ import com .github .mikephil .charting .utils .MPPointF ;
2829import com .xxmassdeveloper .mpchartexample .notimportant .DemoBase ;
2930
3031import java .util .ArrayList ;
@@ -108,6 +109,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
108109 mChart .invalidate ();
109110 break ;
110111 }
112+ case R .id .actionToggleIcons : {
113+ for (IDataSet set : mChart .getData ().getDataSets ())
114+ set .setDrawIcons (!set .isDrawIconsEnabled ());
115+
116+ mChart .invalidate ();
117+ break ;
118+ }
111119 case R .id .actionToggleHighlight : {
112120 if (mChart .getData () != null ) {
113121 mChart .getData ().setHighlightEnabled (!mChart .getData ().isHighlightEnabled ());
@@ -167,14 +175,14 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
167175 float val = (float ) (Math .random () * range );
168176 float size = (float ) (Math .random () * range );
169177
170- yVals1 .add (new BubbleEntry (i , val , size ));
178+ yVals1 .add (new BubbleEntry (i , val , size , getResources (). getDrawable ( R . drawable . star ) ));
171179 }
172180
173181 for (int i = 0 ; i < count ; i ++) {
174182 float val = (float ) (Math .random () * range );
175183 float size = (float ) (Math .random () * range );
176184
177- yVals2 .add (new BubbleEntry (i , val , size ));
185+ yVals2 .add (new BubbleEntry (i , val , size , getResources (). getDrawable ( R . drawable . star ) ));
178186 }
179187
180188 for (int i = 0 ; i < count ; i ++) {
@@ -186,11 +194,16 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
186194
187195 // create a dataset and give it a type
188196 BubbleDataSet set1 = new BubbleDataSet (yVals1 , "DS 1" );
197+ set1 .setDrawIcons (false );
189198 set1 .setColor (ColorTemplate .COLORFUL_COLORS [0 ], 130 );
190199 set1 .setDrawValues (true );
200+
191201 BubbleDataSet set2 = new BubbleDataSet (yVals2 , "DS 2" );
202+ set2 .setDrawIcons (false );
203+ set2 .setIconsOffset (new MPPointF (0 , 15 ));
192204 set2 .setColor (ColorTemplate .COLORFUL_COLORS [1 ], 130 );
193205 set2 .setDrawValues (true );
206+
194207 BubbleDataSet set3 = new BubbleDataSet (yVals3 , "DS 3" );
195208 set3 .setColor (ColorTemplate .COLORFUL_COLORS [2 ], 130 );
196209 set3 .setDrawValues (true );
0 commit comments