Skip to content

Commit 5a5348c

Browse files
author
yogeshbalan
committed
Graphs are working now VOILA!!
Signed-off-by: yogeshbalan <[email protected]>
1 parent 224cb0a commit 5a5348c

12 files changed

+137
-217
lines changed

.idea/libraries/appcompat_v7_23_0_0.xml

-15
This file was deleted.

.idea/libraries/bolts_android_1_2_1.xml

-11
This file was deleted.

.idea/libraries/cardview_v7_23_0_0.xml

-12
This file was deleted.

.idea/libraries/design_23_0_0.xml

-13
This file was deleted.

.idea/libraries/palette_v7_23_0_0.xml

-12
This file was deleted.

.idea/libraries/parse_android_1_10_1.xml

-11
This file was deleted.

.idea/libraries/recyclerview_v7_23_0_0.xml

-12
This file was deleted.

.idea/libraries/support_annotations_23_0_0.xml

-11
This file was deleted.

.idea/libraries/support_v4_23_0_0.xml

-16
This file was deleted.

app/src/main/java/xyz/airquality/Fragments/ComparisonDaily.java

+94-92
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class ComparisonDaily extends Fragment {
5151
private ImageButton mPlayTwo;
5252
private boolean mUpdateTwo;
5353
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}};
5555
private TextView mTextViewTwo;
5656

5757

@@ -60,7 +60,7 @@ public class ComparisonDaily extends Fragment {
6060
private ImageButton mPlayThree;
6161
private boolean mUpdateThree;
6262
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}};
6464

6565

6666

@@ -375,79 +375,62 @@ private void dismissTooltipOne(){
375375
*/
376376

377377
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;
389379

390-
horChart.setOnEntryClickListener(new OnEntryClickListener() {
380+
barChart.setOnEntryClickListener(new OnEntryClickListener() {
391381
@Override
392382
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);
401384
}
402385
});
403386

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);
412393

413-
}
414-
}
415-
});
394+
BarSet barSet = new BarSet(mLabelsTwo, mValuesTwo[0]);
395+
barSet.setColor(Color.parseColor("#a8896c"));
396+
barChart.addData(barSet);
416397

398+
barSet = new BarSet(mLabelsTwo, mValuesTwo[1]);
399+
barSet.setColor(Color.parseColor("#c33232"));
400+
barChart.addData(barSet);
417401

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));
432405

433406
Paint gridPaint = new Paint();
434-
gridPaint.setColor(Color.parseColor("#aab6b2ac"));
407+
gridPaint.setColor(Color.parseColor("#8986705C"));
435408
gridPaint.setStyle(Paint.Style.STROKE);
436409
gridPaint.setAntiAlias(true);
437410
gridPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
438411

439-
horChart.setBorderSpacing(0)
440-
.setAxisBorderValues(0, 100, 5)
412+
barChart.setBorderSpacing(5)
413+
.setAxisBorderValues(0, 10, 2)
441414
.setGrid(BarChartView.GridType.FULL, gridPaint)
442-
.setXAxis(false)
443415
.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"));
446420

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()
449431
.setOverlap(.5f, order)
450-
.setEndAction(action))
432+
.setEndAction(chartOneAction))
433+
//.show()
451434
;
452435
}
453436

@@ -462,24 +445,17 @@ public void updateTwo(ChartView chart){
462445

463446
}
464447

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]);
467451
chart.notifyDataUpdate();
468452
}
469453

470454
public void dismissTwo(ChartView chart, Runnable action){
471455

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-
480456
chart.dismissAllTooltips();
481457

482-
int[] order = {0, 1, 2, 3, 4};
458+
int[] order = {0, 4, 1, 3, 2};
483459
chart.dismiss(new Animation()
484460
.setOverlap(.5f, order)
485461
.setEndAction(action));
@@ -496,53 +472,79 @@ public void dismissTwo(ChartView chart, Runnable action){
496472
public void produceThree(ChartView chart, Runnable action){
497473
BarChartView barChart = (BarChartView) chart;
498474

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+
});
500481

482+
Tooltip tooltip = new Tooltip(getActivity(), R.layout.barchart_one_tooltip);
501483
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));
507486
}
487+
barChart.setTooltips(tooltip);
508488

509-
barChart.setTooltips(tip);
489+
BarSet barSet = new BarSet(mLabelsThree, mValuesThree[0]);
490+
barSet.setColor(Color.parseColor("#a8896c"));
491+
barChart.addData(barSet);
510492

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);
514496

515-
barChart.setBarSpacing(Tools.fromDpToPx(3));
497+
barChart.setSetSpacing(Tools.fromDpToPx(-15));
498+
barChart.setBarSpacing(Tools.fromDpToPx(35));
499+
barChart.setRoundCorners(Tools.fromDpToPx(2));
516500

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));
521506

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"));
525515

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+
;
527530
}
528531

529532
public void updateThree(ChartView chart){
530533

531534
chart.dismissAllTooltips();
532535

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]);
538539
chart.notifyDataUpdate();
539540
}
540541

541542
public void dismissThree(ChartView chart, Runnable action){
542543

543544
chart.dismissAllTooltips();
545+
int[] order = {0, 4, 1, 3, 2};
544546
chart.dismiss(new Animation()
545-
.setEasing(new ElasticEase())
547+
.setOverlap(.5f, order)
546548
.setEndAction(action));
547549
}
548550

0 commit comments

Comments
 (0)