Commit 09a0956f by 匡雅琴

大概布局

1 parent e48dbd15
......@@ -64,12 +64,12 @@ export default {
}
.text-box {
width: 126px;
height: 30px;
height: 29.5px;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 14px;
color: #FFFFFF;
line-height: 30px;
line-height: 29.5px;
padding-left: 2px;
background-image: linear-gradient(270deg, #6578ff00 0%, #5542ff87 53%, #0085CD 100%);
}
......
<template>
<div class="pie-box">
<div :id="id" :style="{ height: height }" class="pie-chart"></div>
<!-- <div class="center-content" :style="{ fontSize: size }">
<div :class="[id, 'center-content-num', 'center-content-num-color']"></div>
</div> -->
<!-- <div class="content-desc">
<div class="content-desc-icon" :style="{ background: descColor }"></div>
{{ numDesc }}
</div> -->
</div>
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'PieChartShadow',
props: {
id: {
type: String,
default: ''
},
keys: {
type: Array,
default: () => ['name', 'value']
},
height: {
type: String,
default: '8.54vh'
},
list: {
type: Array,
default: () => []
},
radius: {
type: Array,
default: () => ['60%', '89%']
},
colors: {
type: Array,
default: () => ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001']
},
size: {
type: String,
default: '0.6vw'
}
},
data() {
return {
option: '',
echartsPie: '',
mTime: '',
viewData: [],
text: '',
subtext: '',
currentIndex: -1,
mainValue: 0,
numDesc: '',
descColor: ''
}
},
watch: {
list: {
handler(newVal) {
if (newVal.length > 0) {
this.initData()
this.$nextTick(() => {
this.draw()
})
}
},
immediate: true
}
},
mounted() {},
methods: {
// 初始化数据
initData() {
const { list, keys } = this
this.viewData = []
list.forEach(item => {
this.viewData.push({
name: item[keys[0]],
value: item[keys[1]]
})
})
},
draw() {
if (this.mTime) clearInterval(this.mTime)
this.echartsPie = echarts.init(document.getElementById(this.id))
window.addEventListener('resize', () => {
this.echartsPie.resize()
})
// 指定图表的配置项和数据
this.option = {
// tooltip: {
// trigger: 'item'
// },
color: this.colors,
series: [
{
type: 'pie',
radius: this.radius,
center: ['50%', '50%'],
tooltip: {
show: false
},
itemStyle: {
normal: {
color: 'rgba(96, 148, 234, 0.5)'
}
},
label: {
normal: {
show: false
}
},
labelLine: {
normal: {
show: false
}
},
emphasis: {
label: {
show: true,
fontSize: this.size,
fontWeight: 'bold',
color: '#fff',
formatter: '{d}%'
}
},
data: [0]
},
{
name: '客户年龄分布',
type: 'pie',
radius: this.radius,
roseType: 'radius',
center: ['50%', '50%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: this.size,
fontWeight: 'bold',
color: '#fff',
formatter: '{d}%'
}
},
labelLine: {
show: false
},
data: this.viewData,
minAngle: 30
}
]
}
this.echartsPie.clear()
this.mainValue = 0
this.numDesc = ''
this.echartsPie.setOption(this.option)
// this.pieActive()
// this.mTime = setInterval(this.pieActive, 15000)
// // 鼠标划出
// this.echartsPie.on('mouseout', () => {
// if (this.mTime) clearInterval(this.mTime)
// this.mTime = setInterval(this.pieActive, 15000)
// })
// this.echartsPie.on('mouseover', data => {
// this.mainValue = data.data.value
// this.numDesc = data.data.name
// this.descColor = data.color
// // 停止定时器,清除之前的高亮
// clearInterval(this.mTime)
// this.currentIndex = data.dataIndex
// this.highlightPie()
// this.emitEvent(data.data)
// })
},
// 事件触发
emitEvent(data) {
this.echartsPie.setOption(this.option)
this.$emit('pieAction', data)
},
highlightPie() {
// 取消所有高亮并高亮当前图形
// 遍历饼图数据,取消所有图形的高亮效果
for (var idx in this.option.series[1].data) {
this.echartsPie.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: idx
})
}
// 高亮当前图形
this.echartsPie.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: this.currentIndex
})
this.descColor = this.option.color[this.currentIndex]
},
// 高亮
pieActive() {
const dataLen = this.option.series[1].data.length
this.currentIndex = (this.currentIndex + 1) % dataLen
this.highlightPie()
this.emitEvent(this.viewData[this.currentIndex])
}
}
}
</script>
<style lang="scss" scoped>
.pie-box {
// background: #262525;
position: relative;
flex: 1;
.center-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
max-width: 40%;
&-num-color {
color: #fff;
}
&-num {
// overflow: hidden;
// text-overflow: ellipsis;
// white-space: nowrap;
// font-size: 0.6vw;
--step: 0;
counter-reset: count var(--step);
z-index: var(--step);
transition: --step 0.5s;
&::before {
content: counter(count);
}
}
&-desc {
font-size: 0.5vw;
color: #606266;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
animation: rotateIn 3s infinite;
}
}
.content-desc {
display: flex;
align-items: center;
font-size: 8px;
color: #c8c8c8;
text-align: center;
font-weight: 400;
position: absolute;
top: 91%;
left: 50%;
transform: translateX(-50%);
text-align: center;
height: 14px !important;
white-space: nowrap;
&-icon {
width: 8px;
height: 4px;
border-radius: 2px;
margin-right: 4px;
}
}
}
@property --step {
syntax: '<integer>';
inherits: false;
initial-value: 15;
}
@keyframes rotateIn {
from {
transform: rotateY(0turn);
}
to {
transform: rotateY(-1turn);
}
}
</style>
......@@ -11,18 +11,22 @@
<PurchaseTrends></PurchaseTrends>
<div class="left-bottom">
<MerchantTrends class="bottom-trends"></MerchantTrends>
<div class="bottom-storage">ddd</div>
<div class="bottom-storage">
<StorageContent></StorageContent>
</div>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
import PurchaseTrends from './PurchaseTrends.vue'
import MerchantTrends from './MerchantTrends.vue'
import StorageContent from './StorageContent.vue'
export default {
name: 'ContentLeft',
components: {
PurchaseTrends,
MerchantTrends
MerchantTrends,
StorageContent
},
data() {
return {
......
<template>
<div class="storage-box">
<box-title title="入库使用情况"></box-title>
<pie-chart-shadow :id="chart.id" :list="listData" :height="chart.height"></pie-chart-shadow>
<Legend class="legend" :list="listData" :legentList="legentList" :colors="legendColors"></Legend>
</div>
</template>
<script>
export default {
name: 'StorageContent',
data() {
return {
chart: {
id: 'shadowPie',
height: '15.34vh'
},
listData: [
{
name: '已发货',
per: 0.36,
value: 1568
},
{
name: '未发货',
per: 0.25,
value: 4568
}
],
legentList: [
{
name: 'name'
},
{
name: 'per'
},
{
name: 'value'
}
]
}
},
mounted() {},
methods: {}
}
</script>
<style lang="scss" scoped>
.storage-box {
width: 19.72vw;
height: 32vh;
box-shadow: inset 0 0 20px 0 #3d57ff69;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!