diff --git a/src/components/DamageChart.vue b/src/components/DamageChart.vue index 459cfb2..efcf783 100644 --- a/src/components/DamageChart.vue +++ b/src/components/DamageChart.vue @@ -38,7 +38,7 @@ export default { } } - const optionGen = (stats, team) => { + const optionGen = (team) => { return { tooltip: { trigger: 'axis', @@ -66,7 +66,7 @@ export default { axisTick: { show: false }, - data: getPlayerArr(stats, team) + data: getPlayerArr(store.state.matchDetails.stats, team) } ], series: [ @@ -80,7 +80,7 @@ export default { emphasis: { focus: 'series' }, - data: dataArr(stats, team, 'team') + data: dataArr(store.state.matchDetails.stats, team, 'team') }, { name: 'Enemy', @@ -93,12 +93,14 @@ export default { emphasis: { focus: 'series' }, - data: dataArr(stats, team, 'enemy') + data: dataArr(store.state.matchDetails.stats, team, 'enemy') } ] } } + let myChart1, myChart2 + onMounted(() => { if (store.state.matchDetails.stats) { echarts.use([ @@ -109,13 +111,11 @@ export default { CanvasRenderer ]); - let myChart1 = echarts.init(document.getElementById('dmg-chart-1'), {}, {width: 1000, height: 300}); - let myChart2 = echarts.init(document.getElementById('dmg-chart-2'), {}, {width: 1000, height: 300}); - let option1 = optionGen(store.state.matchDetails.stats, 1) - let option2 = optionGen(store.state.matchDetails.stats, 2) + myChart1 = echarts.init(document.getElementById('dmg-chart-1'), {}, {width: 1000, height: 300}); + myChart2 = echarts.init(document.getElementById('dmg-chart-2'), {}, {width: 1000, height: 300}); - myChart1.setOption(option1); - myChart2.setOption(option2); + myChart1.setOption(optionGen(1)); + myChart2.setOption(optionGen(2)); } }) } diff --git a/src/components/FlashChart.vue b/src/components/FlashChart.vue index 9417775..1fcb204 100644 --- a/src/components/FlashChart.vue +++ b/src/components/FlashChart.vue @@ -85,7 +85,7 @@ export default { } } - let myChart1, myChart2, option1, option2 + let myChart1, myChart2 onMounted(() => { if (store.state.matchDetails.stats) { @@ -101,11 +101,9 @@ export default { myChart1 = echarts.init(document.getElementById('flash-chart-1'), {}, {width: 600, height: 400}); myChart2 = echarts.init(document.getElementById('flash-chart-2'), {}, {width: 600, height: 400}); - option1 = setOptions(1, color) - option2 = setOptions(2, color) - myChart1.setOption(option1); - myChart2.setOption(option2); + myChart1.setOption(setOptions(1, color)); + myChart2.setOption(setOptions(2, color)); } }) } diff --git a/src/components/MultiKillsChart.vue b/src/components/MultiKillsChart.vue index 969cd5c..a53daea 100644 --- a/src/components/MultiKillsChart.vue +++ b/src/components/MultiKillsChart.vue @@ -18,7 +18,7 @@ import {GridComponent, TooltipComponent, VisualMapComponent} from 'echarts/compo import {HeatmapChart} from 'echarts/charts'; import {CanvasRenderer} from 'echarts/renderers'; import {onMounted} from "vue"; -import {getPlayerArr, checkStatEmpty} from "../utils"; +import {checkStatEmpty, getPlayerArr} from "../utils"; import {useStore} from "vuex"; export default { @@ -119,20 +119,24 @@ export default { } } - onMounted(() => { - echarts.use([ - TooltipComponent, - GridComponent, - VisualMapComponent, - HeatmapChart, - CanvasRenderer - ]); + let myChart1, myChart2 - let myChart1 = echarts.init(document.getElementById('multi-kills-chart-1'), {}, {width: 500, height: 500}); - let myChart2 = echarts.init(document.getElementById('multi-kills-chart-2'), {}, {width: 500, height: 500}); + onMounted(() => { + if (store.state.matchDetails.stats) { + echarts.use([ + TooltipComponent, + GridComponent, + VisualMapComponent, + HeatmapChart, + CanvasRenderer + ]); + + myChart1 = echarts.init(document.getElementById('multi-kills-chart-1'), {}, {width: 500, height: 500}); + myChart2 = echarts.init(document.getElementById('multi-kills-chart-2'), {}, {width: 500, height: 500}); myChart1.setOption(optionGen(1)); myChart2.setOption(optionGen(2)); + } }) } }