index_bak.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!DOCTYPE html>
  2. <html style="height: 100%">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:">
  6. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="default">
  9. <meta name="theme-color" content="#2196f3">
  10. <meta name="format-detection" content="telephone=no">
  11. <meta name="msapplication-tap-highlight" content="no">
  12. <title>动态权益图</title>
  13. </head>
  14. <body style="height: 100%; margin: 0">
  15. <?php
  16. $d=date("Ymd");
  17. if($_GET["date"]!="")
  18. $d=strtotime($_GET["date"]);
  19. $datatxt=file_get_contents("178118_$d.json");
  20. $data=json_decode($datatxt,true);
  21. ?>
  22. <div id="container" style="height: 100%"></div>
  23. <script type="text/javascript" src="//lib.baomitu.com/echarts/5.1.2/echarts.min.js"></script>
  24. <script type="text/javascript" src="//lib.baomitu.com/echarts/5.1.2/extension/dataTool.min.js"></script>
  25. <script type="text/javascript" src="http://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
  26. <script type="text/javascript">
  27. var dom = document.getElementById("container");
  28. var myChart = echarts.init(dom);
  29. var app = {};
  30. option = null;
  31. option = {
  32. title: {
  33. text: '动态权益图',
  34. subtext: '账号:178118'
  35. },
  36. tooltip: {
  37. trigger: 'axis',
  38. axisPointer: {
  39. type: 'cross',
  40. label: {
  41. backgroundColor: '#283b56'
  42. }
  43. }
  44. },
  45. legend: {
  46. data:['最新权益', '盈亏']
  47. },
  48. toolbox: {
  49. show: true,
  50. feature: {
  51. dataView: {readOnly: false},
  52. restore: {},
  53. saveAsImage: {}
  54. }
  55. },
  56. dataZoom: {
  57. show: true,
  58. start: 40,
  59. end: 100
  60. },
  61. xAxis: [
  62. {
  63. type: 'category',
  64. boundaryGap: true,
  65. data:[<?php foreach($data as $k=>$v){ echo "'".$data[$k]["datetime"]."',";} ?>]
  66. },
  67. {
  68. type: 'category',
  69. boundaryGap: true,
  70. data: [<?php foreach($data as $k=>$v){ echo "'".$data[$k]["datetime"]."',";} ?>]
  71. }
  72. ],
  73. yAxis: [
  74. {
  75. type: 'value',
  76. scale: true,
  77. name: '权益',
  78. max: 2500000,
  79. min: 5000000,
  80. boundaryGap: [0.2, 0.2]
  81. },
  82. {
  83. type: 'value',
  84. scale: true,
  85. name: '盈亏',
  86. max: 200000,
  87. min: -200000,
  88. boundaryGap: [0.2, 0.2]
  89. }
  90. ],
  91. series: [
  92. {
  93. name:'权益',
  94. type:'line',
  95. data:[<?php foreach($data as $k=>$v) { echo $data[$k]["balance"].",";}?>]
  96. },
  97. {
  98. name:'盈亏',
  99. type:'bar',
  100. xAxisIndex: 1,
  101. yAxisIndex: 1,
  102. data:[<?php foreach($data as $k=>$v) { echo ($data[$k]["float_profit"]).",";}?>]
  103. }
  104. ]
  105. };
  106. app.count = 11;
  107. lastid='<?php echo $data[count($data)-1]["datetime"];?>';
  108. setInterval(function (){
  109. htmlobj=$.ajax({url:"/tianqin/getdata.php?date=<?php echo $d;?>&lastid="+lastid,async:false});
  110. jsondata=htmlobj.responseText;
  111. if(jsondata!=""){
  112. newdata=jQuery.parseJSON(jsondata);
  113. console.log(newdata);
  114. if(newdata.length>0){
  115. lastid=newdata[newdata.length-1]["datetime"];
  116. }
  117. for(i=0;i<newdata.length;i++){
  118. var data0 = option.series[0].data;
  119. var data1 = option.series[1].data;
  120. data0.shift();
  121. data0.push(newdata[i]["balance"]);
  122. data1.shift();
  123. data1.push(newdata[i]["float_profit"]);
  124. option.xAxis[0].data.shift();
  125. option.xAxis[0].data.push(newdata[i]["datetime"]);
  126. option.xAxis[1].data.shift();
  127. option.xAxis[1].data.push(newdata[i]["datetime"]);
  128. myChart.setOption(option)
  129. }
  130. }
  131. }, 2100);
  132. if (option && typeof option === "object") {
  133. myChart.setOption(option, true);
  134. }
  135. </script>
  136. </body>
  137. </html>