diff --git a/application/admin/model/History.php b/application/admin/model/History.php index be03d32..bb85272 100644 --- a/application/admin/model/History.php +++ b/application/admin/model/History.php @@ -57,17 +57,11 @@ class History extends Model foreach ($history as $row) { $expects[] = (string)$row['expect']; if ($type === 'special') { - $num = (int)$row['num7']; - $data[] = [ - 'num7' => $num, - 'num7_color' => isset($colorMap[$num]) ? $colorMap[$num] : '—' - ]; + $data[] = ['num7' => (int)$row['num7']]; } else { $row_data = []; for ($i = 1; $i <= 7; $i++) { - $num = (int)$row['num' . $i]; - $row_data['num' . $i] = $num; - $row_data['num' . $i . '_color'] = isset($colorMap[$num]) ? $colorMap[$num] : '—'; + $row_data['num' . $i] = (int)$row['num' . $i]; } $data[] = $row_data; } diff --git a/application/admin/view/history/index.html b/application/admin/view/history/index.html index f7fbe1d..ded8342 100644 --- a/application/admin/view/history/index.html +++ b/application/admin/view/history/index.html @@ -22,3 +22,6 @@ + + + diff --git a/public/assets/js/backend/history.js b/public/assets/js/backend/history.js index 85a855b..ab355dc 100644 --- a/public/assets/js/backend/history.js +++ b/public/assets/js/backend/history.js @@ -217,7 +217,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin }, /** - * 渲染走势图(网格形式) + * 渲染走势图(ECharts 折线图) */ renderTrend: function (data, type, layero) { var expects = data.expects; @@ -238,35 +238,81 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin return '#95a5a6'; }; - var html = '
| 期号 | '; + $('#trend-result', layero).html(''); + + var chartDom = document.getElementById('trend-chart'); + var myChart = echarts.init(chartDom); + + var series = []; if (type === 'special') { - html += '特码 | '; - } else { - for (var c = 1; c <= 7; c++) { - html += '' + c + ' | '; - } - } - html += '
|---|---|---|
| ' + expects[i] + ' | '; - if (type === 'special') { - var num = rows[i].num7; - var color = getColor(num); - html += '' + num + ' | '; - } else { - for (var j = 1; j <= 7; j++) { - var val = rows[i]['num' + j]; - var c = getColor(val); - html += '' + val + ' | '; + series = [{ + name: '特码', + type: 'line', + data: rows.map(function (r) { return r.num7; }), + smooth: false, + symbol: 'circle', + symbolSize: 8, + lineStyle: { width: 2 }, + itemStyle: { + color: function (params) { + var num = params.data; + return getColor(num); + } + }, + label: { + show: true, + position: 'top', + fontSize: 11, + color: '#333' } + }]; + } else { + var numFields = []; + for (var c = 1; c <= 7; c++) { + numFields.push('num' + c); + } + var colors = ['#e74c3c', '#3498db', '#2ecc71', '#f39c12', '#9b59b6', '#1abc9c', '#e67e22']; + for (var f = 0; f < numFields.length; f++) { + (function (idx) { + series.push({ + name: '第' + (idx + 1) + '码', + type: 'line', + data: rows.map(function (r) { return r[numFields[idx]]; }), + smooth: false, + symbol: 'circle', + symbolSize: 6, + lineStyle: { width: 2 }, + itemStyle: { color: colors[idx] }, + label: { + show: true, + position: 'top', + fontSize: 10, + color: '#333' + } + }); + })(f); } - html += '