html代碼 <div class="layui-row" style="margin-top:0.5rem"> <div style="width:90%;margin:0rem auto 0.7rem auto;font-size:0.28rem"> <div style="background ...
html代碼
<div class="layui-row" style="margin-top:0.5rem"> <div style="width:90%;margin:0rem auto 0.7rem auto;font-size:0.28rem"> <div style="background:#3385ff;color:#fff;border-radius:4px;padding:0.08rem 0.2rem;display: inline;margin-left:0.2rem;">體溫變化曲線圖 / ℃</div> <div style="border:1px solid #3385ff;height:auto;border-radius:4px;box-sizing:border-box;margin-top:-0.18rem;height:3.2rem;"> <div id="tiwen" style="width:100;height:100%;"></div> </div> </div> </div>
js代碼
<script type="text/javascript"> // 折線圖 $(function () { tiwen(); // 體溫 function tiwen() { // 基於準備好的dom,初始化echarts實例 var myChart = echarts.init(document.getElementById('tiwen')); option = { title:{ // text:'EChars入門' }, grid:{ x:35, y:35, x2:25, y2:40, }, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', data: [], axisLabel: { margin: 10, color: '#777', }, axisLine: { lineStyle: { color: 'rgba(107,107,107,1)', } }, }, yAxis: { type: 'value', splitNumber: 2, scale:true, // minInterval: 1, maxInterval: 3600 * 24 * 1000, axisLabel: { color: '#555', margin: 6 }, axisLine: { lineStyle: { color: 'rgba(107,107,107,0.2)', } }, splitLine: { lineStyle: { type: 'dashed', color: 'rgba(131,101,101,0.3)' } }, }, series: [{ name: '體溫', data: [], type: 'line', lineStyle: { normal: { width: 2, color: { type: 'linear', colorStops: [{ offset: 0, color: '#48D8BF' // 0% 處的顏色 }, { offset: 1, color: '#48D8BF' // 100% 處的顏色 }], globalCoord: false // 預設為 false } } }, itemStyle: { normal: { color: '#48D8BF', borderColor: "#5b92c9" } }, smooth: true }] }; // 使用剛指定的配置項和數據顯示圖表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); // 非同步載入數據 $.get("getTiwen.html?cardid="+cardid+"").done(function (data) { if (data.code == 200) { // 後臺傳過來的數據 var createdate = data.data.createdate var tiwen = data.data.tiwen }else{ // 預設值 var createdate = ['03/01','03/02','03/03','03/04','03/05','03/06','03/07'] var tiwen = [62,64,62,63,63,64,63] } // 填入數據 myChart.setOption({ xAxis: { data: createdate }, series: [{ data: tiwen }] }); }); } }) </script>