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

相关推荐
2501_9159090617 小时前
iOS 应用反调试技详解术 检测调试器的原理与防护实践
android·ios·小程序·https·uni-app·iphone·webview
Lvan的前端笔记17 小时前
AndroidX 完全入门指南
android·androidx
帅次17 小时前
Android 应用高级面试:Window 近1年高频追问 18 题
android·面试·职场和发展
总捣什么乱118 小时前
MySQL MySQL是怎么保证主备一致的?
android·mysql·adb
zzm62818 小时前
精读 HinDroid:基于异构信息网络的安卓恶意软件检测
android
weixin_4407841119 小时前
Android基础知识汇总
android·java·android studio
sbjdhjd19 小时前
安全初级 | Upload 文件上传漏洞实操
android·经验分享·安全·网络安全·开源·php·apache
small-pudding19 小时前
Cocos Creator Android 热更新方案实践:逻辑更新、远程 Bundle 与线上回滚
android
00后程序员张20 小时前
iOS加固技术路线全面解析:Bitcode模式、源码模式与汇编模式对比及爱加密优势
android·汇编·ios·小程序·uni-app·cocoa·iphone
yunsr20 小时前
PHP函数及漏洞防御
android·开发语言·php