@@ -51,7 +51,7 @@ public class ComparisonDaily extends Fragment {
51
51
private ImageButton mPlayTwo ;
52
52
private boolean mUpdateTwo ;
53
53
private final String [] mLabelsTwo = {"1 h" , "2 h" , "3 h" , "4 h" , "5 h" };
54
- private final float [] mValuesTwo = {23f , 34f , 55f , 71f , 98f };
54
+ private final float [][] mValuesTwo = {{ 9.5f , 7.5f , 5.5f , 4.5f , 10f }, { 6.5f , 3.5f , 3.5f , 2.5f , 7.5f } };
55
55
private TextView mTextViewTwo ;
56
56
57
57
@@ -60,7 +60,7 @@ public class ComparisonDaily extends Fragment {
60
60
private ImageButton mPlayThree ;
61
61
private boolean mUpdateThree ;
62
62
private final String [] mLabelsThree = {"1 h" , "2 h" , "3 h" , "4 h" , "5 h" };
63
- private final float [] mValuesThree = {2 .5f , 3.7f , 4f , 8f , 4 .5f };
63
+ private final float [][] mValuesThree = {{ 9 .5f , 7.5f , 5.5f , 4.5f , 10f }, { 6.5f , 3.5f , 3.5f , 2.5f , 7 .5f} };
64
64
65
65
66
66
@@ -375,79 +375,62 @@ private void dismissTooltipOne(){
375
375
*/
376
376
377
377
public void produceTwo (ChartView chart , Runnable action ){
378
- BarChartView horChart = (BarChartView ) chart ;
379
-
380
- Tooltip tip = new Tooltip (getActivity (), R .layout .barchart_one_tooltip );
381
-
382
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .ICE_CREAM_SANDWICH ) {
383
- tip .setEnterAnimation (PropertyValuesHolder .ofFloat (View .ALPHA , 1 ));
384
- tip .setExitAnimation (PropertyValuesHolder .ofFloat (View .ALPHA ,0 ));
385
- }
386
-
387
- horChart .setTooltips (tip );
388
-
378
+ BarChartView barChart = (BarChartView ) chart ;
389
379
390
- horChart .setOnEntryClickListener (new OnEntryClickListener () {
380
+ barChart .setOnEntryClickListener (new OnEntryClickListener () {
391
381
@ Override
392
382
public void onClick (int setIndex , int entryIndex , Rect rect ) {
393
- mTextViewTwo .setText (Integer .toString ((int ) mValuesTwo [entryIndex ]));
394
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .HONEYCOMB_MR1 ) {
395
- mTextViewTwo .animate ().alpha (1 ).setDuration (200 );
396
-
397
- }else {
398
- mTextViewTwo .setVisibility (View .VISIBLE );
399
-
400
- }
383
+ System .out .println ("OnClick " +rect .left );
401
384
}
402
385
});
403
386
404
- horChart .setOnClickListener (new View .OnClickListener () {
405
- @ Override
406
- public void onClick (View v ) {
407
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .HONEYCOMB_MR1 ) {
408
- mTextViewTwo .animate ().alpha (0 ).setDuration (100 );
409
-
410
- }else {
411
- mTextViewTwo .setVisibility (View .INVISIBLE );
387
+ Tooltip tooltip = new Tooltip (getActivity (), R .layout .barchart_one_tooltip );
388
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .ICE_CREAM_SANDWICH ) {
389
+ tooltip .setEnterAnimation (PropertyValuesHolder .ofFloat (View .ALPHA , 1 ));
390
+ tooltip .setExitAnimation (PropertyValuesHolder .ofFloat (View .ALPHA , 0 ));
391
+ }
392
+ barChart .setTooltips (tooltip );
412
393
413
- }
414
- }
415
- } );
394
+ BarSet barSet = new BarSet ( mLabelsTwo , mValuesTwo [ 0 ]);
395
+ barSet . setColor ( Color . parseColor ( "#a8896c" ));
396
+ barChart . addData ( barSet );
416
397
398
+ barSet = new BarSet (mLabelsTwo , mValuesTwo [1 ]);
399
+ barSet .setColor (Color .parseColor ("#c33232" ));
400
+ barChart .addData (barSet );
417
401
418
- BarSet barSet = new BarSet ();
419
- Bar bar ;
420
- for (int i = 0 ; i < mLabelsTwo .length ; i ++){
421
- bar = new Bar (mLabelsTwo [i ], mValuesTwo [i ]);
422
- if (i == mLabelsTwo .length - 1 )
423
- bar .setColor (Color .parseColor ("#b26657" ));
424
- else if (i == 0 )
425
- bar .setColor (Color .parseColor ("#998d6e" ));
426
- else
427
- bar .setColor (Color .parseColor ("#506a6e" ));
428
- barSet .addBar (bar );
429
- }
430
- horChart .addData (barSet );
431
- horChart .setBarSpacing (Tools .fromDpToPx (5 ));
402
+ barChart .setSetSpacing (Tools .fromDpToPx (-15 ));
403
+ barChart .setBarSpacing (Tools .fromDpToPx (35 ));
404
+ barChart .setRoundCorners (Tools .fromDpToPx (2 ));
432
405
433
406
Paint gridPaint = new Paint ();
434
- gridPaint .setColor (Color .parseColor ("#aab6b2ac " ));
407
+ gridPaint .setColor (Color .parseColor ("#8986705C " ));
435
408
gridPaint .setStyle (Paint .Style .STROKE );
436
409
gridPaint .setAntiAlias (true );
437
410
gridPaint .setStrokeWidth (Tools .fromDpToPx (.75f ));
438
411
439
- horChart .setBorderSpacing (0 )
440
- .setAxisBorderValues (0 , 100 , 5 )
412
+ barChart .setBorderSpacing (5 )
413
+ .setAxisBorderValues (0 , 10 , 2 )
441
414
.setGrid (BarChartView .GridType .FULL , gridPaint )
442
- .setXAxis (false )
443
415
.setYAxis (false )
444
- .setLabelsColor (Color .parseColor ("#FF8E8A84" ))
445
- .setXLabels (XController .LabelPosition .NONE );
416
+ .setXLabels (XController .LabelPosition .OUTSIDE )
417
+ .setYLabels (YController .LabelPosition .NONE )
418
+ .setLabelsColor (Color .parseColor ("#86705c" ))
419
+ .setAxisColor (Color .parseColor ("#86705c" ));
446
420
447
- int [] order = {4 , 3 , 2 , 1 , 0 };
448
- horChart .show (new Animation ()
421
+ int [] order = {2 , 1 , 3 , 0 , 4 };
422
+ final Runnable auxAction = action ;
423
+ Runnable chartOneAction = new Runnable () {
424
+ @ Override
425
+ public void run () {
426
+ showTooltipOne ();
427
+ auxAction .run ();
428
+ }
429
+ };
430
+ barChart .show (new Animation ()
449
431
.setOverlap (.5f , order )
450
- .setEndAction (action ))
432
+ .setEndAction (chartOneAction ))
433
+ //.show()
451
434
;
452
435
}
453
436
@@ -462,24 +445,17 @@ public void updateTwo(ChartView chart){
462
445
463
446
}
464
447
465
- float [] valuesTwoOne = {17f , 26f , 48f , 63f , 94f };
466
- chart .updateValues (0 , valuesTwoOne );
448
+ float [][]newValues = {{8.5f , 6.5f , 4.5f , 3.5f , 9f }, {5.5f , 3.0f , 3.0f , 2.5f , 7.5f }};
449
+ chart .updateValues (0 , newValues [0 ]);
450
+ chart .updateValues (1 , newValues [1 ]);
467
451
chart .notifyDataUpdate ();
468
452
}
469
453
470
454
public void dismissTwo (ChartView chart , Runnable action ){
471
455
472
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .HONEYCOMB_MR1 ) {
473
- mTextViewTwo .animate ().alpha (0 ).setDuration (100 );
474
-
475
- }else {
476
- mTextViewTwo .setVisibility (View .INVISIBLE );
477
-
478
- }
479
-
480
456
chart .dismissAllTooltips ();
481
457
482
- int [] order = {0 , 1 , 2 , 3 , 4 };
458
+ int [] order = {0 , 4 , 1 , 3 , 2 };
483
459
chart .dismiss (new Animation ()
484
460
.setOverlap (.5f , order )
485
461
.setEndAction (action ));
@@ -496,53 +472,79 @@ public void dismissTwo(ChartView chart, Runnable action){
496
472
public void produceThree (ChartView chart , Runnable action ){
497
473
BarChartView barChart = (BarChartView ) chart ;
498
474
499
- Tooltip tip = new Tooltip (getActivity (), R .layout .barchart_one_tooltip );
475
+ barChart .setOnEntryClickListener (new OnEntryClickListener () {
476
+ @ Override
477
+ public void onClick (int setIndex , int entryIndex , Rect rect ) {
478
+ System .out .println ("OnClick " +rect .left );
479
+ }
480
+ });
500
481
482
+ Tooltip tooltip = new Tooltip (getActivity (), R .layout .barchart_one_tooltip );
501
483
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .ICE_CREAM_SANDWICH ) {
502
- PropertyValuesHolder alpha = PropertyValuesHolder .ofFloat (View .ALPHA , 1 );
503
- tip .setEnterAnimation (alpha );
504
-
505
- alpha = PropertyValuesHolder .ofFloat (View .ALPHA ,0 );
506
- tip .setExitAnimation (alpha );
484
+ tooltip .setEnterAnimation (PropertyValuesHolder .ofFloat (View .ALPHA , 1 ));
485
+ tooltip .setExitAnimation (PropertyValuesHolder .ofFloat (View .ALPHA , 0 ));
507
486
}
487
+ barChart .setTooltips (tooltip );
508
488
509
- barChart .setTooltips (tip );
489
+ BarSet barSet = new BarSet (mLabelsThree , mValuesThree [0 ]);
490
+ barSet .setColor (Color .parseColor ("#a8896c" ));
491
+ barChart .addData (barSet );
510
492
511
- BarSet dataset = new BarSet (mLabelsThree , mValuesThree );
512
- dataset .setColor (Color .parseColor ("#eb993b " ));
513
- barChart .addData (dataset );
493
+ barSet = new BarSet (mLabelsThree , mValuesThree [ 1 ] );
494
+ barSet .setColor (Color .parseColor ("#c33232 " ));
495
+ barChart .addData (barSet );
514
496
515
- barChart .setBarSpacing (Tools .fromDpToPx (3 ));
497
+ barChart .setSetSpacing (Tools .fromDpToPx (-15 ));
498
+ barChart .setBarSpacing (Tools .fromDpToPx (35 ));
499
+ barChart .setRoundCorners (Tools .fromDpToPx (2 ));
516
500
517
- barChart .setXLabels (AxisController .LabelPosition .NONE )
518
- .setYLabels (AxisController .LabelPosition .NONE )
519
- .setXAxis (false )
520
- .setYAxis (false );
501
+ Paint gridPaint = new Paint ();
502
+ gridPaint .setColor (Color .parseColor ("#8986705C" ));
503
+ gridPaint .setStyle (Paint .Style .STROKE );
504
+ gridPaint .setAntiAlias (true );
505
+ gridPaint .setStrokeWidth (Tools .fromDpToPx (.75f ));
521
506
522
- Animation anim = new Animation ()
523
- .setEasing (new ElasticEase ())
524
- .setEndAction (action );
507
+ barChart .setBorderSpacing (5 )
508
+ .setAxisBorderValues (0 , 10 , 2 )
509
+ .setGrid (BarChartView .GridType .FULL , gridPaint )
510
+ .setYAxis (false )
511
+ .setXLabels (XController .LabelPosition .OUTSIDE )
512
+ .setYLabels (YController .LabelPosition .NONE )
513
+ .setLabelsColor (Color .parseColor ("#86705c" ))
514
+ .setAxisColor (Color .parseColor ("#86705c" ));
525
515
526
- chart .show (anim );
516
+ int [] order = {2 , 1 , 3 , 0 , 4 };
517
+ final Runnable auxAction = action ;
518
+ Runnable chartOneAction = new Runnable () {
519
+ @ Override
520
+ public void run () {
521
+ showTooltipOne ();
522
+ auxAction .run ();
523
+ }
524
+ };
525
+ barChart .show (new Animation ()
526
+ .setOverlap (.5f , order )
527
+ .setEndAction (chartOneAction ))
528
+ //.show()
529
+ ;
527
530
}
528
531
529
532
public void updateThree (ChartView chart ){
530
533
531
534
chart .dismissAllTooltips ();
532
535
533
- float [] values = {3.5f , 4.7f , 5f , 9f , 5.5f , 5f , 6f , 8f , 11f , 13f ,
534
- 11f , 7f , 6f , 7f , 10f , 11f , 12f , 9f , 8f , 7f ,
535
- 6f , 5f , 4f , 3f , 6f , 7f , 8f , 9f , 10f , 12f ,
536
- 13f , 11 , 13f , 10f ,8f , 7f , 5f , 4f , 3f , 7f };
537
- chart .updateValues (0 , values );
536
+ float [][]newValues = {{8.5f , 6.5f , 4.5f , 3.5f , 9f }, {5.5f , 3.0f , 3.0f , 2.5f , 7.5f }};
537
+ chart .updateValues (0 , newValues [0 ]);
538
+ chart .updateValues (1 , newValues [1 ]);
538
539
chart .notifyDataUpdate ();
539
540
}
540
541
541
542
public void dismissThree (ChartView chart , Runnable action ){
542
543
543
544
chart .dismissAllTooltips ();
545
+ int [] order = {0 , 4 , 1 , 3 , 2 };
544
546
chart .dismiss (new Animation ()
545
- .setEasing ( new ElasticEase () )
547
+ .setOverlap ( .5f , order )
546
548
.setEndAction (action ));
547
549
}
548
550
0 commit comments