Browse Source

page3

master
xuhuajiao 1 year ago
parent
commit
ab97588273
  1. BIN
      src/assets/images/circle-bg.png
  2. 97
      src/assets/styles/index.scss
  3. 32
      src/components/echart/barEcharts.vue
  4. 2
      src/main.js
  5. 162
      src/utils/mixins.js
  6. 15
      src/views/index.vue
  7. 27
      src/views/map/index.vue
  8. 1
      src/views/pageOne/index.vue
  9. 154
      src/views/pageThree/index.vue
  10. 206
      src/views/pageThree/module/todayCircle.vue
  11. 206
      src/views/pageThree/module/yearCircle.vue

BIN
src/assets/images/circle-bg.png

After

Width: 132  |  Height: 131  |  Size: 16 KiB

97
src/assets/styles/index.scss

@ -266,9 +266,7 @@
background: url('~@/assets/images/database-icon2.png') no-repeat left top;
background-size: 100% 100%;
}
}
.flop-figure {
.flop-figure {
position: relative;
display: inline-block;
width: .275rem;
@ -289,9 +287,8 @@
-webkit-text-fill-color: transparent;
text-shadow: 0 2px 8px rgba(5,28,55,0.42);
}
}
.pageLeft-flop-box {
}
.pageLeft-flop-box {
position: relative;
height: .325rem;
margin-top: .125rem;
@ -331,12 +328,16 @@
color: #A8CBF6;
height: .375rem;
}
}
.flop-item-name{
}
.flop-item-name{
font-size: .1875rem;
}
}
// 左边进度条
.pageOne-left-progress{
display: flex;
@ -699,7 +700,9 @@
}
}
}
.lending-ranking{
}
.lending-ranking{
padding: 0 .2625rem 0 .425rem;
h5{
font-size: .225rem;
@ -767,7 +770,6 @@
}
}
}
}
}
.tooltip-main{
position: relative;
@ -833,4 +835,79 @@
.database-title{
width: 6.0375rem;
}
.three-lending{
display: flex;
justify-content: space-between;
padding: .1875rem .3125rem 0 .4125rem;
h5{
font-size: .2rem;
color: #47A6FF;
}
.three-lending-left{
.totalItem{
.pageLeft-flop-box{
position: relative;
height: .9125rem;
margin: .2875rem 0 .4rem 0;
overflow: hidden;
& div:first-child {
height: .9125rem;
overflow: hidden;
display: flex;
align-items: center;
justify-content: flex-start;
}
.flop-figure {
position: relative;
display: inline-block;
width: .675rem;
height: 100%;
line-height: .625rem;
padding: .125rem 0;
overflow: hidden;
writing-mode: vertical-lr;
text-orientation: upright;
background: rgba(13,145,214,0.25);
margin-right: .1625rem;
border: 2px solid #0D79FF;
border-radius: .05rem;
i {
font-size: .6rem;
font-weight: 600;
position: absolute;
text-align: center;
transition: transform 0.6s ease-in-out;
color: #BFE0FF;
}
}
}
}
}
.three-lending-right{
width: 5.25rem;
h5{
position: relative;
padding-left: .2rem;
&::before{
content: "";
position: absolute;
left: 0;
top: 50%;
width: .0625rem;
height: .2rem;
background-color: #47A6FF;
transform: translateY(-50%);
}
}
.ranking-cont{
padding-bottom: .125rem;
.ranking-list{
.ranking-progress .el-progress{
width: 1.25rem;
}
}
}
}
}
}

32
src/components/echart/barEcharts.vue

