123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <!DOCTYPE html>
- <html style="height: 100%">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="default">
- <meta name="theme-color" content="#2196f3">
- <meta name="format-detection" content="telephone=no">
- <meta name="msapplication-tap-highlight" content="no">
- <title>动态权益图</title>
- </head>
- <body style="height: 100%; margin: 0">
- <?php
- $d=date("Ymd");
- if($_GET["date"]!="")
- $d=strtotime($_GET["date"]);
-
- $datatxt=file_get_contents("178118_$d.json");
-
- $data=json_decode($datatxt,true);
-
- ?>
- <div id="container" style="height: 100%"></div>
- <script type="text/javascript" src="//lib.baomitu.com/echarts/5.1.2/echarts.min.js"></script>
- <script type="text/javascript" src="//lib.baomitu.com/echarts/5.1.2/extension/dataTool.min.js"></script>
- <script type="text/javascript" src="http://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
- <script type="text/javascript">
- var dom = document.getElementById("container");
- var myChart = echarts.init(dom);
- var app = {};
- <?php
- $max=0;
- $min=999999999;
- for($i=0;$i<count($data);$i++){
- if($max<$data[$i]['balance']){
- $max=$data[$i]['balance'];
- }
- if($min>$data[$i]['balance']){
- $min=$data[$i]['balance'];
- }
- }
-
- if(count($data)>0){
- $low=round($min*(1-0.01)/10);
- $high=round($max*(1+0.01)/10);
- }else{
- $low=1000000;
- $high=3000000;
- }
- ?>
- option = null;
- option = {
- title: {
- text: '动态权益图',
- subtext: '账号:178118'
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'cross',
- label: {
- backgroundColor: '#283b56'
- }
- }
- },
- grid: {
- top: '16%', // 等价于 y: '16%'
- left: '3%',
- right: '8%',
- bottom: '3%',
- containLabel: true
- },
- legend: {
- data:['最新权益']
- },
- toolbox: {
- show: true,
- feature: {
- dataView: {readOnly: false},
- restore: {},
- saveAsImage: {}
- }
- },
- dataZoom: {
- show: true,
- start: 40,
- end: 100
- },
- xAxis: [
- {
- type: 'category',
- boundaryGap: true,
- data:[<?php foreach($data as $k=>$v){ echo "'".$data[$k]["datetime"]."',";} ?>],
- },
- ],
- yAxis:
- {
- type: 'value',
- name: '权益',
- max: <?php echo $high;?>,
- min: <?php echo $low;?>,
- axisLabel: {
- show: true,
- interval: 'auto',
- formatter: '{value}'
- },
- show: true
-
- },
-
- series: [
-
- {
- name:'权益',
- type:'line',
- data:[<?php foreach($data as $k=>$v) { echo round($data[$k]["balance"]/10).",";}?>]
- }
- ]
-
- };
- app.count = 11;
- lastid='<?php echo $data[count($data)-1]["datetime"];?>';
- setInterval(function (){
-
- htmlobj=$.ajax({url:"/tianqin/getdata.php?date=<?php echo $d;?>&lastid="+lastid,async:false});
- jsondata=htmlobj.responseText;
- if(jsondata!=""){
- newdata=jQuery.parseJSON(jsondata);
- console.log(newdata);
- if(newdata.length>0){
- lastid=newdata[newdata.length-1]["datetime"];
- }
-
- for(i=0;i<newdata.length;i++){
- var data0 = option.series[0].data;
- var data1 = option.series[1].data;
- data0.shift();
- data0.push(round(newdata[i]["balance"]/10));
-
- option.xAxis[0].data.shift();
- option.xAxis[0].data.push(newdata[i]["datetime"]);
- myChart.setOption(option)
-
- }
-
-
- }
- }, 2100);
- if (option && typeof option === "object") {
- myChart.setOption(option, true);
- }
- </script>
- </body>
- </html>
|