<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- 引入 echarts.js -->
<script src="../echarts.js"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
(function () { //加了立即执行函数,foxtable窗口的刷新数据代码不起作用,只有图表模板,无数据
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
var data = []; //应该是未传值进来
var option = {
title: {
text: '动态数据 + 时间坐标轴'
},
tooltip: {
trigger: 'axis',
formatter: function (params) {
params = params[0];
//var date = new Date(params.name);
return '日期:' + params.value[0] + ' 压力: ' + params.value[1] + " 质量:" + params.value[2];
},
axisPointer: {
animation: false
}
},
xAxis: {
type: 'time',
splitLine: {
show: false
}
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%'],
splitLine: {
show: false
}
},
series: [{
name: '模拟数据',
type: 'line',
showSymbol: false,
hoverAnimation: false,
data: data
}]
};
setInterval(function () {
myChart.setOption({
series: [{
data: data
}]
});
}, 2000);
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
})();
</script>
</body>
</html>
foxtable button click刷新数据代码
Dim web = e.Form.Controls("WebBrowser1").BaseControl
Dim dt As DataTable = DataTables("数据表")
web.Document.InvokeScript("eval", new String() {"data=[]"}) '清空数据
'生成数据
For Each dr As DataRow In dt.Select("", "日期")
Dim d As Date = dr("日期")
web.Document.InvokeScript("eval", new String() {"data.push({name: '" & dr("_Identify") & "',value: ['" & d & "',Math.round(" & dr("压力") & "),'" & dr("质量") & "']});" })
Next