Android 使用 eChart 设置标线

echart使用标线

Android部分:

import android.webkit.WebView;
import com.jianqu.plasmasterilizer.R;
import com.jianqu.plasmasterilizer.utils.DisplayUtils;
import com.jianqu.plasmasterilizer.utils.TimerUtil;

import java.util.ArrayList;

import java.util.List;

/**

* 监测
* index 3
* Created by yanyou on 2023/9/10.
*/
public class ChartFragment extends BaseFragment {
private final String TAG = this.getClass().getName();
private TimerUtil timerUtil;
private int time = 100000;
private int count = 120;
private WebView webview;
List<String> xdata = new ArrayList<>();
List<Integer> Ydata = new ArrayList<>();
List<Integer> values1 = new ArrayList<>();
List<Integer> values2 = new ArrayList<>();
List<Integer> values3 = new ArrayList<>();
private int baseLine1 = 7000;
private int baseLine2 = 5500;
private int baseLine3 = 3500;

@Override

protected int setLayoutResouceId() {
return getLayout();
}

private int getLayout() {

int w = DisplayUtils.getScreenH(mActivity);
int layoutId = 0;
layoutId = R.layout.fragment_chart_10c;
return layoutId;
}

@Override

protected void initView() {
findViewById(R.id.rv_back).setOnClickListener(view -> {
mActivity.backFragment(2);
});
findViewById(R.id.ll_scaling).setOnClickListener(view -> {
mActivity.goFragment(4);

});

findViewById(R.id.ll_set).setOnClickListener(view -> {
mActivity.goFragment(6);

});

webview = findViewById(R.id.webview);

int[] yValue1 = new int[]{0, 3000, 6000, 9000, 12000, 15000};

for (int s : yValue1) {
Ydata.add(s);
}
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setAllowFileAccess(true);
webview.loadUrl("file:///android_asset/chart.html");

initTimerUtil();

}

private void initTimerUtil() {

TimerUtil.OnTimerChangeListener onTimerChangeListener = new TimerUtil.OnTimerChangeListener() {
@Override
public void doChange() {
doTimeChange();
}
};
timerUtil = new TimerUtil(500, 500, onTimerChangeListener);
timerUtil.timeStart();
}

private void doTimeChange() {

time--;
if (time > 0) {
//
int val = (int) (Math.random() * 1000) + 6500;
values1.add(val);
int val2 = (int) (Math.random() * 2000) + 4000;
values2.add(val2);
int val3 = (int) (Math.random() * 2300) + 2000;
values3.add(val3);
xdata.add("" + xdata.size());
webview.loadUrl("javascript:doCreateChart(" + baseLine1 + "," + baseLine2 + "," + baseLine3 + "," + xdata + "," + Ydata + "," + values1 + "," + values2 + "," + values3 + ");");
} else if (time == 0) {
//
timerUtil.timeStop();
}
}

@Override

protected boolean isRegisterEventBus() {
return false;
}

@Override

public void onDestroy() {
// EventBus.getDefault().unregister(this);
super.onDestroy();
}
}

eChart部分:

https://download.csdn.net/download/anroidyanyou/88411884

相关推荐
似霰2 分钟前
安卓智能指针sp、wp、RefBase浅析
android·c++·binder
大风起兮云飞扬丶2 分钟前
Android——网络请求
android
干一行,爱一行4 分钟前
android camera data -> surface 显示
android
断墨先生21 分钟前
uniapp—android原生插件开发(3Android真机调试)
android·uni-app
无极程序员2 小时前
PHP常量
android·ide·android studio
萌面小侠Plus3 小时前
Android笔记(三十三):封装设备性能级别判断工具——低端机还是高端机
android·性能优化·kotlin·工具类·低端机
慢慢成长的码农3 小时前
Android Profiler 内存分析
android
大风起兮云飞扬丶3 小时前
Android——多线程、线程通信、handler机制
android
L72563 小时前
Android的Handler
android
清风徐来辽3 小时前
Android HandlerThread 基础
android