java - 如何制作实时滴答线图(MpandroidChart)?
问题描述
我从一个字符串创建了一个数组列表,如下所示:
String strp = pprices.getText().toString().trim();
String[] wordsp=strp.split("\\s+");
int get_current_price = i_current_index;
int next_60_seconds = i_current_index + 60;
int s_launch = StringUtils.ordinalIndexOf(strp, " ", get_current_price);
String split1 = strp.substring(0, s_launch);
String split2 = strp.substring(s_launch);
int s_required_60 = StringUtils.ordinalIndexOf(split2, " ", next_60_seconds);
String split3 = strp.substring(0, s_required_60);
String split4 = strp.substring(s_required_60);
List<Double> numberListp2 = new ArrayList<Double>();
for (String numberTextp2 : split2.trim().split("\\s+"))
numberListp2.add(Double.valueOf(numberTextp2));
// To array
int i2;
String[] numberTextsp2 = split2.trim().split("\\s+");
double[] numberArrayp2 = new double[numberTextsp2.length];
for (i2 = 0; i2 < numberTextsp2.length; i2++) {
numberArrayp2[i2] = Double.parseDouble(numberTextsp2[i2]);
}
//1. Set the x-axis and y-axis points
List<Entry> entries2 = new ArrayList<>();
for (i2 = 0; i2 < numberTextsp2.length; i2++) {
entries2.add(new Entry(i2, (float) numberArrayp2[i2]));
entry_count = i2;
}
所以我正在使用这条线绘制:
entries2.add(new Entry(i2, (float) numberArrayp2[i2]));
X和Y坐标在哪里i2
_(float) numberArrayp2[i2]
然后我有:
ArrayList<ILineDataSet> dataSets= new ArrayList<ILineDataSet>();
LineDataSet dataSet2 = new LineDataSet(entries2, "Entry2");
dataSets.add(dataSet2);
LineData linedata = new LineData(dataSets);
mChart.setData(linedata);
mChart.invalidate(); // refresh
data.notifyDataChanged();
此代码有效,并且折线图绘制得很好。
现在直接解决我的问题:
我不想一次绘制所有点,而是让它实时滴答作响,在点之间以 1000 毫秒的间隔一个接一个地绘制。
我怎样才能做到这一点?
解决方案
推荐阅读
- c# - 如何在 C# 中执行函数参数
- spring-boot - 在名称为“dispatcherServlet”的 DispatcherServlet 中找不到具有 URI [/WEB-INF/JSP/restapis.jsp] 的 HTTP 请求的映射
- d3.js - D3折线和文本重叠
- jquery - 我如何根据我在 Jquery Autocomplete 中选择的选项获取值(ID)
- vba - 如何使 vba PowerPoint 的自动运行工作?
- r - 带有 `dbplyr` 和 `RPostgres` 的 unnest json 列
- java - 使用 Apache Beam 将 SAP HANA 连接到 Big Query
- c++ - C ++中的指针输出问题
- sql - 如何使用 case 语句在 PIVOT 中获取多个列
- ansible - Ansible:你可以在另一个变量中迭代一个变量吗?