大屏数据展示

This commit is contained in:
Rue Ji
2026-02-04 23:46:37 +08:00
parent 79a8fc11cf
commit 14c9bd8ce0
14 changed files with 2566 additions and 909 deletions

View File

@ -13,8 +13,6 @@
width: 100%;
height: 100%;
overflow: auto;
background-color: #030829;
font-family: "Microsoft YaHei", sans-serif;
}
.screen-container {
width: 6500px;
@ -24,311 +22,436 @@
background-repeat: no-repeat;
position: relative;
}
/* Module Container */
.rank-module-container {
.stat-card {
position: absolute;
top: 356px;
left: 198px;
width: 1900px;
height: 1400px;
/* background: rgba(255, 0, 0, 0.1); Debugging background */
display: flex;
flex-direction: column;
padding: 20px;
top: 257px;
/* left: 1910px; */
width: 200px;
height: 71px;
color: rgba(255, 255, 255, 1);
font-family: Gilroy;
font-weight: 500;
font-size: 60px;
}
.card-1 { left: 1910px; }
.card-2 { left: 2832px; }
.card-3 { left: 3754px; }
.ring-chart-wrapper {
position: absolute;
top: 563px;
left: 1880px;
width: 662px;
height: 455px;
}
.pie-chart-wrapper-2 {
position: absolute;
top: 563px;
left: 2572px;
width: 662px;
height: 455px;
}
.gauge-chart-wrapper-3 {
position: absolute;
top: 563px;
left: 3264px;
width: 662px;
height: 455px;
}
.gauge-chart-wrapper-4 {
position: absolute;
top: 563px;
left: 3956px;
width: 662px;
height: 455px;
}
.bar-chart-wrapper-5 {
position: absolute;
top: 1158px;
left: 1881px;
width: 1353px;
height: 592px;
}
.bar-chart-wrapper-6 {
position: absolute;
top: 1158px;
left: 3265px;
width: 1353px;
height: 592px;
}
.ring-chart-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.4;
mix-blend-mode: normal;
/* border: 1px solid rgba(27, 126, 242, 1); */
box-sizing: border-box;
/* background: rgba(27, 126, 242, 0.6); */
}
/* Statistics Header */
.stats-header {
width: 100%;
height: 180px;
display: flex;
justify-content: space-around;
align-items: center;
background: rgba(0, 20, 50, 0.3);
border: 1px solid rgba(0, 234, 255, 0.2);
border-radius: 12px;
margin-bottom: 30px;
backdrop-filter: blur(10px);
}
.stat-item {
text-align: center;
}
.stat-label {
font-size: 32px;
color: #00eaff;
margin-bottom: 10px;
}
.stat-value {
font-size: 64px;
font-weight: bold;
color: #ffffff;
font-family: 'DIN Alternate', 'Arial Narrow', sans-serif;
text-shadow: 0 0 20px rgba(0, 234, 255, 0.5);
}
.stat-unit {
font-size: 24px;
color: #aaaaaa;
margin-left: 5px;
}
/* Charts Area */
.charts-wrapper {
flex: 1;
display: flex;
gap: 40px;
}
.chart-box {
flex: 1;
background: rgba(0, 20, 50, 0.3);
border: 1px solid rgba(0, 234, 255, 0.2);
border-radius: 12px;
padding: 20px;
display: flex;
flex-direction: column;
backdrop-filter: blur(10px);
}
.chart-title {
font-size: 36px;
color: #ffffff;
text-align: center;
margin-bottom: 20px;
padding-bottom: 15px;
border-bottom: 1px solid rgba(0, 234, 255, 0.2);
}
.chart-content {
flex: 1;
#ring-chart-content, #pie-chart-content-2, #gauge-chart-content-3, #gauge-chart-content-4, #bar-chart-content-5, #bar-chart-content-6 {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="screen-container">
<div class="rank-module-container">
<!-- Statistics -->
<div class="stats-header">
<div class="stat-item">
<div class="stat-label">辖区排污企业总数</div>
<div class="stat-value" id="totalCount">0<span class="stat-unit">家</span></div>
</div>
<div class="stat-item">
<div class="stat-label">已接入监控</div>
<div class="stat-value" style="color: #00ff00;" id="connectedCount">0<span class="stat-unit">家</span></div>
</div>
<div class="stat-item">
<div class="stat-label">正在接入中</div>
<div class="stat-value" style="color: #ffaa00;" id="connectingCount">0<span class="stat-unit">家</span></div>
</div>
</div>
<!-- Charts -->
<div class="charts-wrapper">
<div class="chart-box">
<div class="chart-title">近30日排污量 TOP 10 (最大)</div>
<div id="chartMax" class="chart-content"></div>
</div>
<div class="chart-box">
<div class="chart-title">近30日排污量 TOP 10 (最小)</div>
<div id="chartMin" class="chart-content"></div>
</div>
</div>
<div class="stat-card card-1">53829.5</div>
<div class="stat-card card-2">2495</div>
<div class="stat-card card-3">2460</div>
<div class="ring-chart-wrapper">
<div class="ring-chart-bg"></div>
<div id="ring-chart-content"></div>
</div>
<div class="pie-chart-wrapper-2">
<div class="ring-chart-bg"></div>
<div id="pie-chart-content-2"></div>
</div>
<div class="gauge-chart-wrapper-3">
<div class="ring-chart-bg"></div>
<div id="gauge-chart-content-3"></div>
</div>
<div class="gauge-chart-wrapper-4">
<div class="ring-chart-bg"></div>
<div id="gauge-chart-content-4"></div>
</div>
<div class="bar-chart-wrapper-5">
<div class="ring-chart-bg"></div>
<div id="bar-chart-content-5"></div>
</div>
<div class="bar-chart-wrapper-6">
<div class="ring-chart-bg"></div>
<div id="bar-chart-content-6"></div>
</div>
</div>
<script>
$(document).ready(function() {
initData();
launchIntoFullscreen(document.documentElement);
initPieChart();
initPieChart2();
initGaugeChart('gauge-chart-content-3', 53829.5);
initGaugeChart('gauge-chart-content-4', 12345.6);
initBarChart('bar-chart-content-5', [3000, 4500, 1500, 5000, 23000, 1500, 15000, 3000, 4000, 5000, 2000, 1000, 500, 2563, 4000]);
initBarChart('bar-chart-content-6', [2000, 3000, 1000, 4000, 18000, 1000, 12000, 2000, 3000, 4000, 1500, 800, 400, 2000, 3000]);
// Double click to toggle fullscreen
$('body').on('dblclick', function() {
launchIntoFullscreen(document.documentElement);
});
});
function initData() {
// Mock Data Generation
var enterprises = [];
var total = 158;
var connected = 124;
var connecting = 34;
// Update Stats
$('#totalCount').html(total + '<span class="stat-unit">家</span>');
$('#connectedCount').html(connected + '<span class="stat-unit">家</span>');
$('#connectingCount').html(connecting + '<span class="stat-unit">家</span>');
// Generate random enterprise data
for (var i = 1; i <= 50; i++) {
enterprises.push({
name: '企业-' + i,
value: Math.floor(Math.random() * 10000) + 500
});
}
// Sort for Max
var sortedMax = [...enterprises].sort((a, b) => b.value - a.value).slice(0, 10);
// Sort for Min
var sortedMin = [...enterprises].sort((a, b) => a.value - b.value).slice(0, 10);
renderCharts(sortedMax, sortedMin);
function initPieChart() {
var chartDom = document.getElementById('ring-chart-content');
var myChart = echarts.init(chartDom);
var option = {
color: [
'#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc',
'#00d4ff', '#ffb700', '#2bff89', '#915eff', '#ff7f00'
],
series: [
{
name: '管线类型统计',
type: 'pie',
radius: '55%',
center: ['50%', '50%'],
avoidLabelOverlap: true,
label: {
show: true,
position: 'outside',
formatter: '{b}',
fontSize: 14,
lineHeight: 20,
align: 'left'
},
labelLine: {
show: true,
length: 20,
length2: 30,
lineStyle: {
type: 'solid'
}
},
data: [
{ value: 335, name: 'II级钢筋混凝土管 承插接口' },
{ value: 310, name: '焊接钢管 焊接接口' },
{ value: 274, name: '高密度聚乙烯双壁波纹管' },
{ value: 235, name: '聚乙烯PE管' },
{ value: 200, name: 'II级钢筋混凝土管' },
{ value: 180, name: '高密度聚乙烯缠绕管' },
{ value: 150, name: '焊接钢管 焊接连接' },
{ value: 140, name: '高密度聚乙烯中空壁缠绕管' },
{ value: 130, name: '钢筋混凝土管' },
{ value: 110, name: '球墨铸铁管' },
{ value: 100, name: '预应力钢筒混凝土管' }
]
}
]
};
myChart.setOption(option);
}
function renderCharts(maxData, minData) {
var chartMax = echarts.init(document.getElementById('chartMax'));
var chartMin = echarts.init(document.getElementById('chartMin'));
// Max Option
var optionMax = {
tooltip: {
trigger: 'axis',
axisPointer: { type: 'shadow' }
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
axisLabel: { color: '#fff', fontSize: 16 },
splitLine: { lineStyle: { color: 'rgba(255,255,255,0.1)' } }
},
yAxis: {
type: 'category',
data: maxData.map(item => item.name).reverse(),
axisLabel: { color: '#fff', fontSize: 18 },
axisLine: { lineStyle: { color: '#00eaff' } }
},
series: [{
name: '排污量',
type: 'bar',
data: maxData.map(item => item.value).reverse(),
label: { show: true, position: 'right', color: '#fff', fontSize: 16 },
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
offset: 0, color: '#ff5500'
}, {
offset: 1, color: '#ffbb00'
}]),
barBorderRadius: [0, 10, 10, 0]
}
},
barWidth: 40,
animationDuration: 2000,
animationEasing: 'cubicOut'
}]
function initPieChart2() {
var chartDom = document.getElementById('pie-chart-content-2');
var myChart = echarts.init(chartDom);
var option = {
color: [
'#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc',
'#00d4ff', '#ffb700', '#2bff89', '#915eff', '#ff7f00'
],
series: [
{
name: '管线类型统计2',
type: 'pie',
radius: '55%',
center: ['50%', '50%'],
avoidLabelOverlap: true,
label: {
show: true,
position: 'outside',
formatter: '{b}',
fontSize: 14,
lineHeight: 20,
align: 'left'
},
labelLine: {
show: true,
length: 20,
length2: 30,
lineStyle: {
type: 'solid'
}
},
data: [
{ value: 335, name: 'II级钢筋混凝土管 承插接口' },
{ value: 310, name: '焊接钢管 焊接接口' },
{ value: 274, name: '高密度聚乙烯双壁波纹管' },
{ value: 235, name: '聚乙烯PE管' },
{ value: 200, name: 'II级钢筋混凝土管' },
{ value: 180, name: '高密度聚乙烯缠绕管' },
{ value: 150, name: '焊接钢管 焊接连接' },
{ value: 140, name: '高密度聚乙烯中空壁缠绕管' },
{ value: 130, name: '钢筋混凝土管' },
{ value: 110, name: '球墨铸铁管' },
{ value: 100, name: '预应力钢筒混凝土管' }
]
}
]
};
myChart.setOption(option);
}
// Min Option
var optionMin = {
tooltip: {
trigger: 'axis',
axisPointer: { type: 'shadow' }
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
axisLabel: { color: '#fff', fontSize: 16 },
splitLine: { lineStyle: { color: 'rgba(255,255,255,0.1)' } }
},
yAxis: {
type: 'category',
data: minData.map(item => item.name).reverse(),
axisLabel: { color: '#fff', fontSize: 18 },
axisLine: { lineStyle: { color: '#00eaff' } }
},
series: [{
name: '排污量',
type: 'bar',
data: minData.map(item => item.value).reverse(),
label: { show: true, position: 'right', color: '#fff', fontSize: 16 },
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
offset: 0, color: '#00aa00'
}, {
offset: 1, color: '#00ff00'
}]),
barBorderRadius: [0, 10, 10, 0]
}
},
barWidth: 40,
animationDuration: 2000,
animationEasing: 'cubicOut'
}]
function initGaugeChart(domId, value) {
var chartDom = document.getElementById(domId);
var myChart = echarts.init(chartDom);
var option = {
series: [
{
type: 'gauge',
startAngle: 180,
endAngle: 0,
min: 0,
max: 300,
splitNumber: 6,
radius: '90%',
center: ['50%', '70%'],
axisLine: {
lineStyle: {
width: 40,
color: [[1, new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{ offset: 0, color: 'rgba(65, 108, 243, 1)' },
{ offset: 1, color: 'rgba(0, 68, 160, 1)' }
])]]
}
},
pointer: {
show: true,
length: '60%',
width: 6,
itemStyle: {
color: '#00d4ff'
}
},
axisTick: {
show: false
},
splitLine: {
show: false
},
axisLabel: {
color: '#00d4ff',
fontSize: 14,
distance: -60,
formatter: function (value) {
return value;
}
},
detail: {
show: true,
offsetCenter: [0, '40%'],
fontSize: 30,
color: '#fff',
formatter: '{value} m'
},
data: [{
value: value,
name: ''
}]
}
]
};
chartMax.setOption(optionMax);
chartMin.setOption(optionMin);
// Dynamic Sort Simulation (Update every 3 seconds)
setInterval(function() {
// Randomly change values slightly
maxData.forEach(item => {
item.value += Math.floor(Math.random() * 200) - 100;
if(item.value < 0) item.value = 0;
});
// Re-sort
maxData.sort((a, b) => a.value - b.value); // For horizontal bar, small index is bottom. ECharts draws category 0 at bottom.
// Actually in my code I used reverse() so data is Top to Bottom visually if array is Descending.
// Let's keep data array as Ascending (Small -> Large) so index 0 is at bottom (or top depending on axis inverse).
// Default category axis: index 0 at bottom.
// If I want Top 1 at top, I need index 0 to be the smallest value (if not inverse) or configure axis.
// In previous code: data: maxData.map(item => item.name).reverse()
// If maxData was sorted Descending (Large -> Small), then reverse makes it Small -> Large.
// So index 0 (bottom) is Smallest of the top 10. Index 9 (top) is Largest. Correct.
// Let's just re-sort the source array Descending
maxData.sort((a, b) => b.value - a.value);
// Update chart
chartMax.setOption({
yAxis: {
data: maxData.map(item => item.name).reverse()
},
series: [{
data: maxData.map(item => item.value).reverse()
}]
});
// Do same for Min? Min usually doesn't fluctuate as much to swap "Top Min", but let's simulate.
minData.forEach(item => {
item.value += Math.floor(Math.random() * 50) - 25;
if(item.value < 0) item.value = 0;
});
minData.sort((a, b) => a.value - b.value); // Small -> Large.
// Display: I want Smallest at Top? Or Largest of the Smallest at Top?
// Usually "Top 10 Min" means the 10 smallest values.
// Visualizing: Smallest bar at Top.
// If data is [1, 2, 3...], and I reverse it -> [..., 3, 2, 1].
// Index 0 (bottom) = 10. Index 9 (top) = 1.
// So I need the array to be sorted Small -> Large.
// Then reverse it -> Large -> Small.
// Then bottom (index 0) is Large. Top (index 9) is Small.
// Correct.
chartMin.setOption({
yAxis: {
data: minData.map(item => item.name).reverse()
},
series: [{
data: minData.map(item => item.value).reverse()
}]
});
// Adjust value if it exceeds max for visual representation (optional)
// For now, we just set the data value as is, but if it's large like 53829.5,
// the pointer will be pegged at max.
// If the gauge is just a visual indicator and the number is what matters:
// Let's set the gauge pointer to max if value > 300
if (value > 300) {
option.series[0].data[0].value = 300; // Pointer at max
option.series[0].detail.formatter = value + ' m'; // Show real value
}
}, 3000);
myChart.setOption(option);
}
function initBarChart(domId, data) {
var chartDom = document.getElementById(domId);
var myChart = echarts.init(chartDom);
// Find max value for markPoint (example logic)
var maxVal = Math.max(...data);
var minVal = Math.min(...data);
var option = {
grid: {
top: '20%',
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
data: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15'],
axisLine: {
show: true,
lineStyle: {
color: 'rgba(255, 255, 255, 0.3)'
}
},
axisLabel: {
color: '#fff',
fontSize: 14
},
axisTick: {
show: false
}
},
yAxis: {
type: 'value',
name: '长度(m)',
nameTextStyle: {
color: '#fff',
padding: [0, 0, 0, 20]
},
axisLine: {
show: false
},
axisLabel: {
color: '#fff',
fontSize: 14
},
splitLine: {
show: true,
lineStyle: {
color: 'rgba(255, 255, 255, 0.1)'
}
}
},
series: [
{
data: data,
type: 'bar',
barWidth: '40%',
itemStyle: {
color: 'rgba(255, 170, 0, 0.4)',
borderColor: '#ffaa00',
borderWidth: 1
},
markPoint: {
symbol: 'pin',
symbolSize: 50,
label: {
show: true,
color: '#fff',
fontSize: 12
},
itemStyle: {
color: '#ffaa00'
},
data: [
{ type: 'max', name: 'Max' },
{ type: 'min', name: 'Min' }
]
},
markLine: {
symbol: 'none',
data: [
{ yAxis: 2563.31, name: 'Average' }
],
label: {
show: true,
position: 'end',
formatter: '{c}',
color: '#ffaa00'
},
lineStyle: {
type: 'dotted',
color: '#ffaa00'
}
}
}
]
};
myChart.setOption(option);
}
function launchIntoFullscreen(element) {
if(element.requestFullscreen) {
element.requestFullscreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if(element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}
function exitFullscreen() {
if(document.exitFullscreen) {
document.exitFullscreen();
} else if(document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if(document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
</script>
</body>