11
22package com .xxmassdeveloper .mpchartexample ;
33
4+ import android .graphics .Color ;
45import android .graphics .Typeface ;
56import android .os .Bundle ;
67import android .view .Menu ;
78import android .view .MenuItem ;
89import android .view .WindowManager ;
10+ import android .widget .TextView ;
911import android .widget .Toast ;
1012
1113import com .github .mikephil .charting .animation .Easing ;
@@ -37,16 +39,23 @@ protected void onCreate(Bundle savedInstanceState) {
3739 super .onCreate (savedInstanceState );
3840 getWindow ().setFlags (WindowManager .LayoutParams .FLAG_FULLSCREEN ,
3941 WindowManager .LayoutParams .FLAG_FULLSCREEN );
40- setContentView (R .layout .activity_radarchart );
41-
42- mChart = (RadarChart ) findViewById (R .id .chart1 );
42+ setContentView (R .layout .activity_radarchart_noseekbar );
4343
4444 tf = Typeface .createFromAsset (getAssets (), "OpenSans-Regular.ttf" );
4545
46+ TextView tv = (TextView ) findViewById (R .id .textView );
47+ tv .setTypeface (tf );
48+ tv .setTextColor (Color .WHITE );
49+ tv .setBackgroundColor (Color .rgb (60 , 65 , 82 ));
50+
51+ mChart = (RadarChart ) findViewById (R .id .chart1 );
52+ mChart .setBackgroundColor (Color .rgb (60 , 65 , 82 ));
53+
4654 mChart .setDescription ("" );
4755
48- mChart .setWebLineWidth (1.5f );
49- mChart .setWebLineWidthInner (0.75f );
56+ mChart .setWebLineWidth (1f );
57+ mChart .setWebColor (Color .LTGRAY );
58+ mChart .setWebLineWidthInner (1f );
5059 mChart .setWebAlpha (100 );
5160
5261 // create a custom MarkerView (extend MarkerView) and specify the layout
@@ -66,29 +75,36 @@ protected void onCreate(Bundle savedInstanceState) {
6675 XAxis xAxis = mChart .getXAxis ();
6776 xAxis .setTypeface (tf );
6877 xAxis .setTextSize (9f );
78+ xAxis .setYOffset (0f );
79+ xAxis .setXOffset (0f );
6980 xAxis .setValueFormatter (new AxisValueFormatter () {
81+
82+ private String [] mActivities = new String []{"Burger" , "Steak" , "Salad" , "Pasta" , "Pizza" };
7083 @ Override
7184 public String getFormattedValue (float value , AxisBase axis ) {
72- return mMonths [(int ) value % mMonths .length ];
85+ return mActivities [(int ) value % mActivities .length ];
7386 }
7487
7588 @ Override
7689 public int getDecimalDigits () {
7790 return 0 ;
7891 }
7992 });
93+ xAxis .setTextColor (Color .WHITE );
8094
8195 YAxis yAxis = mChart .getYAxis ();
8296 yAxis .setTypeface (tf );
8397 yAxis .setLabelCount (5 , false );
8498 yAxis .setTextSize (9f );
8599 yAxis .setAxisMinValue (0f );
100+ yAxis .setDrawLabels (false );
86101
87102 Legend l = mChart .getLegend ();
88- l .setPosition (LegendPosition .RIGHT_OF_CHART );
103+ l .setPosition (LegendPosition .ABOVE_CHART_CENTER );
89104 l .setTypeface (tf );
90105 l .setXEntrySpace (7f );
91106 l .setYEntrySpace (5f );
107+ l .setTextColor (Color .WHITE );
92108 }
93109
94110 @ Override
@@ -190,15 +206,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
190206 return true ;
191207 }
192208
193- private String [] mParties = new String []{
194- "Party A" , "Party B" , "Party C" , "Party D" , "Party E" , "Party F" , "Party G" , "Party H" ,
195- "Party I"
196- };
197-
198209 public void setData () {
199210
200- float mult = 150 ;
201- int cnt = 9 ;
211+ float mult = 80 ;
212+ float min = 20 ;
213+ int cnt = 5 ;
202214
203215 ArrayList <Entry > yVals1 = new ArrayList <Entry >();
204216 ArrayList <Entry > yVals2 = new ArrayList <Entry >();
@@ -207,25 +219,27 @@ public void setData() {
207219 // xIndex (even if from different DataSets), since no values can be
208220 // drawn above each other.
209221 for (int i = 0 ; i < cnt ; i ++) {
210- float val = (float ) (Math .random () * mult ) + mult / 2 ;
222+ float val = (float ) (Math .random () * mult ) + min ;
211223 yVals1 .add (new Entry (i , val ));
212224 }
213225
214226 for (int i = 0 ; i < cnt ; i ++) {
215- float val = (float ) (Math .random () * mult ) + mult / 2 ;
227+ float val = (float ) (Math .random () * mult ) + min ;
216228 yVals2 .add (new Entry (i , val ));
217229 }
218230
219- RadarDataSet set1 = new RadarDataSet (yVals1 , "Set 1 " );
220- set1 .setColor (ColorTemplate . VORDIPLOM_COLORS [ 0 ] );
221- set1 .setFillColor (ColorTemplate . VORDIPLOM_COLORS [ 0 ] );
231+ RadarDataSet set1 = new RadarDataSet (yVals1 , "Last Week " );
232+ set1 .setColor (Color . rgb ( 103 , 110 , 129 ) );
233+ set1 .setFillColor (Color . rgb ( 103 , 110 , 129 ) );
222234 set1 .setDrawFilled (true );
235+ set1 .setFillAlpha (180 );
223236 set1 .setLineWidth (2f );
224237
225- RadarDataSet set2 = new RadarDataSet (yVals2 , "Set 2 " );
226- set2 .setColor (ColorTemplate . VORDIPLOM_COLORS [ 4 ] );
227- set2 .setFillColor (ColorTemplate . VORDIPLOM_COLORS [ 4 ] );
238+ RadarDataSet set2 = new RadarDataSet (yVals2 , "This Week " );
239+ set2 .setColor (Color . rgb ( 121 , 162 , 175 ) );
240+ set2 .setFillColor (Color . rgb ( 121 , 162 , 175 ) );
228241 set2 .setDrawFilled (true );
242+ set2 .setFillAlpha (180 );
229243 set2 .setLineWidth (2f );
230244
231245 ArrayList <IRadarDataSet > sets = new ArrayList <IRadarDataSet >();
@@ -236,6 +250,7 @@ public void setData() {
236250 data .setValueTypeface (tf );
237251 data .setValueTextSize (8f );
238252 data .setDrawValues (false );
253+ data .setValueTextColor (Color .WHITE );
239254
240255 mChart .setData (data );
241256 mChart .invalidate ();
0 commit comments