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. 69
      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(() => {

69
src/components/szBar/index.vue

@ -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 = {
@ -99,7 +108,7 @@ export default {
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)'
}]) }])
@ -140,15 +149,15 @@ export default {
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',
@ -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