Android: Take data from CSV file and plot line chart
Hello, I'm using Line chart for my Android application, where I've to take data from CSV file and plot it. Also, when CSV file is updated by adding more data the chart should take automatically updated data as well and plot it. but the chart is taking only last values from CSV file and plotting or I think it is overwriting on same data set.
Please help me out.
@vigneshtg Please, provide the following details about the issue:
- Do you need to create multiple series on the same Line chart?
- Does the data set includes multiple values for the same X coordinate in a series?
If you can provide the data set and the chart configuration code we can review it and provide a solution.
@Shestac92 Yes, I need to have all the data on CSV file to plot it in line chart. In my case, CSV file looks like as follows: 2020/11/11, 01:07AM, 92.6 2020/11/15, 02:51PM, 96.9 2020/11/15, 02:52PM, 93.6
Also, when more data is added to CSV file, these data should be added automatically to series and plot to same Line chart in addition to current data's plotted. But when I plot it, by taking above 3 data for instance, there's only one data plotted which is last data (2020/11/15, 02:52PM, 93.6) on the CSV file which is depicted in below image:
Figure 1

Here's my code:
public class ChartActivity extends BaseAppCompatActivity { private Toolbar toolbar; private File logFile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chart);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
}
public void onResume() {
super.onResume();
logFile = (File) getIntent().getExtras().get(Constants.EXTRA_LOG_FILE);
if (logFile != null) {
toolbar.setTitle(logFile.getName() + getString(R.string.charting));
try {
setLogText(logFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
private void setLogText(File file) throws FileNotFoundException {
AnyChartView anyChartView = findViewById(R.id.any_chart_view);
Scanner inputStream;
inputStream = new Scanner(file);
while(inputStream.hasNext()){
String line= inputStream.next();
if (line.equals("")) { continue; } // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W= values[1]; // Time (12 hours format)
String X= values[2]; // Temperature
float T = Parsefloat(X); // converts string temperature to float value
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(true);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.title("META");
cartesian.xAxis(0).title("Time");
cartesian.yAxis(0).title("Temperature");
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
List<DataEntry> seriesData = new ArrayList<>();
seriesData.add(new CustomDataEntry(V+W, T));
Set set = Set.instantiate();
set.data(seriesData);
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Temp Data");
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
anyChartView.setChart(cartesian);
}
inputStream.close();
}
private class CustomDataEntry extends ValueDataEntry {
CustomDataEntry(String x, Number value) {
super(x, value);
}
}
public float Parsefloat(String strNumber) {
if (strNumber != null && strNumber.length() > 0) {
try {
return Float.parseFloat(strNumber);
} catch(Exception e) {
return -1; // or some value to mark this field is wrong. or make a function validates field first ...
}
}
else return 0;
}
}
My chart should be like this, where I've used our Line chart example by adding about 10 series of data (time versus temperature) and plotted which is depicted in below image:
Figure 2

But I need a single series where all the data will be appended one by one and add to single series and plot it. This is because in above case (Figure 2), I randomly added 10 series like
seriesData.add(new CustomDataEntry("10:26AM", 97.3));
seriesData.add(new CustomDataEntry("11:15AM", 98.5));
seriesData.add(new CustomDataEntry("12:05PM", 97.7));
seriesData.add(new CustomDataEntry("12:23PM", 99.6));
seriesData.add(new CustomDataEntry("12:56PM", 100.2));
seriesData.add(new CustomDataEntry("01:15PM", 101.6));
But in Realtime, we don't know how many data will be in CSV file and it's not possible to add series like above, hence single series is needed like I have it on my code and whenever data is loaded on CSV file, the series should be updated and plot to single Line chart.
@vigneshtg
In the while(inputStream.hasNext()){} loop you recreate the chart on every cycle and apply a single point. You should create the chart and the data set once, but add points in the while loop only.
Like this:
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(true);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.title("META");
cartesian.xAxis(0).title("Time");
cartesian.yAxis(0).title("Temperature");
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Temp Data");
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
inputStream = new Scanner(file);
while(inputStream.hasNext()){
String line= inputStream.next();
if (line.equals("")) { continue; } // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W= values[1]; // Time (12 hours format)
String X= values[2]; // Temperature
float T = Parsefloat(X); // converts string temperature to float value
seriesData.add(new CustomDataEntry(V+W, T));
}
inputStream.close();
set.data(seriesData);
anyChartView.setChart(cartesian);
@vigneshtg
The problem is that in the while(inputStream.hasNext()){} loop in every cycle you recreate the chart and apply a single point. It overrides the whole chart.
You should create and adjust the chart once outside the loop. And then only collect and apply the data in the loop/ Like this:
AnyChartView anyChartView = findViewById(R.id.any_chart_view);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(true);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.title("META");
cartesian.xAxis(0).title("Time");
cartesian.yAxis(0).title("Temperature");
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Temp Data");
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while(inputStream.hasNext()){
String line= inputStream.next();
if (line.equals("")) { continue; } // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W= values[1]; // Time (12 hours format)
String X= values[2]; // Temperature
float T = Parsefloat(X); // converts string temperature to float value
List<DataEntry> seriesData = new ArrayList<>();
seriesData.add(new CustomDataEntry(V+W, T));
}
inputStream.close();
anyChartView.setChart(cartesian);
set.data(seriesData);
@Shestac92 Thank you for help. I'll check it and let you know. In between, in the above code, SeriesData is defined inside while loop, but it can't be declared globally outside the loop as you've provided:
While {
List<DataEntry> seriesData = new ArrayList<>(); seriesData.add(new CustomDataEntry(V+W, T)); }
inputStream.close(); anyChartView.setChart(cartesian); set.data(seriesData);
@Shestac92 I've checked and it is working fine. Thanks!! Further, I need some modifications on the line chart.
- On the figure below, Is it possible to have Date on first line and time on second line with center Text Alignment in X-Axis, So that I'll get more space.

- Right now, I've setup minimum of 91.0 and maximum of 109.5 on Y-Axis, but I need a Y-Axis scale with equal units, Say in steps of 2 intervals.
- On my data below: 2020/11/18,09:32PM,98.0 2020/11/18,09:34PM,94.5 2020/11/18,09:37PM,94.6 2020/11/18,09:42PM,98.1 2020/11/18,09:42PM,92.4 2020/11/18,09:46PM,98.0 2020/11/18,09:54PM,97.7 2020/11/18,09:55PM,97.1 2020/11/18,10:01PM,92.5 2020/11/18,10:06PM,96.7 2020/11/18,10:08PM,96.5 2020/11/19,12:03AM,92.4 2020/11/19,12:20AM,96.8
If you see bolded data, X-Axis is same with 2 different data on Y-Axis. But currently in my case, it is taking latest data (92.4) and skipping previous data (98.1), which is depicted on above figure also. But I need to have both the data on line chart (Like multiple values for the same X coordinate).
Here's my code after modifications:
public class ChartActivity extends BaseAppCompatActivity {
private Toolbar toolbar;
private File logFile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chart);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
logFile = (File) getIntent().getExtras().get(Constants.EXTRA_LOG_FILE);
if (logFile != null) {
try {
setLogText(logFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
public void onResume() {
super.onResume();
logFile = (File) getIntent().getExtras().get(Constants.EXTRA_LOG_FILE);
if (logFile != null) {
toolbar.setTitle(logFile.getName() + getString(R.string.charting));
}
}
private class CustomDataEntry extends ValueDataEntry {
CustomDataEntry(String x, Number value) {
super(x, value);
}
}
public float Parsefloat(String strNumber) {
if (strNumber != null && strNumber.length() > 0) {
try {
return Float.parseFloat(strNumber);
} catch(Exception e) {
return -1; // or some value to mark this field is wrong. or make a function validates field first ...
}
}
else return 0;
}
private void setLogText(File file) throws FileNotFoundException {
AnyChartView anyChartView = findViewById(R.id.any_chart_view);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.title("META");
cartesian.xAxis(0).title("Time");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("Temperature");
cartesian.yScale().maximum(109.5).minimum(91.0);
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Temp Data");
series1.markers(true);
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while(inputStream.hasNext()){
String line= inputStream.next();
if (line.equals("")) { continue; } // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W= values[1]; // Time (12 hours format)
String X= values[2]; // Temperature
float T = Parsefloat(X); // converts string temperature to float value
seriesData.add(new CustomDataEntry(V + " " + W, T));
}
inputStream.close();
set.data(seriesData);
anyChartView.setChart(cartesian);
}
}
Thank you!!
@vigneshtg
A1 - Yes, to achieve that you can add \n instead of a space. Like this:
seriesData.add(new CustomDataEntry(V + "\n" + W, T));
A2 - You can apply the ticks interval equal to 5, for example. Like below:
cartesian.yScale().ticks().interval(5);
A3 - Unfortunately, it's not possible. All Cartesian charts support only a single point in every category.
@Shestac92 Thank you for your reply. Initially, I've tried by adding \n for newline before you've suggested like seriesData.add(new CustomDataEntry(V + "\n" + W, T));
But the Line Chart is blank. May I know the reason?
Thank you.
@vigneshtg I'm sorry for the typo, it requires a double backslash. Like this:
seriesData.add(new CustomDataEntry(V + "\\n" + W, T));
@Shestac92 Thank you for help!!
@Shestac92
For Zoom, I've used anyChartView.setZoomEnabled(true);
Further, how do i set X and Y-Axis scroller to view multiple data?
Thank you
@vigneshtg
chart.xScroller(true);
chart.yScroller(true);
@Shestac92 I've already setup this 2 lines: chart.xScroller(true); chart.yScroller(true);
But the scroller is not moving.
@Shestac92 I need a scroller to setup in Android with above chart like this in the below link:
https://playground.anychart.com/docs/v8/samples/CS_Scroller_05
In the above link, Initially, some X-Axis (like 02:00, 04:00 etc.) are not visible, but when we scroll it, the X-Axis is getting formatted and in between X-Axis becomes visible.
How it should be setup for my above chart like this Scrolling?
Thank you.
@vigneshtg The sample you provided, implements the xScroller with a single line I already mentioned:
chart.xScroller(true);
It will create the scroller for your chart.
But the scroller is not moving.
Can you provide more details? Can you provide a screencast?
@Shestac92
Yes, I've mentioned
chart.xScroller(true);
for X-Scroller on my code, but it's difficult to move it and also sometimes, it is moving and manytimes not moving when I tried to Scroll it.
Here's my code: `private void setLogText(File file) throws FileNotFoundException {
AnyChartView anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setZoomEnabled(true);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.xScroller(true);
cartesian.xAxis(0).title("Time");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("Temperature");
cartesian.yScale().maximum(110.0).minimum(90.0);
cartesian.yScale().ticks().interval(5);
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.markers(true);
series1.name("Temp");
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
Scanner inputStream;
inputStream = new Scanner(file);
while(inputStream.hasNext()){
String line= inputStream.next();
if (line.equals("")) { continue; } // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W= values[1]; // Time (12 hours format)
String X= values[2]; // Temperature
float T = Parsefloat(X); // converts string temperature to float value
seriesData.add(new CustomDataEntry(V + "\\n" + W, T));
}
inputStream.close();
set.data(seriesData);
anyChartView.setChart(cartesian);
}`

Is it possible when I zoom horizontally, X-Axis should scroll and show in between X-Axis? Like the operation of Scroller should be implemented when I Zoom horizontally.
@vigneshtg Unfortunately, this is the only possible xScroller implementation in the current version of the library.
@Shestac92 Thank you for reply. As in my code above, I'm taking both temperature data and Date/Time directly from CSV file. Is it possible to take temperature data alone from CSV file and plot it with Date/Time defined within Line chart with X-axis formatter for Date and time like Realtime Line chart?
@vigneshtg I'm not sure I understood you well. The point value should be bound to a particular x coordinate. So you should provide both X and Value in the dataset.
@Shestac92 Yes, I know, we need to provide both X and Y values in dataset. I mean if I've temperature data only and don't have date/time, how can I plot this data versus Date and time? Like in my above code, whenever, new temperature data from CSV file is added to series, it should add Date/Time simultaneously to series, (for instance, when new temperature data is added to series, at What Date/Time, temperature data has been added to series should be added to series). Hence finally we've temperature data as Y-Axis and Date and time as X-axis to be plotted.
@vigneshtg In this case, you should the X coordinate manually in the code, the chart doesn't provide a possibility to populate it itself.
@Shestac92 Thank you for reply. Further, if you see this data as below:
2020/11/18,09:34PM,94.5 2020/11/18,09:37PM,94.6 2020/11/18,09:42PM,98.1 2020/11/18,09:42PM,92.4
Here in above data, last 2 rows of data are having same Date/Time, if I plot it why it is showing last row data only (2020/11/18,09:42PM,92.4) and not showing previous data (2020/11/18,09:42PM,98.1) on the chart? Is it overwriting on the chart?
Yes, the Cartesian chart supports only a unique point for every category in a series. So, the second point with the same x-coordinate overrides the first one.
@Shestac92 Thank you. Is there a way to plot both the points on line chart?
@vigneshtg Unfortunately, it's not possible with the current version of the library.
@Shestac92 Thank you for reply.
Hello Everyone,
By seeing to the reference above I also have made the Line chart using the Any chart . Same problem have rose again that the plot of the data is not running continuously. As the CSV file is being created and the values are continuously adding in the CSV file but while plotting the data only till the last row of the file comes and then gets stuck. HELP Below is my code.
import static androidx.constraintlayout.helper.widget.MotionEffect.TAG;
import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.widget.Toast; import android.widget.Toolbar;
import androidx.appcompat.app.AppCompatActivity;
import com.anychart.AnyChart; import com.anychart.AnyChartView; import com.anychart.chart.common.dataentry.DataEntry; import com.anychart.chart.common.dataentry.ValueDataEntry; import com.anychart.charts.Cartesian; import com.anychart.core.cartesian.series.Line; import com.anychart.core.ui.ChartCredits; import com.anychart.data.Mapping; import com.anychart.data.Set; import com.anychart.enums.Anchor; import com.anychart.enums.MarkerType; import com.anychart.enums.TooltipPositionMode; import com.anychart.graphics.vector.Stroke; import com.google.android.gms.common.internal.Constants; import com.opencsv.CSVReader;
import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner;
public class GraphPlotingXAxis extends AppCompatActivity {
private Handler handler = new Handler();
public static final String EXTRAS_DEVICE_NAMEEEE = "DEVICE_NAMEEEE";
public static final String EXTRAS_DEVICE_ASSETTT = "PLANT_ASSETTT";
public static final String EXTRAS_DEVICE_EQUIPMENTTAGGG = "PLANT_EQUIPMENT_TAGGG";
public static final String EXTRAS_DEVICE_MACHINECLASSSS = "PLANT_MACHINE_CLASSSS";
public static final String EXTRAS_DEVICE_MOUNTINGLOCATIONNN = "PLANT_MOUNTING_LOCATIONNN";
public static final String EXTRAS_DEVICE_MEASUREMENT = "MEASUREMENT";
static String mAssett, mEqiupmenttagg, mMachineclass, mMountinglocationn;
static String mDeviceAdresss;
static String measAxis;
AnyChartView anyChartView;
static String meas;
private File logFile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_graph_ploting);
final Intent intent = getIntent();
measAxis = intent.getStringExtra(EXTRAS_DEVICE_MEASUREMENT);
mDeviceAdresss = intent.getStringExtra(EXTRAS_DEVICE_NAMEEEE);
mAssett = intent.getStringExtra(EXTRAS_DEVICE_ASSETTT);
mEqiupmenttagg= intent.getStringExtra(EXTRAS_DEVICE_EQUIPMENTTAGGG);
mMachineclass = intent.getStringExtra(EXTRAS_DEVICE_MACHINECLASSSS);
mMountinglocationn = intent.getStringExtra(EXTRAS_DEVICE_MOUNTINGLOCATIONNN);
File file = new File( "/sdcard/Nisent/"+mDeviceAdresss+mAssett+mEqiupmenttagg+mMachineclass+mMountinglocationn+"-X-Axis"+".csv");
logFile = file;
if (logFile != null) {
try {
setLogText(logFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
public void onResume() {
super.onResume();
}
private class CustomDataEntry extends ValueDataEntry {
CustomDataEntry(String x, Number value) {
super(x, value);
}
}
private void setLogText(File file) throws FileNotFoundException {
meas = measAxis;
int i=Integer.parseInt(meas);
Log.d(TAG,"measurment " + i );
switch (i) {
case 1: {
anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setZoomEnabled(true);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.xScroller(true);
cartesian.title(mDeviceAdresss);
cartesian.xAxis(0).title("Time");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("Temperature");
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Temp Data");
series1.markers(true);
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while (inputStream.hasNext()) {
String line = inputStream.next();
if (line.equals("")) {
continue;
} // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W = ""; // Time (12 hours format)
String X = values[2]; // Temperature
String result = X.substring(1, X.length() - 1);
Double T = Double.valueOf(result);
Log.d(TAG, "HELLO+ " + T);
seriesData.add(new CustomDataEntry(V + " " + W, T));
inputStream.hasNext();
}
inputStream.hasNext();
set.data(seriesData);
anyChartView.setChart(cartesian);
break;
}
case 2: {
anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setZoomEnabled(true);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.xScroller(true);
cartesian.title(mDeviceAdresss);
cartesian.xAxis(0).title("VRMS-X");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("VRMS-X");
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("VRMS-X Data");
series1.markers(true);
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while (inputStream.hasNext()) {
String line = inputStream.next();
if (line.equals("")) {
continue;
} // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W = ""; // Time (12 hours format)
String X = values[4]; // Temperature
String result = X.substring(1, X.length() - 1);
Double T = Double.valueOf(result);
Log.d(TAG, "HELLO+ " + T);
seriesData.add(new CustomDataEntry(V + " " + W, T));
inputStream.hasNext();
}
inputStream.hasNext();
set.data(seriesData);
anyChartView.setChart(cartesian);
break;
}
case 3: {
anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setZoomEnabled(true);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.xScroller(true);
cartesian.title(mDeviceAdresss);
cartesian.xAxis(0).title("Acc-P");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("Acc-P");
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Acc-P Data");
series1.markers(true);
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while (inputStream.hasNext()) {
String line = inputStream.next();
if (line.equals("")) {
continue;
} // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W = ""; // Time (12 hours format)
String X = values[6]; // Temperature
String result = X.substring(1, X.length() - 1);
Double T = Double.valueOf(result);
Log.d(TAG, "HELLO+ " + T);
seriesData.add(new CustomDataEntry(V + " " + W, T));
inputStream.hasNext();
}
inputStream.hasNext();
set.data(seriesData);
anyChartView.setChart(cartesian);
break;
}
case 4: {
anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setZoomEnabled(true);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.xScroller(true);
cartesian.title(mDeviceAdresss);
cartesian.xAxis(0).title("Acc-R");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("Acc-R");
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Acc-R Data");
series1.markers(true);
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while (inputStream.hasNext()) {
String line = inputStream.next();
if (line.equals("")) {
continue;
} // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W = ""; // Time (12 hours format)
String X = values[8]; // Temperature
String result = X.substring(1, X.length() - 1);
Double T = Double.valueOf(result);
Log.d(TAG, "HELLO+ " + T);
seriesData.add(new CustomDataEntry(V + " " + W, T));
inputStream.hasNext();
}
inputStream.hasNext();
set.data(seriesData);
anyChartView.setChart(cartesian);
break;
}
case 5: {
anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setZoomEnabled(true);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.xScroller(true);
cartesian.title(mDeviceAdresss);
cartesian.xAxis(0).title("Cres");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("Cres");
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Cres Data");
series1.markers(true);
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while (inputStream.hasNext()) {
String line = inputStream.next();
if (line.equals("")) {
continue;
} // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W = ""; // Time (12 hours format)
String X = values[10]; // Temperature
String result = X.substring(1, X.length() - 1);
Double T = Double.valueOf(result);
Log.d(TAG, "HELLO+ " + T);
seriesData.add(new CustomDataEntry(V + " " + W, T));
inputStream.hasNext();
}
inputStream.hasNext();
set.data(seriesData);
anyChartView.setChart(cartesian);
break;
}
case 6: {
anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setZoomEnabled(true);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.xScroller(true);
cartesian.title(mDeviceAdresss);
cartesian.xAxis(0).title("Kurt");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("Kurt");
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Kurt Data");
series1.markers(true);
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while (inputStream.hasNext()) {
String line = inputStream.next();
if (line.equals("")) {
continue;
} // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W = ""; // Time (12 hours format)
String X = values[12]; // Temperature
String result = X.substring(1, X.length() - 1);
Double T = Double.valueOf(result);
Log.d(TAG, "HELLO+ " + T);
seriesData.add(new CustomDataEntry(V + " " + W, T));
inputStream.hasNext();
}
inputStream.hasNext();
set.data(seriesData);
anyChartView.setChart(cartesian);
break;
}
case 7: {
anyChartView = findViewById(R.id.any_chart_view);
anyChartView.setZoomEnabled(true);
Cartesian cartesian = AnyChart.line();
cartesian.animation(true);
cartesian.padding(10d, 20d, 5d, 20d);
cartesian.crosshair().enabled(false);
cartesian.crosshair()
.yLabel(true)
// TODO ystroke
.yStroke((Stroke) null, null, null, (String) null, (String) null);
cartesian.tooltip().positionMode(TooltipPositionMode.POINT);
cartesian.xScroller(true);
cartesian.title(mDeviceAdresss);
cartesian.xAxis(0).title("Skew");
cartesian.xAxis(0).labels().rotation(-45);
cartesian.yAxis(0).title("Skew");
cartesian.yAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);
cartesian.xAxis(0).labels().fontSize(9);
cartesian.xAxis(0).labels().hAlign("center");
cartesian.xAxis(0).labels().vAlign("center");
List<DataEntry> seriesData = new ArrayList<>();
Set set = Set.instantiate();
Mapping series1Mapping = set.mapAs("{ x: 'x', value: 'value' }");
Line series1 = cartesian.line(series1Mapping);
series1.name("Skew Data");
series1.markers(true);
series1.hovered().markers().enabled(true);
series1.hovered().markers()
.type(MarkerType.CIRCLE)
.size(4d);
series1.tooltip()
.position("right")
.anchor(Anchor.LEFT_CENTER)
.offsetX(5d)
.offsetY(5d);
cartesian.legend().enabled(true);
cartesian.legend().fontSize(13d);
cartesian.legend().padding(0d, 0d, 10d, 0d);
Scanner inputStream;
inputStream = new Scanner(file);
while (inputStream.hasNext()) {
String line = inputStream.next();
if (line.equals("")) {
continue;
} // <--- notice this line
String[] values = line.split(",");
String V = values[0]; // Date
String W = ""; // Time (12 hours format)
String X = values[14]; // Temperature
String result = X.substring(1, X.length() - 1);
Double T = Double.valueOf(result);
Log.d(TAG, "HELLO+ " + T);
seriesData.add(new CustomDataEntry(V + " " + W, T));
inputStream.hasNext();
}
inputStream.hasNext();
set.data(seriesData);
anyChartView.setChart(cartesian);
break;
}
}
}
}