事故快检UI页面布局画完

This commit is contained in:
纵昂 2026-03-19 14:00:01 +08:00
parent 5a2ebb1d32
commit 4e976a5593
1 changed files with 401 additions and 7 deletions

View File

@ -1,8 +1,8 @@
<script setup>
import { ref, computed,onMounted } from 'vue'
<script setup >
import { ref, computed,onMounted,onUnmounted } from 'vue'
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { PieChart, BarChart } from 'echarts/charts'
import { BarChart } from 'echarts/charts'
import { TooltipComponent, TitleComponent, GridComponent } from 'echarts/components'
import VChart from 'vue-echarts'
import imgAccuracy from '@/assets/images/home/recognitionAcc.png'
@ -10,9 +10,85 @@ import imgDelay from '@/assets/images/home/detectionAvg.png'
import MapPage from '@/views/map/index.vue'
import Timeline from '@/components/TimelineView/TimelinePag.vue'
import * as echarts from "echarts";
const chartRef = ref(null);
use([CanvasRenderer, PieChart, BarChart, TooltipComponent, TitleComponent, GridComponent])
const chartRef = ref(null); //2
const chartRefThree = ref(null);//3
const chartRefFre = ref(null);//4
let myChartOne = null;
// [, ]
const data = [
[1, 12], [1, 18], [2, 16], [4, 18], [5, 15], [6, 31], [7, 10], [7, 36],
[1.5, 48], [1.8, 80], [4.2, 40], [6.5, 108], [8.5, 72], [9.2, 63],
[10.8, 58], [10.8, 91], [11.2, 98], [12.5, 68], [12.5, 71], [15, 78],
[16.8, 75], [19.2, 72], [19.8, 95], [20.2, 48], [20.8, 50], [21, 71],
[21, 79], [23, 67], [23.2, 102], [32, 95]
];
const initChart = () => {
if (chartRefFre.value) {
myChartOne = echarts.init(chartRefFre.value);
const optionFor = {
grid: {
left: '5%',
right: '5%',
bottom: '10%',
top: '10%',
containLabel: true
},
xAxis: {
name: '处理时间(分钟)',
nameLocation: 'center',
nameGap: 30,
type: 'value',
min: 0,
max: 40,
interval: 10,
axisLine: { show: true, lineStyle: { color: '#E0E0E0' } },
axisTick: { show: false },
axisLabel: { color: '#666', fontSize: 14 },
splitLine: { show: false } // 线
},
yAxis: {
name: '(严重程度)',
nameLocation: 'start',
type: 'value',
min: 0,
max: 120,
interval: 20,
axisLine: { show: false },
axisTick: { show: false },
axisLabel: { color: '#666', fontSize: 14 },
splitLine: {
show: true,
lineStyle: { type: 'dashed', color: '#E0E0E0' } // 线
}
},
series: [
{
data: data,
type: 'scatter',
symbolSize: 10,
itemStyle: {
color: '#2ECC71', // 绿
opacity: 0.8
}
}
]
};
myChartOne.setOption(optionFor);
}
};
//
const handleResize = () => {
myChartOne && myChartOne.resize();
};
// ECharts
use([CanvasRenderer, BarChart, TooltipComponent, TitleComponent, GridComponent])
// -
const accidentQuickDetect = ref({
@ -77,7 +153,166 @@ const carList = ref([
{ name: '建设路', time: '11:12', img: 'xxx.jpg' },
])
// -------------------------------------------------------------------
// 1.
const rawData = [
{ time: '06:00-07:00', blue: 3.0, cyan: 0 },
{ time: '08:00-09:00', blue: 11.6, cyan: 0 },
{ time: '10:00-11:00', blue: 0, cyan: 16.2 },
{ time: '12:00-13:00', blue: 8.9, cyan: 0 },
{ time: '14:00-15:00', blue: 6.9, cyan: 0 },
];
// 2. XY
const xAxisData = computed(() => rawData.map(item => item.time));
const blueData = computed(() => rawData.map(item => item.blue));
const cyanData = computed(() => rawData.map(item => item.cyan));
// 3. ECharts
const optionNew = computed(() => {
// ()
const labelStyle = {
show: true,
position: 'top',
fontSize: 12,
offset: [0, -5], //
formatter: (params) => {
// 0
return params.value > 0 ? params.value.toFixed(1) : '';
},
};
return {
//
color: ['#4A7CFF', '#00E8FF'], // [, ]
//
grid: {
left: '5%',
right: '5%',
top: '15%',
bottom: '10%',
containLabel: true,
},
// ()
legend: {
data: ['数据', '数据一'],
right: 10,
top: 0,
icon: 'rect', //
itemWidth: 10,
itemHeight: 10,
textStyle: {
fontSize: 11,
color: '#666',
},
},
// ()
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
// X
xAxis: {
type: 'category',
data: xAxisData.value,
axisLine: {
lineStyle: {
color: '#E0E0E0', // X线
},
},
axisTick: {
show: false, // 线
},
axisLabel: {
color: '#666',
fontSize: 11,
interval: 0, //
rotate: 0,
margin: 10,
},
},
// Y
yAxis: {
type: 'value',
min: 0,
max: 25, //
interval: 5, // 5
axisLine: {
show: false, // Y线
},
axisTick: {
show: false, // 线
},
axisLabel: {
color: '#666',
fontSize: 11,
},
splitLine: {
show: true,
lineStyle: {
color: '#E0E0E0',
type: 'dashed', // 线
},
},
},
// ()
series: [
{
name: '数据', //
type: 'bar',
barWidth: 15, //
barGap: '-100%', // 使X
data: blueData.value,
label: {
...labelStyle,
color: '#4A7CFF', //
},
itemStyle: {
borderRadius: [2, 2, 0, 0], //
color: (params) => {
// 0
return params.value > 0 ? '#4A7CFF' : 'rgba(0,0,0,0)';
},
},
},
{
name: '数据一', //
type: 'bar',
barWidth: 15,
data: cyanData.value,
label: {
...labelStyle,
color: '#00E8FF', //
},
itemStyle: {
borderRadius: [2, 2, 0, 0],
color: (params) => {
// 0
return params.value > 0 ? '#00E8FF' : 'rgba(0,0,0,0)';
},
},
},
],
};
});
onMounted(() => {
// ------------------------------------------------------------------------
initChart();
window.addEventListener('resize', handleResize);
// ------------------------------------------------------------------------
const chart = echarts.init(chartRef.value);
const option = {
title: {
@ -137,14 +372,98 @@ onMounted(() => {
]
};
chart.setOption(option);
chart.setOption(option);
window.addEventListener("resize", () => {
chart.resize();
});
// --------------------------------------------------------------------------------
const myChart = echarts.init(chartRefThree.value);
const data = [15, 18, 22, 31, 33];
const categories = ['和平路', '文化路', '解放路', '人民路', '建设路'];
const optionThree = {
grid: {
left: '3%',
right: '10%',
bottom: '10%',
top: '5%',
containLabel: true
},
xAxis: {
type: 'value',
max: 40, //
splitLine: {
lineStyle: {
type: 'dashed',
color: '#E0E0E0'
}
},
axisLine: { show: false },
axisTick: { show: false },
axisLabel: {
color: '#666',
margin: 15
},
name: '(事故人数)',
nameLocation: 'middle',
nameGap: 30
},
yAxis: {
type: 'category',
data: categories,
axisLine: { show: false },
axisTick: { show: false },
axisLabel: {
color: '#666',
fontSize: 14
}
},
series: [
{
name: '人数',
type: 'bar',
barWidth: 12, //
showBackground: true,
backgroundStyle: {
color: '#EDEDED',
borderRadius: 10
},
itemStyle: {
borderRadius: 10,
// 线 ()
color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{ offset: 0, color: '#A5C1FF' },
{ offset: 1, color: '#4D73FF' }
])
},
label: {
show: true,
position: 'top', //
distance: 5,
color: '#4D73FF',
fontWeight: 'bold',
formatter: '{c}'
},
data: data
}
]
};
myChart.setOption(optionThree);
//
window.addEventListener('resize', () => myChart.resize());
})
onUnmounted(() => {
window.removeEventListener('resize', handleResize);
myChartOne && myChartOne.dispose();
});
//
const accidentTypesWithPercent = computed(() => {
const total = accidentQuickDetect.value.totalToday
@ -540,18 +859,34 @@ const accidentList = ref([
<img class="img-jt" src="@/assets/images/erjititle.png" alt="区域交通概况" srcset="">
事故高发时段
</div>
<div>
<div class="chart-wrapper">
<v-chart class="chart" :option="optionNew" autoresize />
</div>
</div>
</div>
<div class="impact-item3">
<div class="title-Bottoms">
<img class="img-jt" src="@/assets/images/erjititle.png" alt="区域交通概况" srcset="">
事故高发路段TOP5
</div>
<div class="earchartconter">
<div ref="chartRefThree" class="earcsslThree"></div>
</div>
</div>
<div class="impact-item4">
<div class="title-Bottoms">
<img class="img-jt" src="@/assets/images/erjititle.png" alt="区域交通概况" srcset="">
处理时间与严重程度分析
</div>
<div class="earchartconter">
<!-- <div class="chart-header">
<div class="header-right">
平均处理时长<span class="avg-value">25</span> 分钟
</div>
</div> -->
<div ref="chartRefFre" class="earcsslThree"></div>
</div>
</div>
</div>
</div>
@ -741,6 +1076,13 @@ const accidentList = ref([
font-size: 14px;
}
/* 图表 2--------------------------------- */
.chart {
width: 400px;
height: 300px;
}
.type-percent {
font-size: 11px;
color: #94a3b8;
@ -910,6 +1252,12 @@ const accidentList = ref([
width: 300px;
height: 300px;
}
.earcsslThree{
width: 500px;
height: 300px;
}
.titlnew{
display: flex;
margin-left: 10px;
@ -1751,4 +2099,50 @@ img {
width: 100%;
display: block;
}
.chart-container {
padding: 20px;
background: #fff;
border-radius: 8px;
font-family: sans-serif;
}
.chart-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.header-left {
display: flex;
align-items: center;
}
.header-left .icon {
color: #4A90E2;
font-weight: bold;
margin-right: 10px;
letter-spacing: -2px;
}
.header-left .title {
font-size: 18px;
font-weight: bold;
color: #333;
}
.header-right {
font-size: 16px;
color: #333;
}
.avg-value {
font-size: 24px;
color: #4A90E2;
font-weight: bold;
margin-left: 5px;
}
</style>