added plotting of graph data
This commit is contained in:
parent
55f4998f78
commit
f4533ee427
@ -39,7 +39,7 @@ dependencies {
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
||||
implementation 'com.android.volley:volley:1.1.1'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.github.lecho:hellocharts-library:1.5.8'
|
||||
implementation 'com.jjoe64:graphview:4.2.2'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
|
@ -12,20 +12,15 @@ import com.example.aped.MainActivity;
|
||||
import com.example.aped.R;
|
||||
import com.example.aped.communication.Communicator;
|
||||
import com.example.aped.utils.IXML;
|
||||
import com.example.aped.utils.XMLHandler;
|
||||
import com.jjoe64.graphview.GraphView;
|
||||
import com.jjoe64.graphview.series.DataPoint;
|
||||
import com.jjoe64.graphview.series.LineGraphSeries;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Dictionary;
|
||||
import java.util.List;
|
||||
import lecho.lib.hellocharts.model.AxisValue;
|
||||
import lecho.lib.hellocharts.model.Line;
|
||||
import lecho.lib.hellocharts.model.LineChartData;
|
||||
import lecho.lib.hellocharts.model.PointValue;
|
||||
import lecho.lib.hellocharts.view.LineChartView;
|
||||
|
||||
public class PlotFragment extends Fragment {
|
||||
|
||||
@ -34,7 +29,7 @@ public class PlotFragment extends Fragment {
|
||||
/** List of all the devices with buffers. **/
|
||||
private List<String> bufferedDevices;
|
||||
/** Line Chart View that is displayed **/
|
||||
private LineChartView lineChartView;
|
||||
private GraphView graphView;
|
||||
|
||||
/**
|
||||
* paul
|
||||
@ -52,7 +47,7 @@ public class PlotFragment extends Fragment {
|
||||
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_plot, container, false);
|
||||
this.lineChartView = view.findViewById(R.id.test_plot);
|
||||
this.graphView = view.findViewById(R.id.graph);
|
||||
|
||||
getBufferedValues(mainActivity.getDelivery(), mainActivity.getXml());
|
||||
mainActivity.getConfigurationHandler().setCurrentView(R.id.nav_plots);
|
||||
@ -84,16 +79,16 @@ public class PlotFragment extends Fragment {
|
||||
}
|
||||
|
||||
//display data
|
||||
List yAxisValues = new ArrayList();
|
||||
DataPoint[] dataPoints = new DataPoint[values.length];
|
||||
for (int i = 0; i < values.length; i++){
|
||||
yAxisValues.add(values[i]);
|
||||
dataPoints[i] = new DataPoint(i, values[i]);
|
||||
}
|
||||
Line line = new Line(yAxisValues);
|
||||
List lines = new ArrayList();
|
||||
lines.add(line);
|
||||
LineChartData lineChartData = new LineChartData();
|
||||
lineChartData.setLines(lines);
|
||||
this.lineChartView.setLineChartData(lineChartData);
|
||||
LineGraphSeries<DataPoint> lineGraphSeries = new LineGraphSeries<>(dataPoints);
|
||||
this.graphView.addSeries(lineGraphSeries);
|
||||
this.graphView.getViewport().setMaxX(600);
|
||||
this.graphView.getViewport().setMaxY(100);
|
||||
this.graphView.getViewport().setXAxisBoundsManual(true);
|
||||
this.graphView.getViewport().setYAxisBoundsManual(true);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e("PlotFragment", "error while parsing JSON on READ BUFFER: " + e.getMessage());
|
||||
|
@ -5,8 +5,8 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.plots.PlotFragment">
|
||||
|
||||
<lecho.lib.hellocharts.view.LineChartView
|
||||
android:id="@+id/test_plot"
|
||||
<com.jjoe64.graphview.GraphView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/graph"/>
|
||||
</FrameLayout>
|
Loading…
x
Reference in New Issue
Block a user