Greetings ... I tell you that I've been doing an app which I want you to graph from a SQLite database, the library I'm using is MPAndroidChart. The way I want it to be drawn is according to the following image.
The labels on the X axis will also be obtained from the database which has the following format of type TEXT "01/27 / 18-20: 55". Someone who can help me with this problem please. I share the code with which I wanted to perform tests, even without SQLite data but unfortunately it is not working for me, since it closes the app. Culquier help is welcome, thanks in advance.
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_charts, container, false);
voltageChart = (LineChart) v.findViewById(R.id.voltageChart);
currentChart = (LineChart) v.findViewById(R.id.currentChart);
numMapVoltage = new HashMap<>();
numMapVoltage.put(1,"01/27/2018-20:30");
numMapVoltage.put(2,"01/27/2018-20:35");
numMapVoltage.put(3,"01/27/2018-20:40");
numMapVoltage.put(4,"01/27/2018-20:45");
numMapVoltage.put(5,"01/27/2018-20:50");
numMapVoltage.put(6,"01/27/2018-20:55");
entriesVoltage = new ArrayList<>();
for (int num:numArray){
entriesVoltage.add(new Entry(num,num));
}
LineDataSet voltageDataset = new LineDataSet(entriesVoltage,"Voltage Values");
voltageDataset.setColors( ColorTemplate.COLORFUL_COLORS);
LineData voltageData = new LineData(voltageDataset);
XAxis voltageXAxis = voltageChart.getXAxis();
voltageXAxis.setValueFormatter( new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return numMapVotage.get((int) value);
}
} );
voltageChart.setData(voltageData);
return v;
}