private static final SimpleDateFormat DISP_SDF_DAY_OF_WEEK = new SimpleDateFormat("E", Locale.getDefault());
private static final SimpleDateFormat INFLUXDB_UTC_SDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
...
XAxis xAxis = this.chart.getXAxis();
xAxis.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
//
// Problem
//
return DISP_SDF_DAY_OF_WEEK.format(Float.valueOf(value).longValue() * 1000L);
}
});
...
BarDataSet barDataSet;
YAxis barYAxis = this.chart.getAxis(YAxis.AxisDependency.LEFT);
barYAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
barYAxis.setDrawGridLines(false);
barYAxis.setTextColor(android.R.color.black);
barYAxis.setSpaceTop(15f);
barYAxis.setAxisMinimum(0f);
List<BarEntry> barEntryList = new ArrayList<>();
BarEntry barEntry;
ArrayList<Object> list;
long time;
Object temp;
float mean;
try {
for (int ll = 0; ll < values.length; ll++) {
list = (ArrayList<Object>) values[ll];
//
// Problem
//
time = INFLUXDB_UTC_SDF.parse((String) list.get(0)).getTime() / 1000L; // eg. 2019-08-07T00:00:00Z
temp = list.get(1);
if (temp instanceof java.lang.Double) {
mean = ((Double) temp).floatValue();
} else if (temp instanceof java.lang.Integer) {
mean = ((Integer) temp).floatValue();
} else {
mean = (float) temp;
}
barEntry = new BarEntry(time, (int) list.get(2));
barEntryList.add(barEntry);
}
} catch (java.text.ParseException e) {
Log.e("dorbae", e.getMessage(), e);
}
barDataSet = new BarDataSet(barEntryList, "Accumulation");
barDataSet.setColor(getResources().getColor(R.color.colorPrimary));
barDataSet.setValueTextColor(getResources().getColor(R.color.colorPrimary));
barDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
barDataSet.setVisible(true);
barDataSet.setDrawIcons(false);
BarData barData = new BarData(barDataSet);
//
// It didn't work well because of other reason
//
barData.setBarWidth(30f);
Legend l = this.chart.getLegend();
l.setDrawInside(true);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setTextColor(Color.BLACK);
CombinedData combinedData = new CombinedData();
combinedData.setData(barData);
combinedData.setData(lineData);
this.chart.setData(combinedData);
this.chart.getAxisLeft().setEnabled(true);
this.chart.setVisibility(View.VISIBLE);
this.chart.invalidate();
this.chart.notifyDataSetChanged();
...
댓글남기기