Commit 8b606a3f by 王志慧

饼图

1 parent 0ad6cad3
...@@ -5,14 +5,13 @@ html, ...@@ -5,14 +5,13 @@ html,
body .app { body .app {
color: #333333; color: #333333;
font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif; font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif;
background-color: #FFF; background-color: #fff;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
height: 100%; height: 100%;
// overflow: hidden; // overflow: hidden;
--themeColor: #3975C6; --themeColor: #3975c6;
} }
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -72,14 +71,14 @@ img { ...@@ -72,14 +71,14 @@ img {
} }
.box { .box {
background: #1D1C1C; background: #1d1c1c;
} }
.inline { .inline {
display: inline-block; display: inline-block;
} }
.title { .title {
font-size: 12px; font-size: 12px;
color: #E8E8E8; color: #e8e8e8;
line-height: 2.1vh; line-height: 2.1vh;
font-weight: 400; font-weight: 400;
padding: 0.5vh 8px; padding: 0.5vh 8px;
...@@ -92,9 +91,14 @@ img { ...@@ -92,9 +91,14 @@ img {
display: inline-block; display: inline-block;
width: 4px; width: 4px;
height: 4px; height: 4px;
background: #EB6001; background: #eb6001;
box-shadow: 0px 0px 5px 5px rgba(255,104,0,0.3); box-shadow: 0px 0px 5px 5px rgba(255, 104, 0, 0.3);
border-radius: 1px; border-radius: 1px;
margin-right: 6px; margin-right: 6px;
} }
} }
.container {
// margin: 0.5vh 0.6vw 1vh 0.6vw;
// height:14.1vh;
// box-sizing: border-box;
}
<template> <template>
<div class="pie-box"> <div class="pie-box" >
<div id="pie-chart" class="pie-chart"></div> <div :id="id" :style="{ width: width, height: height }" class="pie-chart"></div>
</div> </div>
</template> </template>
...@@ -10,10 +10,22 @@ export default { ...@@ -10,10 +10,22 @@ export default {
name: 'PieChart', name: 'PieChart',
props: { props: {
id: {
type: String,
default: ''
},
keys: { keys: {
type: Array, type: Array,
default: () => ['name', 'number'] default: () => ['name', 'number']
}, },
height: {
type: String,
default: '12.7vh'
},
width: {
type: String,
default: '7.2vw'
},
list: { list: {
type: Array, type: Array,
default: () => [ default: () => [
...@@ -23,14 +35,25 @@ export default { ...@@ -23,14 +35,25 @@ export default {
{ number: 484, name: 'Union Ads' }, { number: 484, name: 'Union Ads' },
{ number: 300, name: 'Video Ads' } { number: 300, name: 'Video Ads' }
] ]
},
radius: {
type: Array,
default: () => ['55%', '72%']
},
colors: {
type: Array,
default: () => ['#4FA0FF', '#7CFFB2', '#FDF006', '#EB6001', '#F5AA01', '#BF98FF', '#58D9F9']
} }
}, },
data() { data() {
return { return {
option: '',
echartsPie: '', echartsPie: '',
mTime: '', mTime: '',
viewData: [] viewData: [],
text: '',
subtext: ''
} }
}, },
...@@ -39,7 +62,8 @@ export default { ...@@ -39,7 +62,8 @@ export default {
}, },
mounted() { mounted() {
this.echartsPie = echarts.init(document.getElementById('pie-chart')) let id = this.id
this.echartsPie = echarts.init(document.getElementById(id))
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.echartsPie.resize() this.echartsPie.resize()
}) })
...@@ -59,33 +83,21 @@ export default { ...@@ -59,33 +83,21 @@ export default {
}, },
draw() { draw() {
// 指定图表的配置项和数据 // 指定图表的配置项和数据
const option = { this.option = {
tooltip: { // tooltip: {
trigger: 'item' // trigger: 'item'
},
// color: ['#289df5', '#ff5050'],
// graphic: {
// type: 'text',
// left: 'center',
// top: '40%',
// style: {
// text: '运动达标率',
// textAlign: 'center',
// fill: '#333',
// fontSize: 20,
// fontWeight: 700
// }
// }, // },
color: this.colors,
title: { title: {
text: '主标题', text: this.text,
// 副标题 // 副标题
subtext: '50%', subtext: this.subtext,
// 主副标题间距 // 主副标题间距
itemGap: 40, itemGap: 5,
x: 'center', x: 'center',
y: 'center', y: 'center',
top: '280', top: '50',
// 主标题样式 // 主标题样式
textStyle: { textStyle: {
fontSize: '12', fontSize: '12',
...@@ -104,7 +116,7 @@ export default { ...@@ -104,7 +116,7 @@ export default {
{ {
name: '客户年龄分布', name: '客户年龄分布',
type: 'pie', type: 'pie',
radius: ['55%', '70%'], radius: this.radius,
center: ['50%', '50%'], center: ['50%', '50%'],
avoidLabelOverlap: false, avoidLabelOverlap: false,
label: { label: {
...@@ -125,17 +137,29 @@ export default { ...@@ -125,17 +137,29 @@ export default {
labelLine: { labelLine: {
show: false show: false
}, },
animationType: 'scale',
animationEasing: 'elasticOut',
animationDurationUpdate: 3000,
animationTypeUpdate: 'transition',
animation: true,
data: this.viewData data: this.viewData
} }
] ]
} }
this.echartsPie.setOption(option) this.echartsPie.setOption(this.option)
this.pieActive() this.pieActive()
// 鼠标划出 // 鼠标划出
this.echartsPie.on('mouseout', () => { this.echartsPie.on('mouseout', () => {
this.pieActive() this.pieActive()
}) })
}, },
// 事件触发
emitEvent(data) {
this.text = data.name
this.subtext = data.value
this.echartsPie.setOption(this.option)
this.$emit('pieAction', data)
},
//高亮 //高亮
pieActive() { pieActive() {
let index = -1 //高亮所在下标 let index = -1 //高亮所在下标
...@@ -159,9 +183,10 @@ export default { ...@@ -159,9 +183,10 @@ export default {
if (index > dataLength) { if (index > dataLength) {
index = 0 index = 0
} }
this.emitEvent(this.viewData[index])
}, 2000) }, 2000)
// 鼠标划入 // 鼠标划入
this.echartsPie.on('mouseover', () => { this.echartsPie.on('mouseover', data => {
// 停止定时器,清除之前的高亮 // 停止定时器,清除之前的高亮
clearInterval(this.mTime) clearInterval(this.mTime)
this.echartsPie.dispatchAction({ this.echartsPie.dispatchAction({
...@@ -169,6 +194,9 @@ export default { ...@@ -169,6 +194,9 @@ export default {
seriesIndex: 0, seriesIndex: 0,
dataIndex: index dataIndex: index
}) })
console.log('mouseover')
console.log(data)
this.emitEvent(data.data)
}) })
} }
} }
...@@ -177,10 +205,8 @@ export default { ...@@ -177,10 +205,8 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.pie-box { .pie-box {
height: 14vh; background: #262525;
.pie-chart { .pie-chart {
flex: 1;
height: 100%;
} }
} }
</style> </style>
<template>
<div class="ranking-container">
<div class="title">品牌排名</div>
<div class="ranking">
<div class="brand flex" v-for="(item, index) in 5" :key="index">
<span class="brand-num">{{ index + 1 }}</span>
<marquee class="marquee" :direction="directionTimer" :delay="delayTimer" :text="text" />
</div>
</div>
</div>
</template>
<script>
export default {
name: 'RanKing',
data() {
return {
delayTimer: 3000,
directionTimer: 3000,
text: '丰田丰田丰田丰田丰田'
}
}
}
</script>
<style lang="scss" scoped>
.ranking-container {
margin-left:0.6vw;
box-sizing: border-box;
.title {
width: 6.7vw;
background: rgba(53, 53, 53, 0.6);
font-size: 10px;
color: #eb6001;
font-weight: 400;
text-align: center;
line-height: 2.4vh;
}
.ranking {
background: #262525;
font-size: 10px;
color: #ffffff;
letter-spacing: 0;
font-weight: 400;
padding-left: 0.6vw;
.brand {
line-height: 1.9vh;
height: 1.9vh;
.brand-num {
color: #606266;
margin-right:0.6vw;
}
.marquee {
width: calc(100% - 2.2vw);
height: 2.1vh;
}
}
}
}
</style>
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<view-tabs /> <view-tabs />
<view-pie-group> <view-pie-group>
<div slot="1"><Age :height="defaultHeight"></Age></div> <div slot="1"><Age :height="defaultHeight"></Age></div>
<div slot="2"><BuyCar :height="defaultHeight"></BuyCar></div> <div slot="2"><Sex :height="defaultHeight"></Sex></div>
<div slot="3"><Sex :height="defaultHeight"></Sex></div> <div slot="3"><BuyCar :height="defaultHeight"></BuyCar></div>
</view-pie-group> </view-pie-group>
</div> </div>
<div class="bottom"> <div class="bottom">
......
...@@ -11,14 +11,22 @@ ...@@ -11,14 +11,22 @@
<span class="icon"></span> <span class="icon"></span>
<span>客户年龄分布</span> <span>客户年龄分布</span>
</div> </div>
<div> <div class="container flex">
<pie-chart></pie-chart> <pie-chart :id="chart.id"></pie-chart>
<ran-king></ran-king>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'Age' name: 'Age',
data() {
return {
chart: {
id: 'age-pie'
}
}
}
} }
</script> </script>
...@@ -11,11 +11,22 @@ ...@@ -11,11 +11,22 @@
<span class="icon"></span> <span class="icon"></span>
<span>客户购车年限</span> <span>客户购车年限</span>
</div> </div>
<div class="flex">
<pie-chart :id="chart.id"></pie-chart>
<ran-king></ran-king>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'BuyCar' name: 'BuyCar',
data(){
return {
chart: {
id: 'car-pie'
}
}
}
} }
</script> </script>
...@@ -11,10 +11,21 @@ ...@@ -11,10 +11,21 @@
<span class="icon"></span> <span class="icon"></span>
<span>客户性别</span> <span>客户性别</span>
</div> </div>
<div class="flex">
<pie-chart :id="chart.id"></pie-chart>
<ran-king></ran-king>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'Sex' name: 'Sex',
data() {
return {
chart: {
id: 'sex-pie'
}
}
}
} }
</script> </script>
...@@ -11,11 +11,22 @@ ...@@ -11,11 +11,22 @@
<span class="icon"></span> <span class="icon"></span>
<span>客户级别</span> <span>客户级别</span>
</div> </div>
<div class="flex container">
<pie-chart :id="chart.id"></pie-chart>
<ran-king></ran-king>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'CustomerCategory' name: 'CustomerCategory',
data() {
return {
chart: {
id: 'customerCategory-pie'
}
}
}
} }
</script> </script>
...@@ -11,11 +11,22 @@ ...@@ -11,11 +11,22 @@
<span class="icon"></span> <span class="icon"></span>
<span>进店类型</span> <span>进店类型</span>
</div> </div>
<div class="flex">
<pie-chart :id="chart.id"></pie-chart>
<ran-king></ran-king>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'EnterCategory' name: 'EnterCategory',
data() {
return {
chart: {
id: 'enterCategory-pie'
}
}
}
} }
</script> </script>
...@@ -11,11 +11,22 @@ ...@@ -11,11 +11,22 @@
<span class="icon"></span> <span class="icon"></span>
<span>信息来源</span> <span>信息来源</span>
</div> </div>
<div class="flex">
<pie-chart :id="chart.id"></pie-chart>
<ran-king></ran-king>
</div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'InfoFrom' name: 'InfoFrom',
data() {
return {
chart: {
id: 'infoFrom-pie'
}
}
}
} }
</script> </script>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!