mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-11 19:24:06 +02:00
Graphics: reverse top chart and bottom chart. This way, from top to bottom, char are years->months->days instead of years->days->months
Signed-off-by: Jerome Flesch <jflesch@kwain.net>
This commit is contained in:
@@ -64,8 +64,8 @@ import lecho.lib.hellocharts.view.LineChartView;
|
|||||||
|
|
||||||
public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||||
private View graphView;
|
private View graphView;
|
||||||
private LineChartView chartTop;
|
private LineChartView chartBottom;
|
||||||
private ColumnChartView chartBottom;
|
private ColumnChartView chartTop;
|
||||||
private Viewport defaultTopViewport;
|
private Viewport defaultTopViewport;
|
||||||
private TextView txtYear;
|
private TextView txtYear;
|
||||||
private FloatingActionButton diagramWeight;
|
private FloatingActionButton diagramWeight;
|
||||||
@@ -94,12 +94,12 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
{
|
{
|
||||||
graphView = inflater.inflate(R.layout.fragment_graph, container, false);
|
graphView = inflater.inflate(R.layout.fragment_graph, container, false);
|
||||||
|
|
||||||
chartTop = (LineChartView) graphView.findViewById(R.id.chart_top);
|
chartBottom = (LineChartView) graphView.findViewById(R.id.chart_bottom);
|
||||||
chartBottom = (ColumnChartView) graphView.findViewById(R.id.chart_bottom);
|
chartTop = (ColumnChartView) graphView.findViewById(R.id.chart_top);
|
||||||
|
|
||||||
chartTop.setOnTouchListener(new ChartTopListener());
|
chartBottom.setOnTouchListener(new chartBottomListener());
|
||||||
chartTop.setOnValueTouchListener(new ChartTopValueTouchListener());
|
chartBottom.setOnValueTouchListener(new chartBottomValueTouchListener());
|
||||||
chartBottom.setOnValueTouchListener(new ChartBottomValueTouchListener());
|
chartTop.setOnValueTouchListener(new chartTopValueTouchListener());
|
||||||
|
|
||||||
txtYear = (TextView) graphView.findViewById(R.id.txtYear);
|
txtYear = (TextView) graphView.findViewById(R.id.txtYear);
|
||||||
txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR)));
|
txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR)));
|
||||||
@@ -319,11 +319,11 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
setTextColor(Color.BLACK)
|
setTextColor(Color.BLACK)
|
||||||
);
|
);
|
||||||
|
|
||||||
chartTop.setLineChartData(lineData);
|
chartBottom.setLineChartData(lineData);
|
||||||
defaultTopViewport = new Viewport(0, chartTop.getCurrentViewport().top+4, axisValues.size()-1, chartTop.getCurrentViewport().bottom-4);
|
defaultTopViewport = new Viewport(0, chartBottom.getCurrentViewport().top+4, axisValues.size()-1, chartBottom.getCurrentViewport().bottom-4);
|
||||||
|
|
||||||
chartTop.setMaximumViewport(defaultTopViewport);
|
chartBottom.setMaximumViewport(defaultTopViewport);
|
||||||
chartTop.setCurrentViewport(defaultTopViewport);
|
chartBottom.setCurrentViewport(defaultTopViewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateColumnData()
|
private void generateColumnData()
|
||||||
@@ -354,17 +354,17 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
|
|
||||||
columnData.setAxisXBottom(new Axis(axisValues).setHasLines(true).setTextColor(Color.BLACK));
|
columnData.setAxisXBottom(new Axis(axisValues).setHasLines(true).setTextColor(Color.BLACK));
|
||||||
|
|
||||||
chartBottom.setColumnChartData(columnData);
|
chartTop.setColumnChartData(columnData);
|
||||||
chartBottom.setValueSelectionEnabled(true);
|
chartTop.setValueSelectionEnabled(true);
|
||||||
chartBottom.setZoomEnabled(false);
|
chartTop.setZoomEnabled(false);
|
||||||
chartBottom.selectValue(new SelectedValue(calLastSelected.get(Calendar.MONTH), 0, SelectedValue.SelectedValueType.COLUMN));
|
chartTop.selectValue(new SelectedValue(calLastSelected.get(Calendar.MONTH), 0, SelectedValue.SelectedValueType.COLUMN));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateGraphs() {
|
private void generateGraphs() {
|
||||||
// show monthly diagram
|
// show monthly diagram
|
||||||
if (prefs.getBoolean(String.valueOf(enableMonth.getId()), true)) {
|
if (prefs.getBoolean(String.valueOf(enableMonth.getId()), true)) {
|
||||||
chartBottom.setVisibility(View.VISIBLE);
|
chartTop.setVisibility(View.VISIBLE);
|
||||||
chartTop.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 0.7f));
|
chartBottom.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 0.7f));
|
||||||
|
|
||||||
generateColumnData();
|
generateColumnData();
|
||||||
scaleDataList = openScale.getScaleDataOfMonth(calYears.get(Calendar.YEAR), calLastSelected.get(Calendar.MONTH));
|
scaleDataList = openScale.getScaleDataOfMonth(calYears.get(Calendar.YEAR), calLastSelected.get(Calendar.MONTH));
|
||||||
@@ -372,8 +372,8 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
generateLineData(Calendar.DAY_OF_MONTH);
|
generateLineData(Calendar.DAY_OF_MONTH);
|
||||||
// show only yearly diagram and hide monthly diagram
|
// show only yearly diagram and hide monthly diagram
|
||||||
} else {
|
} else {
|
||||||
chartBottom.setVisibility(View.GONE);
|
chartTop.setVisibility(View.GONE);
|
||||||
chartTop.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
chartBottom.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
scaleDataList = openScale.getScaleDataOfYear(calYears.get(Calendar.YEAR));
|
scaleDataList = openScale.getScaleDataOfYear(calYears.get(Calendar.YEAR));
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChartBottomValueTouchListener implements ColumnChartOnValueSelectListener {
|
private class chartTopValueTouchListener implements ColumnChartOnValueSelectListener {
|
||||||
@Override
|
@Override
|
||||||
public void onValueSelected(int selectedLine, int selectedValue, SubcolumnValue value) {
|
public void onValueSelected(int selectedLine, int selectedValue, SubcolumnValue value) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
@@ -400,10 +400,10 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChartTopListener implements View.OnTouchListener {
|
private class chartBottomListener implements View.OnTouchListener {
|
||||||
final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
|
final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
|
||||||
public void onLongPress(MotionEvent e) {
|
public void onLongPress(MotionEvent e) {
|
||||||
chartTop.setCurrentViewport(defaultTopViewport);
|
chartBottom.setCurrentViewport(defaultTopViewport);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChartTopValueTouchListener implements LineChartOnValueSelectListener {
|
private class chartBottomValueTouchListener implements LineChartOnValueSelectListener {
|
||||||
@Override
|
@Override
|
||||||
public void onValueSelected(int lineIndex, int pointIndex, PointValue pointValue) {
|
public void onValueSelected(int lineIndex, int pointIndex, PointValue pointValue) {
|
||||||
ScaleData scaleData = scaleDataList.get(pointIndex);
|
ScaleData scaleData = scaleDataList.get(pointIndex);
|
||||||
|
@@ -130,18 +130,18 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<lecho.lib.hellocharts.view.LineChartView
|
<lecho.lib.hellocharts.view.ColumnChartView
|
||||||
android:id="@+id/chart_top"
|
android:id="@+id/chart_top"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="0.7" />
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_weight="0.3" />
|
||||||
|
|
||||||
<lecho.lib.hellocharts.view.ColumnChartView
|
<lecho.lib.hellocharts.view.LineChartView
|
||||||
android:id="@+id/chart_bottom"
|
android:id="@+id/chart_bottom"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_weight="0.7" />
|
||||||
android:layout_weight="0.3" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -153,8 +153,8 @@
|
|||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:src="@drawable/lastmonth"
|
android:src="@drawable/lastmonth"
|
||||||
app:backgroundTint="#33B5E5"
|
app:backgroundTint="#33B5E5"
|
||||||
app:rippleColor="#33B5E5"
|
|
||||||
app:layout_anchor="@id/chart_top"
|
app:layout_anchor="@id/chart_top"
|
||||||
app:layout_anchorGravity="top|right|end" />
|
app:layout_anchorGravity="top|right|end"
|
||||||
|
app:rippleColor="#33B5E5" />
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
Reference in New Issue
Block a user