Commit 8b606a3f by 王志慧

饼图

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