Browse Source

监听数据变化重渲染echarts

master
j1ack 3 years ago
parent
commit
2ebdc58b8c
  1. 8
      src/components/companySummary/business.vue
  2. 13
      src/components/companySummary/talent.vue
  3. 8
      src/components/ringPie/index.vue
  4. 8
      src/components/scrollArc/index.vue
  5. 117
      src/components/szBar/index.vue

8
src/components/companySummary/business.vue

@ -17,6 +17,14 @@ export default {
data() { data() {
return { return {
} }
},
watch: {
chartData: {
deep: true,
handler: function () {
this.getEchartLeft1()
}
}
}, },
mounted() { mounted() {
setTimeout(() => { setTimeout(() => {

13
src/components/companySummary/talent.vue

@ -38,12 +38,21 @@ export default {
name: "talent", name: "talent",
data() { data() {
return { return {
sum:0, sum: 0,
} }
}, },
created() { created() {
}, },
watch: {
chartData: {
deep: true,
handler: function () {
this.getEchartLeft2()
}
}
},
mounted() { mounted() {
setTimeout(() => { setTimeout(() => {
// console.log(this.chartData) // console.log(this.chartData)
@ -53,7 +62,7 @@ export default {
}, },
methods: { methods: {
GetPercent(num, total) { GetPercent(num, total) {
this.sum=this.chartData.alipayPayAmount+this.chartData.weixinPayAmount+this.chartData.casePayAmount+this.chartData.robotPayAmount+this.chartData.unionPayAmount this.sum = this.chartData.alipayPayAmount + this.chartData.weixinPayAmount + this.chartData.casePayAmount + this.chartData.robotPayAmount + this.chartData.unionPayAmount
num = parseFloat(num); num = parseFloat(num);
total = parseFloat(total); total = parseFloat(total);
if (isNaN(num) || isNaN(total)) { if (isNaN(num) || isNaN(total)) {

8
src/components/ringPie/index.vue

@ -49,6 +49,14 @@ export default {
this.shenRate=100-this.dataRate this.shenRate=100-this.dataRate
this.getEchart(); this.getEchart();
}, 800); }, 800);
},
watch: {
chartData: {
deep: true,
handler: function () {
this.getEchart()
}
}
}, },
methods: { methods: {
getEchart() { getEchart() {

8
src/components/scrollArc/index.vue

@ -38,6 +38,14 @@ export default {
dataIn: [], dataIn: [],
dataOut: [], dataOut: [],
} }
},
watch: {
chartData: {
deep: true,
handler: function () {
this.getEchart()
}
}
}, },
mounted() { mounted() {
setTimeout(() => { setTimeout(() => {

117
src/components/szBar/index.vue

@ -10,14 +10,14 @@
</div> </div>
</div> </div>
</div> --> </div> -->
<div class="income-container"> <div class="income-container">
<div class="chart" id="chart_bar"></div> <div class="chart" id="chart_bar"></div>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
chartData: { chartData: {
required: true, required: true,
}, },
@ -30,47 +30,56 @@ export default {
yData1: [], yData1: [],
} }
}, },
watch: {
chartData: {
deep: true,
handler: function () {
this.getEchart()
}
}
},
mounted() { mounted() {
setTimeout(() => { setTimeout(() => {
// console.log(this.chartData) // console.log(this.chartData)
for(var i= 0;i<this.chartData.inStatistics.length;i++){ for (var i = 0; i < this.chartData.inStatistics.length; i++) {
this.xAxisData.push(this.chartData.inStatistics[i].timeUnit) this.xAxisData.push(this.chartData.inStatistics[i].timeUnit)
this.yData1.push(this.chartData.inStatistics[i].num) this.yData1.push(this.chartData.inStatistics[i].num)
} }
this.getEchart(); this.getEchart();
}, 800); }, 800);
}, },
methods: { methods: {
getEchart() { getEchart() {
let myChart = echarts.init(document.getElementById('chart_bar')); let myChart = echarts.init(document.getElementById('chart_bar'));
let barWidth = '15%'; let barWidth = '15%';
let dataCoord = [ let dataCoord = [
{coord: [0, 9]}, { coord: [0, 9] },
{coord: [1, 12]}, { coord: [1, 12] },
{coord: [2, 15]}, { coord: [2, 15] },
{coord: [3, 18]}, { coord: [3, 18] },
{coord: [4, 15]}, { coord: [4, 15] },
{coord: [5, 12]}, { coord: [5, 12] },
{coord: [6, 9]}, { coord: [6, 9] },
{coord: [7, 12]}, { coord: [7, 12] },
{coord: [8, 15]}, { coord: [8, 15] },
{coord: [9, 18]}, { coord: [9, 18] },
{coord: [10, 15]}, { coord: [10, 15] },
{coord: [11, 12]}, { coord: [11, 12] },
]; ];
let dataCoord2 = [ let dataCoord2 = [
{coord: [0, -9]}, { coord: [0, -9] },
{coord: [1, -12]}, { coord: [1, -12] },
{coord: [2, -15]}, { coord: [2, -15] },
{coord: [3, -18]}, { coord: [3, -18] },
{coord: [4, -15]}, { coord: [4, -15] },
{coord: [5, -12]}, { coord: [5, -12] },
{coord: [6, -9]}, { coord: [6, -9] },
{coord: [7, -12]}, { coord: [7, -12] },
{coord: [8, -15]}, { coord: [8, -15] },
{coord: [9, -18]}, { coord: [9, -18] },
{coord: [10, -15]}, { coord: [10, -15] },
{coord: [11, -12]}, { coord: [11, -12] },
]; ];
this.option = { this.option = {
@ -82,7 +91,7 @@ export default {
}, },
axisTick: { axisTick: {
show: false show: false
}, },
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
@ -90,16 +99,16 @@ export default {
} }
}, },
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
showContent: true, showContent: true,
axisPointer: { axisPointer: {
type: 'shadow', type: 'shadow',
shadowStyle: { shadowStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 1, offset: 1,
color: '#5d83ff' color: '#5d83ff'
},{ }, {
offset: 0, offset: 0,
color: 'rgba(255, 255, 255, 0)' color: 'rgba(255, 255, 255, 0)'
}]) }])
@ -112,7 +121,7 @@ export default {
}, },
axisTick: { axisTick: {
show: false show: false
}, },
splitLine: { splitLine: {
show: false show: false
}, },
@ -138,23 +147,23 @@ export default {
itemStyle: { itemStyle: {
normal: { normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 1, offset: 1,
color: 'rgba(0, 0, 0, 0)' color: 'rgba(0, 0, 0, 0)'
},{ }, {
offset: 0.6, offset: 0.6,
color: '#466e71' color: '#466e71'
},{ }, {
offset: 0, offset: 0,
color: '#43FFFF' color: '#43FFFF'
}]), }]),
label: { label: {
position:"top", position: "top",
show: true, // show: true, //
textStyle: { // textStyle: { //
color: '#fff', color: '#fff',
fontSize: 10 fontSize: 10
} }
} }
} }
}, },
barWidth: barWidth, barWidth: barWidth,
@ -173,7 +182,7 @@ export default {
// }, // },
data: this.yData1 data: this.yData1
}, },
] ]
}; };
myChart.setOption(this.option, true); myChart.setOption(this.option, true);
@ -184,7 +193,7 @@ export default {
} }
}, },
beforeDestroy() { beforeDestroy() {
} }
}; };
</script> </script>
@ -195,11 +204,13 @@ export default {
height: 3rem; height: 3rem;
} }
} }
.sn-container { .sn-container {
left: 975px; left: 975px;
top: 690px; top: 690px;
width: 895px; width: 895px;
height: 400px; height: 400px;
.chartsdom { .chartsdom {
width: 100%; width: 100%;
height: 95%; height: 95%;

Loading…
Cancel
Save