use of ru.sash0k.thriftbox.charting.MyMarkerView in project Thrift-box by Sash0k.
the class ChartsFragment method onCreateView.
// ============================================================================
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.charts_fragment, container, false);
TextView month = (TextView) v.findViewById(R.id.current_month);
long ts = getArguments().getLong(DB.TIMESTAMP);
month.setText(SDF_MONTH.format(new Date(ts * 1000)));
// отображение статистики за текущий месяц
BarChart barChart = (BarChart) v.findViewById(R.id.bar_chart);
barChart.setDescription("");
Paint mInfoPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mInfoPaint.setColor(getResources().getColor(R.color.primary));
mInfoPaint.setTextAlign(Paint.Align.CENTER);
mInfoPaint.setTextSize(com.github.mikephil.charting.utils.Utils.convertDpToPixel(16f));
barChart.setPaint(mInfoPaint, Chart.PAINT_INFO);
barChart.setNoDataText(getString(R.string.charts_no_data));
barChart.setDrawBarShadow(false);
barChart.setDrawGridBackground(false);
barChart.setDrawValueAboveBar(false);
barChart.setPinchZoom(false);
barChart.setScaleEnabled(false);
barChart.setDoubleTapToZoomEnabled(false);
barChart.getXAxis().disableGridDashedLine();
barChart.getXAxis().setDrawGridLines(false);
barChart.getXAxis().setEnabled(false);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getAxisLeft().setEnabled(false);
barChart.getAxisRight().setDrawGridLines(false);
barChart.getAxisRight().removeAllLimitLines();
barChart.getAxisRight().setValueFormatter(new FinanceFormatter());
barChart.getLegend().setEnabled(false);
barChart.setData(generateMonthlyData());
// если данных нет, не показывать ось
barChart.getAxisRight().setEnabled(!barChart.isEmpty());
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mv.setX(mv.getMeasuredWidth());
barChart.setMarkerView(mv);
Utils.log("getYMin = " + barChart.getBarData().getYMin());
Utils.log("getYMax = " + barChart.getBarData().getYMax());
barChart.animateY(ANIMATION_TIME);
return v;
}
Aggregations