feat:完善功能

This commit is contained in:
zjc
2024-12-27 13:51:47 +08:00
parent c145b856d1
commit 02d5f4942d
10 changed files with 395 additions and 438 deletions

View File

@@ -13,58 +13,54 @@
watch(
() => homeData.value?.userPortrait?.ageRate,
() => {
init()
}
)
const init = () => {
setOption({
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
left: '60%',
y: 'center',
itemHeight: fitChartSize(8),
itemWidth: fitChartSize(8),
itemGap: fitChartSize(10),
formatter: function (name) {
return '{name|' + name + '}'
setOption({
tooltip: {
trigger: 'item'
},
textStyle: {
rich: {
name: {
color: '#fff',
fontSize: fitChartSize(14)
},
value: {
color: '#00D5F6',
fontSize: fitChartSize(14)
legend: {
orient: 'vertical',
left: '60%',
y: 'center',
itemHeight: fitChartSize(8),
itemWidth: fitChartSize(8),
itemGap: fitChartSize(10),
formatter: function (name) {
return '{name|' + name + '}'
},
textStyle: {
rich: {
name: {
color: '#fff',
fontSize: fitChartSize(14)
},
value: {
color: '#00D5F6',
fontSize: fitChartSize(14)
}
}
}
}
},
series: [
{
type: 'pie',
center: ['30%', '50%'],
radius: ['50%', '70%'],
itemStyle: {
borderColor: 'transparent',
borderRadius: fitChartSize(2),
borderWidth: fitChartSize(2)
},
label: {
show: false,
color: '#D3F0FE',
fontSize: fitChartSize(12)
},
data: homeData.value?.userPortrait?.ageRate || []
}
]
})
}
},
series: [
{
type: 'pie',
center: ['30%', '50%'],
radius: ['50%', '70%'],
itemStyle: {
borderColor: 'transparent',
borderRadius: fitChartSize(2),
borderWidth: fitChartSize(2)
},
label: {
show: false,
color: '#D3F0FE',
fontSize: fitChartSize(12)
},
data: homeData.value?.userPortrait?.ageRate || []
}
]
})
}
)
</script>
<style lang="scss" scoped>

View File

@@ -7,9 +7,10 @@
</Title1>
<div class="flex pt-20">
<div
v-for="(item, index) in homeData?.scenicSpot"
class="item"
:class="{ core: index == 0, queue: index == 1, congestion: index == 2 }"
v-for="(item, index) in homeData?.scenicSpot"
:key="index"
>
<span class="label">{{ item.name }}</span>
<div class="flex align-end">
@@ -146,9 +147,9 @@
<Title2 title="景区购票数" />
<div class="ticket-wrap">
<img src="@/assets/images/ticket.png" />
<div> <span class="label">当日购票量</span><countup endVal="768578" /> </div>
<div> <span class="label">未来3天购票量</span><countup endVal="768578" /> </div>
<div> <span class="label">3天后购票量</span><countup endVal="768578" /> </div>
<div v-for="(item, index) in homeData?.admission" :key="index">
<span class="label">{{ item.name }}</span><countup :end-val="item.value" />
</div>
</div>
</div>
@@ -157,8 +158,12 @@
<div class="box-1">
<Title3 title="年龄/性别占比" />
<age />
<div class="count">总人数<countup endVal="124563" /></div>
<div class="cell pt-20" v-for="item in homeData?.userPortrait.genderRate">
<div class="count">总人数<countup :end-val="ageRateTotal" /></div>
<div
class="cell pt-20"
v-for="(item, index) in homeData?.userPortrait.genderRate"
:key="index"
>
<img class="icon" src="@/assets/images/man.png" />
<div class="bg">
<span class="text">{{ item.name }}</span>
@@ -181,7 +186,7 @@
</div>
<div class="box-1">
<Title3 title="购票来源" />
<div class="count">总人数<countup endVal="124563" /></div>
<div class="count">总人数<countup :end-val="channelTotal" /></div>
<ticket />
</div>
</div>
@@ -196,6 +201,19 @@
import ticket from './ticket.vue'
const homeData = inject('homeData')
const ageRateTotal = computed(() => {
return homeData.value?.userPortrait.genderRate.reduce(
(total, current) => Number(current.count) + total,
0
)
})
const channelTotal = computed(() => {
return homeData.value?.userPortrait.channel.reduce(
(total, current) => Number(current.count) + total,
0
)
})
</script>
<style lang="scss" scoped>