@ -137,6 +137,31 @@ export default {
name: {}
}
}
// //
// var today = new Date()
// //
// var startDayOfWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - today.getDay() + 1)
// //
// var xAxisData = []
// for (var i = 0; i < 7; i++) {
// xAxisData.push(new Date(startDayOfWeek.getFullYear(), startDayOfWeek.getMonth(), startDayOfWeek.getDate() + i).toLocaleDateString())
// }
//
function getLastWeekDates() {
var dates = []
var today = new Date()
for (var i = 0; i < 7; i++) {
var day = new Date(today - i * 24 * 60 * 60 * 1000)
var dayOfWeek = day.getDay()
if (dayOfWeek === 0) {
day.setTime(day.getTime() - 5 * 24 * 60 * 60 * 1000)
}
dates.unshift(day.toLocaleDateString())
}
return dates
}
option = {
tooltip: {
trigger: 'axis',
@ -180,7 +205,7 @@ export default {
xAxis: [{
type: 'category',
axisTick: { show: false },
data: this.storageData.storageMonths,
data: getLastWeekDates(),
axisLine: { // 线
lineStyle: {
color: '#113D72'
@ -190,10 +215,7 @@ export default {
show: true,
textStyle: {
color: '#fff'
},
formatter: this.storageData.storageMonths.map(function(item) {
return item
})
}
},
splitLine: { // 线
lineStyle: {

2
src/main.js

@ -13,6 +13,8 @@ import '@/common/flexible.js'
import './assets/js/rollSlide.js'
import './assets/js/tagcloud-2.2.js'
import './utils/mixins'
// 引入全局css
import './assets/fonts/fonts.css'
import './assets/iconfont/iconfont.js'

162
src/utils/mixins.js

@ -0,0 +1,162 @@
import Vue from 'vue'
Vue.mixin({
methods: {
// 错误
$LoopShowTooltip(chart, chartOption, options) {
const defaultOptions = {
interval: 2000,
loopSeries: false,
seriesIndex: 0,
updateData: null
}
if (!chart || !chartOption) {
return {}
}
let dataIndex = 0 // 数据索引,初始化为-1,是为了判断是否是第一次执行
let seriesIndex = 0 // 系列索引
let timeTicket = 0
const seriesLen = chartOption.series.length // 系列个数
let dataLen = 0 // 某个系列数据个数
let chartType // 系列类型
let first = true
// 不循环series时seriesIndex指定显示tooltip的系列,不指定默认为0,指定多个则默认为第一个
// 循环series时seriesIndex指定循环的series,不指定则从0开始循环所有series,指定单个则相当于不循环,指定多个
// 要不要添加开始series索引和开始的data索引?
if (options) {
options.interval = options.interval || defaultOptions.interval
options.loopSeries = options.loopSeries || defaultOptions.loopSeries
options.seriesIndex = options.seriesIndex || defaultOptions.seriesIndex
options.updateData = options.updateData || defaultOptions.updateData
} else {
options = defaultOptions
}
// 如果设置的seriesIndex无效,则默认为0
if (options.seriesIndex < 0 || options.seriesIndex >= seriesLen) {
seriesIndex = 0
} else {
seriesIndex = options.seriesIndex
}
function autoShowTip() {
function showTip() {
// 判断是否更新数据
if (dataIndex === 0 && !first && typeof options.updateData === 'function') {
options.updateData()
chart.setOption(chartOption)
}
const series = chartOption.series
chartType = series[seriesIndex].type // 系列类型
dataLen = series[seriesIndex].data.length // 某个系列的数据个数
const tipParams = { seriesIndex: seriesIndex }
switch (chartType) {
case 'map':
case 'pie':
case 'chord':
tipParams.name = series[seriesIndex].data[dataIndex].name
break
case 'radar': // 雷达图
tipParams.seriesIndex = seriesIndex
tipParams.dataIndex = dataIndex
break
default:
tipParams.dataIndex = dataIndex
break
}
if (chartType === 'pie' || chartType === 'radar') {
// 取消之前高亮的图形
chart.dispatchAction({
type: 'downplay',
seriesIndex: options.loopSeries ? (seriesIndex === 0 ? seriesLen - 1 : seriesIndex - 1) : seriesIndex,
dataIndex: dataIndex === 0 ? dataLen - 1 : dataIndex - 1
})
// 高亮当前图形
chart.dispatchAction({
type: 'highlight',
seriesIndex: seriesIndex,
dataIndex: dataIndex
})
}
// 显示 tooltip
tipParams.type = 'showTip'
chart.dispatchAction(tipParams)
dataIndex = (dataIndex + 1) % dataLen
if (options.loopSeries && dataIndex === 0 && !first) { // 数据索引归0表示当前系列数据已经循环完
seriesIndex = (seriesIndex + 1) % seriesLen
}
first = false
}
showTip()
timeTicket = setInterval(showTip, options.interval)
}
// 关闭轮播
function stopAutoShow() {
if (timeTicket) {
clearInterval(timeTicket)
timeTicket = 0
if (chartType === 'pie' || chartType === 'radar') {
// 取消高亮的图形
chart.dispatchAction({
type: 'downplay',
seriesIndex: options.loopSeries ? (seriesIndex === 0 ? seriesLen - 1 : seriesIndex - 1) : seriesIndex,
dataIndex: dataIndex === 0 ? dataLen - 1 : dataIndex - 1
})
}
}
}
const zRender = chart.getZr()
function zRenderMouseMove(param) {
if (param.event) {
// 阻止canvas上的鼠标移动事件冒泡
param.event.cancelBubble = true
}
stopAutoShow()
}
// 离开echarts图时恢复自动轮播
function zRenderGlobalOut() {
if (!timeTicket) {
autoShowTip()
}
}
// 鼠标在echarts图上时停止轮播
chart.on('mousemove', stopAutoShow)
zRender.on('mousemove', zRenderMouseMove)
zRender.on('globalout', zRenderGlobalOut)
autoShowTip()
return {
clearLoop: function() {
if (timeTicket) {
clearInterval(timeTicket)
timeTicket = 0
}
chart.off('mousemove', stopAutoShow)
zRender.off('mousemove', zRenderMouseMove)
zRender.off('globalout', zRenderGlobalOut)
}
}
}
}
})

15
src/views/index.vue

@ -41,7 +41,7 @@ export default {
},
data() {
return {
active: 3,
active: 1,
isLoading: false,
fullscreen: false,
height: '',
@ -87,7 +87,7 @@ export default {
clearInterval(this.timer2)
window.removeEventListener('resize', this.setElementHeight)
})
// this.autoPagination()
this.autoPagination()
},
methods: {
autoPagination() {
@ -161,20 +161,31 @@ export default {
let leftTimer
let middleTimer
let deviceTimer
let todayTimer
let yearTimer
if (type === 'middle') {
middleTimer = this.initInterval2(targetList, 8000)
} else if (type === 'left') {
leftTimer = this.initInterval(targetList, 10000)
} else if (type === 'device') {
deviceTimer = this.initInterval(targetList, 8000)
} else if (type === 'todayTotal') {
todayTimer = this.initInterval(targetList, 8000)
} else if (type === 'yearTotal') {
yearTimer = this.initInterval(targetList, 10000)
}
this.$once('hook:beforeDestroy', () => {
clearInterval(leftTimer)
clearInterval(middleTimer)
clearInterval(deviceTimer)
clearInterval(todayTimer)
clearInterval(yearTimer)
middleTimer = null
leftTimer = null
deviceTimer = null
todayTimer = null
yearTimer = null
})
},
setNumberTransform2(item) {

27
src/views/map/index.vue

@ -56,19 +56,19 @@
<h5>借阅Top10</h5>
<div class="ranking-cont">
<ul class="ranking-title">
<li style="width: 0.725rem;">排名</li>
<li style="width: 0.8125rem;">姓名</li>
<li style="width: 0.8rem;">排名</li>
<li style="width: 1.5rem; text-align: left; padding-left: 0.25rem;">姓名</li>
<li style="flex:1;" />
<li style="width: 1.375rem;">借阅次数</li>
<li style="width: 1.75rem; text-align: right; padding-right: .375rem;">借阅次数</li>
</ul>
<ul class="ranking-list">
<li v-for="(item,index) in rankingWithPercentage" :key="index">
<div style="width: 0.725rem; color: #79B8FF;" :class="[{'ranking-num1':index===0},{'ranking-num2':index===1},{'ranking-num3':index===2}]">{{ index>=3 ? index+1 : null }}</div>
<div style="width: 0.8125rem;">{{ item.name }}</div>
<div class="ranking-progress" style="flex:1; margin-left: 0.125rem; align-self: center;">
<div style="width: 1rem; color: #79B8FF;" :class="[{'ranking-num1':index===0},{'ranking-num2':index===1},{'ranking-num3':index===2}]">{{ index>=3 ? index+1 : null }}</div>
<div style="width: 1.5rem; text-align: left; padding-left: .25rem;">{{ item.name }}</div>
<div class="ranking-progress" style="flex:1; align-self: center;">
<el-progress :percentage="item.percentage" :stroke-width="8" :show-text="false" color="#009afb" />
</div>
<div style="width: 1.375rem;">{{ item.num }}<i></i></div>
<div style="width: 1.75rem; text-align: right; padding-right: .375rem;">{{ item.num }}<i></i></div>
</li>
</ul>
</div>
@ -137,7 +137,7 @@ export default {
{ id: 6, num: 140, name: '胡图图' },
{ id: 7, num: 120, name: '胡图图' },
{ id: 8, num: 100, name: '胡图图' },
{ id: 9, num: 70, name: '胡图图' },
{ id: 9, num: 70, name: '胡1' },
{ id: 10, num: 60, name: '胡图图' }
],
rankingWithPercentage: []
@ -168,8 +168,17 @@ export default {
methods: {
rankingDataComputed() {
const firstPlaceNum = this.rankingData[0].num
this.rankingWithPercentage = this.rankingData.map(item => {
if (item.name.length === 2) {
// name
item.name = item.name.substring(0, 1) + ' * '
} else if (item.name.length === 3) {
//
item.name = item.name.substring(0, 1) + ' * ' + item.name.substring(2, 3)
} else if (item.name.length > 3) {
// 4
item.name = item.name.substring(0, 1) + ' * ' + ' * ' + item.name.substring(3, item.name.length)
}
const percentage = (item.num / firstPlaceNum) * 100
return { ...item, percentage }
})

1
src/views/pageOne/index.vue

@ -224,7 +224,6 @@ export default {
multicolour: false // true(),false
})
},
initDataPreview() {
//
const previewData = {

154
src/views/pageThree/index.vue

@ -3,9 +3,95 @@
<div class="page-three">
<div class="three-item three01">
<div class="database-title">本年累计借阅数量</div>
<div class="three-lending">
<div class="three-lending-left">
<h5>本年累计借阅</h5>
<ul class="totalItem">
<li
v-for="(item, index) in yearTotal"
:key="index"
:class="[{'yearTotal': item.id === 'yearTotal'}]"
>
<div class="pageLeft-flop-box">
<div>
<span v-for="(ls, i) in item.valueArr" :key="item.id + i" :class="[{'flop-figure': !isNaN(ls)}, {'flop-comma': isNaN(ls)}]">
<i v-if="!isNaN(ls)">0123456789</i>
<!-- <span v-else>{{ ls }}</span> -->
</span>
</div>
</div>
</li>
</ul>
<YearCircle />
</div>
<div class="three-lending-right lending-ranking">
<h5>分馆累计借阅排行榜</h5>
<div class="ranking-cont">
<ul class="ranking-title">
<li style="width: 0.725rem;">排名</li>
<li style="width: 1.5rem; text-align: left;">学院名称</li>
<li style="flex:1;" />
<li style="width: 1.25rem; padding-right: .25rem; text-align: right;">借阅数量</li>
</ul>
<ul class="ranking-list">
<li v-for="(item,index) in rankingWithPercentage" :key="index">
<div style="width: 0.725rem; color: #79B8FF;" :class="[{'ranking-num1':index===0},{'ranking-num2':index===1},{'ranking-num3':index===2}]">{{ index>=3 ? index+1 : null }}</div>
<div style="width: 1.5rem; text-align: left;">{{ item.name }}</div>
<div class="ranking-progress" style="flex:1; align-self: center;">
<el-progress :percentage="item.percentage" :stroke-width="8" :show-text="false" color="#009afb" />
</div>
<div style="width: 1.25rem; padding-right: .25rem; text-align: right;">{{ item.num }}<i style="padding-left:.0625rem;"></i></div>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="three-item three02">
<div class="database-title">今日借阅数量</div>
<div class="three-lending">
<div class="three-lending-left">
<h5>今日累计借阅</h5>
<ul class="totalItem">
<li
v-for="(item, index) in todayTotal"
:key="index"
:class="[{'todayTotal': item.id === 'todayTotal'}]"
>
<div class="pageLeft-flop-box">
<div>
<span v-for="(ls, i) in item.valueArr" :key="item.id + i" :class="[{'flop-figure': !isNaN(ls)}, {'flop-comma': isNaN(ls)}]">
<i v-if="!isNaN(ls)">0123456789</i>
<!-- <span v-else>{{ ls }}</span> -->
</span>
</div>
</div>
</li>
</ul>
<TodayCircle />
</div>
<div class="three-lending-right lending-ranking">
<h5>分馆今日借阅排行榜 </h5>
<div class="ranking-cont">
<ul class="ranking-title">
<li style="width: 0.725rem;">排名</li>
<li style="width: 1.5rem; text-align: left;">学院名称</li>
<li style="flex:1;" />
<li style="width: 1.25rem; padding-right: .25rem; text-align: right;">借阅数量</li>
</ul>
<ul class="ranking-list">
<li v-for="(item,index) in rankingWithPercentage" :key="index">
<div style="width: 0.725rem; color: #79B8FF;" :class="[{'ranking-num1':index===0},{'ranking-num2':index===1},{'ranking-num3':index===2}]">{{ index>=3 ? index+1 : null }}</div>
<div style="width: 1.5rem; text-align: left;">{{ item.name }}</div>
<div class="ranking-progress" style="flex:1; align-self: center;">
<el-progress :percentage="item.percentage" :stroke-width="8" :show-text="false" color="#009afb" />
</div>
<div style="width: 1.25rem; padding-right: .25rem; text-align: right;">{{ item.num }}<i style="padding-left:.0625rem;"></i></div>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="three-item three03">
<div class="database-title">今日借阅趋势</div>
@ -26,10 +112,14 @@
<script>
import LineChartService from '@/components/echart/lineChartService'
import BarEcharts from '@/components/echart/barEcharts'
import YearCircle from './module/yearCircle'
import TodayCircle from './module/todayCircle'
export default {
components: {
LineChartService,
BarEcharts
BarEcharts,
YearCircle,
TodayCircle
},
data() {
return {
@ -38,24 +128,68 @@ export default {
borrowedData: [20, 182, 191, 234, 290, 330]
},
storageData: {
storageMonths: ['05-13', '05-14', '05-15', '05-16', '05-17', '05-18', '05-19'],
inStorageData: [220, 132, 10, 134, 90, 230, 80],
outStorageData: [20, 182, 191, 234, 290, 330, 30]
}
inStorageData: [60, 92, 10, 68, 90, 76, 80],
outStorageData: [20, 82, 191, 134, 90, 56, 30]
},
rankingData: [
{ id: 1, num: 718, name: '少儿图书馆' },
{ id: 2, num: 447, name: '大村店分馆' },
{ id: 3, num: 261, name: '邵家岭分馆' },
{ id: 4, num: 242, name: '复兴路分馆' },
{ id: 5, num: 165, name: '白竹湖分馆' },
{ id: 6, num: 140, name: '资源环境学院' }
],
rankingWithPercentage: [],
todayTotal: [],
yearTotal: []
}
},
computed: {
},
created() {
},
beforeDestroy() {
clearTimeout(this.timer2)
},
mounted() {
this.rankingDataComputed()
this.initDataPreview()
},
methods: {
rankingDataComputed() {
const firstPlaceNum = this.rankingData[0].num
this.rankingWithPercentage = this.rankingData.map(item => {
const percentage = (item.num / firstPlaceNum) * 100
return { ...item, percentage }
})
},
initDataPreview() {
//
const previewData = {
'code': 0,
'data': {
'allYearNumCount': 35877,
'allUserOpenNumCount': 2200
},
'message': 'success'
}
if (previewData.code !== 0) return
this.todayTotal = []
this.yearTotal = []
this.todayTotal.push({
id: 'todayTotal',
name: '今日累计借阅',
value: this.$parent.formatter(previewData.data.allUserOpenNumCount),
valueArr: this.$parent.formatter(previewData.data.allUserOpenNumCount).split('')
})
this.yearTotal.push({
id: 'yearTotal',
name: '本年累计借阅',
value: this.$parent.formatter(previewData.data.allYearNumCount),
valueArr: this.$parent.formatter(previewData.data.allYearNumCount).split('')
})
setTimeout(() => {
this.$parent.timedRefresh(this.todayTotal, 'todayTotal')
this.$parent.timedRefresh(this.yearTotal, 'yearTotal')
}, 1000)
}
}
}

206
src/views/pageThree/module/todayCircle.vue

@ -0,0 +1,206 @@
<template>
<div style="height: calc(100% - 200px); display: flex; align-items: center; justify-content: flex-start;">
<div id="todayType" style="width:400px; height: 230px" />
</div>
</template>
<script>
export default {
components: {
},
data() {
return {
}
},
computed: {
},
created() {
},
beforeDestroy() {
},
mounted() {
this.initTodayCircle()
},
methods: {
initTodayCircle() {
const yearAllnum = {
'code': 0,
'data': {
'headerLib': 588,
'branchLib': 60
},
'message': 'success'
}
if (yearAllnum.code !== 0) return
const optionData = [
{ value: yearAllnum.data.headerLib || 0, name: '总馆' },
{ value: yearAllnum.data.branchLib || 0, name: '分馆' }
]
const myChart = this.$echarts.init(document.getElementById('todayType'))
function arrCount(arr) {
let count = 0
arr.forEach(item => {
count = count + item.value
})
return count
}
var centerImg = require('@/assets/images/circle-bg.png')
const option = {
tooltip: {
trigger: 'item',
position: 'bottom'
// backgroundColor: 'rgba(74, 144, 226, 0.84)',
// formatter: (params) => {
// return `<div>${params.seriesName} <br> ${params.data.name}${this.$parent.formatter(params.data.value)} (${params.percent}%)</div>`
// }
},
legend: {
orient: 'vertical',
right: 70,
top: 55,
// textStyle: {
// color: '#EEF6FF',
// padding: [20, 0, 18, 4],
// fontSize: '14'
// },
itemWidth: 10,
itemHeight: 10,
icon: 'circle',
selectedMode: false,
data: ['总馆', '分馆'],
formatter: (name) => {
// `${name} ${((flag.value / count).toFixed(2)) * 100 + '%'}`
const count = arrCount(optionData)
if (optionData) {
const flag = optionData?.find(item => name === item.name)
if (flag) return [`{name|${name}}`, `{num|${((flag.value / count).toFixed(2)) * 100 + '%'}}`]
} else return name
},
textStyle: {
rich: {
name: {
fontSize: 14,
color: '#EEF6FF',
padding: [20, 0, 20, 4]
},
num: {
fontSize: 16,
fontWeight: 600,
padding: [20, 0, 20, 15],
color: '#4C90FF'
}
}
}
// formatter: function(name) {
// let tarValue
// const count = arrCount(optionData)
// for (let i = 0; i < optionData.length; i++) {
// if (data[i].name === name) {
// tarValue = data[i].value
// }
// }
// return [`{name|${name}}`, `{num|${((tarValue / count).toFixed(2)) * 100 + '%'}}`].join('\n')
// }
},
// ()
graphic: [
{
type: 'image',
id: 'logo',
left: '8.5%', //
top: '22%', //
z: -10,
bounding: 'raw',
rotation: 0, //
origin: [64.5, 32.5], //
scale: [1.0, 1.0], //
//
style: {
image: centerImg,
width: 132,
height: 131,
opacity: 1
}
}
],
series: [
{
name: '今日累计借阅',
type: 'pie',
left: '-50%',
radius: ['60%', '70%'],
avoidLabelOverlap: false,
label: {
show: false,
position: 'center'
},
labelLine: {
show: true
},
itemStyle: {
borderWidth: 2,
borderColor: 'rgba(16,16,21,0.4)'
},
emphasis: {
label: {
show: true,
// params
formatter: function(params) {
const { value, name } = params
return [
`{c| ${value}}`,
`{b| ${name}}`
].join('\n') //
},
rich: {
c: {
fontSize: 24,
fontWeight: 600,
color: '#317FFF',
// color: {
// type: 'linear',
// x: 0,
// y: 0,
// x2: 0,
// y2: 1,
// colorStops: [
// {
// offset: 0,
// color: 'red' // 0%
// },
// {
// offset: 1,
// color: 'yellow' // 100%
// }
// ],
// globalCoord: false // false
// },
lineHeight: 34
},
b: {
fontSize: 14,
color: '#fff'
}
}
}
},
color: ['#317FFF', '#31DFFF'],
data: optionData
}
]
}
myChart.setOption(option)
this.$LoopShowTooltip(myChart, option, { loopSeries: true, interval: 4000 })
}
}
}
</script>
<style lang="scss">
@import "~@/assets/styles/index.scss";
@import "~@/assets/styles/font-some.css";
</style>

206
src/views/pageThree/module/yearCircle.vue

@ -0,0 +1,206 @@
<template>
<div style="height: calc(100% - 200px); display: flex; align-items: center; justify-content: flex-start;">
<div id="modelType" style="width:400px; height: 230px" />
</div>
</template>
<script>
export default {
components: {
},
data() {
return {
}
},
computed: {
},
created() {
},
beforeDestroy() {
},
mounted() {
this.initYearCircle()
},
methods: {
initYearCircle() {
const yearAllnum = {
'code': 0,
'data': {
'headerLib': 45585,
'branchLib': 15445
},
'message': 'success'
}
if (yearAllnum.code !== 0) return
const optionData = [
{ value: yearAllnum.data.headerLib || 0, name: '总馆' },
{ value: yearAllnum.data.branchLib || 0, name: '分馆' }
]
const myChart = this.$echarts.init(document.getElementById('modelType'))
function arrCount(arr) {
let count = 0
arr.forEach(item => {
count = count + item.value
})
return count
}
var centerImg = require('@/assets/images/circle-bg.png')
const option = {
tooltip: {
trigger: 'item',
position: 'bottom'
// backgroundColor: 'rgba(74, 144, 226, 0.84)',
// formatter: (params) => {
// return `<div>${params.seriesName} <br> ${params.data.name}${this.$parent.formatter(params.data.value)} (${params.percent}%)</div>`
// }
},
legend: {
orient: 'vertical',
right: 70,
top: 55,
// textStyle: {
// color: '#EEF6FF',
// padding: [20, 0, 18, 4],
// fontSize: '14'
// },
itemWidth: 10,
itemHeight: 10,
icon: 'circle',
selectedMode: false,
data: ['总馆', '分馆'],
formatter: (name) => {
// `${name} ${((flag.value / count).toFixed(2)) * 100 + '%'}`
const count = arrCount(optionData)
if (optionData) {
const flag = optionData?.find(item => name === item.name)
if (flag) return [`{name|${name}}`, `{num|${((flag.value / count).toFixed(2)) * 100 + '%'}}`]
} else return name
},
textStyle: {
rich: {
name: {
fontSize: 14,
color: '#EEF6FF',
padding: [20, 0, 20, 4]
},
num: {
fontSize: 16,
fontWeight: 600,
padding: [20, 0, 20, 15],
color: '#4C90FF'
}
}
}
// formatter: function(name) {
// let tarValue
// const count = arrCount(optionData)
// for (let i = 0; i < optionData.length; i++) {
// if (data[i].name === name) {
// tarValue = data[i].value
// }
// }
// return [`{name|${name}}`, `{num|${((tarValue / count).toFixed(2)) * 100 + '%'}}`].join('\n')
// }
},
// ()
graphic: [
{
type: 'image',
id: 'logo',
left: '8.5%', //
top: '22%', //
z: -10,
bounding: 'raw',
rotation: 0, //
origin: [64.5, 32.5], //
scale: [1.0, 1.0], //
//
style: {
image: centerImg,
width: 132,
height: 131,
opacity: 1
}
}
],
series: [
{
name: '本年累计借阅',
type: 'pie',
left: '-50%',
radius: ['60%', '70%'],
avoidLabelOverlap: false,
label: {
show: false,
position: 'center'
},
labelLine: {
show: true
},
itemStyle: {
borderWidth: 2,
borderColor: 'rgba(16,16,21,0.4)'
},
emphasis: {
label: {
show: true,
// params
formatter: function(params) {
const { value, name } = params
return [
`{c| ${value}}`,
`{b| ${name}}`
].join('\n') //
},
rich: {
c: {
fontSize: 24,
fontWeight: 600,
color: '#317FFF',
// color: {
// type: 'linear',
// x: 0,
// y: 0,
// x2: 0,
// y2: 1,
// colorStops: [
// {
// offset: 0,
// color: 'red' // 0%
// },
// {
// offset: 1,
// color: 'yellow' // 100%
// }
// ],
// globalCoord: false // false
// },
lineHeight: 34
},
b: {
fontSize: 14,
color: '#fff'
}
}
}
},
color: ['#317FFF', '#31DFFF'],
data: optionData
}
]
}
myChart.setOption(option)
this.$LoopShowTooltip(myChart, option, { loopSeries: true, interval: 4000 })
}
}
}
</script>
<style lang="scss">
@import "~@/assets/styles/index.scss";
@import "~@/assets/styles/font-some.css";
</style>
Loading…
Cancel
Save