View File

@@ -164,7 +164,7 @@
<div class="box-1">
<div class="pt-10">
<Title3 title="拥堵路段总数" />
<traffic-flow />
<traffic />
</div>
</div>
<div class="box-1">
@@ -188,7 +188,7 @@
<div class="car">
<div class="label">车总数</div>
<div class="flex align-center">
<countup class="value" :end-val="homeData?.carShipData.car.count" />
<countup class="value" :end-val="homeData?.carShipData?.car?.count || 0" />
<span class="unit"></span>
</div>
</div>
@@ -198,7 +198,7 @@
<div>调度</div>
<div>空余</div>
</div>
<div class="cell" v-for="item in homeData?.carShipData.car.info" :key="index">
<div class="cell" v-for="(item, index) in homeData?.carShipData?.car.info" :key="index">
<div>{{ item.scenic_area }}</div>
<div>{{ item.started_count }}<span class="unit-1"></span></div>
<div>{{ item.not_started_count }}<span class="unit-1"></span></div>
@@ -209,7 +209,7 @@
<div class="ship">
<div class="label">车总数</div>
<div class="flex align-center">
<countup class="value" :end-val="homeData?.carShipData.ship.count" />
<countup class="value" :end-val="homeData?.carShipData?.ship?.count || 0" />
<span class="unit"></span>
</div>
<div class="table">
@@ -259,7 +259,7 @@
</div>
</div>
<div>
<div class="lodging">
<div class="occupancy">
<Title3 title="酒店入住人数及入住率" />
</div>
<occupancy />
@@ -273,7 +273,7 @@
import jam from './jam.vue'
import vacancy from './vacancy.vue'
import occupancy from './occupancy.vue'
import TrafficFlow from './traffic-flow.vue'
import traffic from './traffic.vue'
import countup from 'vue-countup-v3'
import icon1 from '@/assets/images/icon-1.png'
import icon2 from '@/assets/images/icon-2.png'
@@ -519,7 +519,7 @@
}
}
}
.lodging {
.occupancy {
:deep(.title-3) {
margin-top: vh(10);
}

View File

@@ -1,174 +1,161 @@
<template>
<div class="lodging-ratio" id="lodging-ratio" />
<div class="lodging-ratio" :id="id" />
</template>
<script setup>
import { fitChartSize } from '@/utils/dataUtil'
import * as echarts from 'echarts'
import { useEchart } from '@/hooks/echart'
let topChart = null
let result = [
{ name: '酒店1', value: 86 },
{ name: '酒店2', value: 83 },
{ name: '酒店3', value: 73 }
]
let option = {
backgroundColor: 'transparent',
tooltip: {
show: false
},
legend: {
show: false
},
grid: {
left: '4%',
right: '4%',
top: '20%',
bottom: '-10%',
containLabel: true
},
xAxis: [{ max: 100, show: false }],
yAxis: [
{
splitLine: {
const { id, setOption } = useEchart()
const homeData = inject('homeData')
watch(
() => homeData.value?.hotelData?.list,
() => {
setOption({
backgroundColor: 'transparent',
tooltip: {
show: false
},
axisLine: {
legend: {
show: false
},
type: 'category',
axisTick: {
show: false
grid: {
left: '4%',
right: '4%',
top: '20%',
bottom: '-10%',
containLabel: true
},
data: result.map((item) => item.name),
axisLabel: {
show: false
}
},
{
type: 'category',
axisTick: 'none',
axisLine: 'none',
show: true,
axisLabel: {
textStyle: {
color: '#fff',
fontSize: fitChartSize(12)
},
verticalAlign: 'bottom',
padding: [0, 0, fitChartSize(6), 0],
inside: true,
formatter: function (value) {
return `{value|${value}}`
},
rich: {
name: {
align: 'center',
color: '#D3E5FF',
fontSize: fitChartSize(14),
fontFamily: 'Source Han Sans CN'
xAxis: [{ max: 100, show: false }],
yAxis: [
{
splitLine: {
show: false
},
value: {
align: 'center',
color: '#fff',
fontSize: fitChartSize(14),
fontFamily: 'Source Han Sans CN'
axisLine: {
show: false
},
type: 'category',
axisTick: {
show: false
},
data: homeData.value?.hotelData?.list.map((item) => item.hotel_name),
axisLabel: {
show: false
}
}
},
data: result.map((item) => item.value)
}
],
series: [
{
name: '',
type: 'bar',
barWidth: fitChartSize(4),
MaxSize: 0,
showBackground: true,
barBorderRadius: [30, 0, 0, 30],
backgroundStyle: {
color: 'rgba(0, 150, 255, 0.15)'
},
label: {
show: true,
offset: [fitChartSize(10), -fitChartSize(20)],
color: '#D3E5FF',
fontWeight: 500,
position: 'left',
align: 'left',
fontSize: fitChartSize(14),
fontFamily: 'Source Han Sans CN',
formatter: function (params) {
return params.data.name
}
},
data: result.map((item, index) => {
return {
name: item.name,
value: item.value,
itemStyle: {
barBorderRadius: [3, 0, 0, 3],
color: {
type: 'linear',
x: 0,
y: 0,
x2: 1,
y2: 1,
colorStops: [
{
offset: 0,
color: 'rgba(255, 112, 33, 0)'
},
{
offset: 1,
color: 'rgba(255, 112, 33, 1)'
}
]
},
{
type: 'category',
axisTick: 'none',
axisLine: 'none',
show: true,
axisLabel: {
textStyle: {
color: '#fff',
fontSize: fitChartSize(12)
},
verticalAlign: 'bottom',
padding: [0, 0, fitChartSize(6), 0],
inside: true,
formatter: function (value) {
return `{value|${value}}`
},
rich: {
name: {
align: 'center',
color: '#D3E5FF',
fontSize: fitChartSize(14),
fontFamily: 'Source Han Sans CN'
},
value: {
align: 'center',
color: '#fff',
fontSize: fitChartSize(14),
fontFamily: 'Source Han Sans CN'
}
}
}
},
data: homeData.value?.hotelData?.list.map((item) => item.occupancy_rate)
}
})
},
{
name: '外圆',
type: 'scatter',
emphasis: {
scale: false
},
showSymbol: true,
symbol: 'circle',
symbolSize: fitChartSize(10),
z: 2,
data: result.map((item, index) => {
return {
name: item.name,
value: item.value,
itemStyle: {
color: '#fff',
opacity: 1
}
],
series: [
{
name: '',
type: 'bar',
barWidth: fitChartSize(4),
MaxSize: 0,
showBackground: true,
barBorderRadius: [30, 0, 0, 30],
backgroundStyle: {
color: 'rgba(0, 150, 255, 0.15)'
},
label: {
show: true,
offset: [fitChartSize(10), -fitChartSize(20)],
color: '#D3E5FF',
fontWeight: 500,
position: 'left',
align: 'left',
fontSize: fitChartSize(14),
fontFamily: 'Source Han Sans CN',
formatter: function (params) {
return params.data.name
}
},
data: homeData.value?.hotelData?.list.map((item) => {
return {
name: item.hotel_name,
value: item.occupancy_rate,
itemStyle: {
barBorderRadius: [3, 0, 0, 3],
color: {
type: 'linear',
x: 0,
y: 0,
x2: 1,
y2: 1,
colorStops: [
{
offset: 0,
color: 'rgba(255, 112, 33, 0)'
},
{
offset: 1,
color: 'rgba(255, 112, 33, 1)'
}
]
}
}
}
})
},
{
name: '外圆',
type: 'scatter',
emphasis: {
scale: false
},
showSymbol: true,
symbol: 'circle',
symbolSize: fitChartSize(10),
z: 2,
data: homeData.value?.hotelData?.list.map((item) => {
return {
name: item.hotel_name,
value: item.occupancy_rate,
itemStyle: {
color: '#fff',
opacity: 1
}
}
}),
animationDelay: 500
}
}),
animationDelay: 500
}
]
}
const init = () => {
topChart = echarts.init(document.getElementById('lodging-ratio'))
topChart.setOption(option)
}
const resize = () => {
if (topChart) {
topChart.dispose()
topChart = null
init()
]
})
}
}
onMounted(() => {
init()
window.addEventListener('resize', resize)
})
)
</script>
<style scoped lang="scss">

View File

@@ -1,190 +1,73 @@
<template>
<div class="ticket" id="ticket" />
<div class="ticket" :id="id" />
</template>
<script setup>
import { fitChartSize } from '@/utils/dataUtil'
import * as echarts from 'echarts'
import { useEchart } from '@/hooks/echart'
let ticketChart = null
var qxzbData = [
{
name: '处理中',
value: 500,
full: 1000 // 最大值
},
{
name: '超期中',
value: 756,
full: 1000
},
{
name: '延期中',
value: 800,
full: 1000
}
]
var returnData = function (qxzbData, name) {
for (var a = 0; a < qxzbData.length; a++) {
if (qxzbData[a].name == name) {
return qxzbData[a].value
}
}
}
let option = {
backgroundColor: 'transparent',
tooltip: {
trigger: 'item',
formatter: function (rsp) {
if (rsp.name != '') {
return rsp.name + '<br/>' + rsp.marker + ' ' + rsp.value + ' ' + rsp.percent + ''
}
}
},
legend: {
x: 'center',
y: 'bottom',
data: qxzbData,
itemHeight: fitChartSize(8),
itemWidth: fitChartSize(8),
itemGap: fitChartSize(20),
formatter: function (name) {
return '{title|' + name + '} {value|' + returnData(qxzbData, name) + '}'
},
textStyle: {
rich: {
title: {
color: '#fff',
fontSize: fitChartSize(14)
const { id, setOption } = useEchart()
const homeData = inject('homeData')
let x = 15
let y = 25
watch(
() => homeData.value?.userPortrait?.channel,
() => {
setOption({
backgroundColor: 'transparent',
legend: {
x: 'center',
y: 'bottom',
itemHeight: fitChartSize(8),
itemWidth: fitChartSize(8),
itemGap: fitChartSize(20),
formatter: function (name) {
return '{title|' + name + '}'
},
value: {
color: '#00D5F6',
fontSize: fitChartSize(14)
}
}
}
},
color: ['#F15A25', '#01FEFE', '#12B5FD'],
series: [
{
name: qxzbData[0].name, //最里面的圈
type: 'pie',
clockWise: false, //顺时加载
radius: ['15%', '25%'],
center: ['50%', '40%'],
label: {
normal: {
show: false
}
},
labelLine: {
show: false
},
itemStyle: {
emphasis: {
show: false
}
},
data: [
{
value: qxzbData[0].value,
name: qxzbData[0].name
},
{
value: qxzbData[0].full,
itemStyle: {
normal: {
color: '#07439C'
textStyle: {
rich: {
title: {
color: '#fff',
fontSize: fitChartSize(14)
},
value: {
color: '#00D5F6',
fontSize: fitChartSize(14)
}
}
}
]
},
{
name: qxzbData[1].name, //第二个圈
type: 'pie',
clockWise: false, //顺时加载
radius: ['30%', '40%'],
center: ['50%', '40%'],
label: {
normal: {
show: false
}
},
labelLine: {
show: false
},
itemStyle: {
emphasis: {
show: false
}
},
data: [
{
value: qxzbData[1].value,
name: qxzbData[1].name
},
{
value: qxzbData[1].full,
itemStyle: {
normal: {
color: '#07439C'
color: ['#F15A25', '#01FEFE', '#12B5FD'],
series: homeData.value?.userPortrait?.channel.map((item, index) => {
return {
name: item.name,
type: 'pie',
clockwise: false, //顺时加载
radius: [`${x * (index + 1)}%`, `${y + index * 15}%`],
center: ['50%', '40%'],
label: { show: false },
labelLine: { show: false },
emphasis: { show: false },
data: [
{
value: parseFloat(item.value),
name: item.name
},
{
value: 100,
itemStyle: {
color: '#07439C'
}
}
}
]
}
]
},
{
name: qxzbData[2].name, //最外层圈
type: 'pie',
clockWise: false, //顺时加载
radius: ['45%', '55%'],
center: ['50%', '40%'],
label: {
normal: {
show: false
}
},
labelLine: {
show: false
},
itemStyle: {
emphasis: {
show: false
}
},
data: [
{
value: qxzbData[2].value,
name: qxzbData[2].name
},
{
value: qxzbData[2].full,
itemStyle: {
normal: {
color: '#07439C'
}
}
}
]
}
]
}
const init = () => {
ticketChart = echarts.init(document.getElementById('ticket'))
ticketChart.setOption(option)
window.addEventListener('resize', resize)
}
const resize = () => {
if (ticketChart) {
ticketChart.dispose()
ticketChart = null
init()
})
})
}
}
onMounted(() => {
init()
})
)
</script>
<style scoped lang="scss">

View File

@@ -10,13 +10,6 @@
const homeData = inject('homeData')
watch(
() => homeData.value?.userPortrait?.provinceRate,
() => {
init()
}
)
const init = () => {
setOption({
backgroundColor: 'transparent',
@@ -138,6 +131,13 @@
]
})
}
watch(
() => homeData.value?.userPortrait?.provinceRate,
() => {
init()
}
)
</script>
<style scoped lang="scss">

View File

@@ -1,54 +1,77 @@
<template>
<div class="select-box">
<Select v-model="params.id" :options="options" @on-change="initChart" />
</div>
<div class="area" :id="id" />
</template>
<script setup>
import { useEchart } from '@/hooks/echart'
import { fitChartSize } from '@/utils/dataUtil'
import { getAreaApi } from '@/api/sentiment.js'
import { getAreaApi, getSpotApi } from '@/api/sentiment.js'
const { id, setOption } = useEchart()
let params = reactive({ id: '' })
let option = null
let options = ref([])
const initChart = async () => {
let res = await getAreaApi()
setOption({
legend: {
top: 'top',
itemWidth: fitChartSize(30),
itemHeight: fitChartSize(30),
textStyle: {
fontSize: fitChartSize(14),
color: '#fff'
}
},
series: [
{
name: 'Nightingale Chart',
type: 'pie',
radius: ['30%', '60%'],
center: ['50%', '56%'],
roseType: 'area',
labelLine: {
normal: {
show: true,
length: 1
}
},
itemStyle: {
borderRadius: fitChartSize(10)
},
data: res.data
}
]
})
let res = await getAreaApi(params)
if (option) {
option.series[0].data = res.data
} else {
option = {
legend: {
top: '10%',
itemWidth: fitChartSize(20),
itemHeight: fitChartSize(20),
textStyle: {
color: '#fff',
fontSize: fitChartSize(20)
}
},
series: [
{
name: '',
type: 'pie',
radius: ['30%', '60%'],
center: ['50%', '56%'],
roseType: 'area',
labelLine: {
normal: {
show: true,
length: 1
}
},
itemStyle: {
borderRadius: fitChartSize(10)
},
data: res.data
}
]
}
}
setOption(option)
}
const getStop = async () => {
let res = await getSpotApi()
options.value = res.data
}
onMounted(() => {
getStop()
initChart()
})
</script>
<style scoped lang="scss">
.select-box {
position: absolute;
z-index: 9999;
top: vh(40);
right: vw(10);
}
.area {
width: vw(740);
width: vw(840);
height: vh(400);
}
</style>

View File

@@ -38,7 +38,9 @@
<div class="flex mt-10">
<div class="box-2 mr-10 rela">
<Title1 title="舆情指数" />
<div class="dropdown"> <Dropdown :options="options" @on-change="onChange" /> </div>
<div class="select-box">
<Select v-model="params.id" :options="options" @on-change="getLineChart" />
</div>
<Line
:width="1560"
:height="400"
@@ -47,7 +49,7 @@
:seriesConfig="{ smooth: false, symbol: 'circle' }"
/>
</div>
<div class="box-1 mr-10">
<div class="box-1 mr-10 rela">
<Title1 title="地域分析" />
<Area />
</div>
@@ -80,9 +82,8 @@
let unsensitive = ref(0)
let stateList = ref([])
let options = ref([])
const onChange = (e) => {
getLineChart(e.id)
}
let params = reactive({ id: '' })
const getStop = async () => {
let res = await getSpotApi()
options.value = res.data
@@ -97,8 +98,8 @@
let res = await getStateApi()
stateList.value = res.data
}
const getLineChart = async (id) => {
let res = await getLineChartApi({ id })
const getLineChart = async () => {
let res = await getLineChartApi(params)
xAxisData.value = res.data.data
seriesData.value = res.data.series
}
@@ -116,9 +117,10 @@
</script>
<style scoped lang="scss">
.dropdown {
.select-box {
position: absolute;
z-index: 9999;
top: vh(10);
right: vw(10);
}
.container {