diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2018-06-12 21:57:04 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2018-12-13 17:09:17 +0100 |
| commit | 52fe2972daf40c462f9b4c9dbc02b87b86e8c67a (patch) | |
| tree | 4ce628bcddb74793681e9f461c17ca20e0d0be50 /src/WinPickScatter.vue | |
| parent | f221ce4c0d20a4980da85e8e050b380d77498fe3 (diff) | |
| download | brokentalents-52fe2972daf40c462f9b4c9dbc02b87b86e8c67a.tar.gz brokentalents-52fe2972daf40c462f9b4c9dbc02b87b86e8c67a.zip | |
Add 'Balance' Scatter Plot
Diffstat (limited to 'src/WinPickScatter.vue')
| -rw-r--r-- | src/WinPickScatter.vue | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/WinPickScatter.vue b/src/WinPickScatter.vue new file mode 100644 index 0000000..45106e6 --- /dev/null +++ b/src/WinPickScatter.vue @@ -0,0 +1,72 @@ +<template> + <div class="plotly" ref="graph"></div> +</template> + +<script> +import Vue from 'vue'; +import Plotly from 'plotly.js/lib/core'; +import ReportService from './ReportService'; +import RouterParamMixin from './RouterParamMixin'; +import * as maps from './maps/maps'; + +Plotly.register([ +]); + +export default Vue.component('win-pick-scatter', { + mixins: [ RouterParamMixin ], + mounted() { + this.refresh(); + window.addEventListener('resize', this.resize); + }, + watch: { + selectedMode() { + this.refresh(); + }, + selectedActor() { + this.refresh(); + }, + }, + methods: { + refresh() { + const data = ReportService.getReport(this.selectedMode); + const total = ReportService.getTotalMatches(this.selectedMode); + const dataWithRarity = (rarity) => data.filter((entry) => maps.getTalentRarity(entry.Talent) == rarity); + + const traces = maps.RARITIES.map((rarity) => ({ + x: dataWithRarity(rarity).map((entry) => entry.Winner), + y: dataWithRarity(rarity).map((entry) => maps.playersPerMatch(this.selectedMode) * entry.Count / total), + text: dataWithRarity(rarity).map((entry) => `${maps.getHero(entry.Actor)} ${rarity}`), + name: rarity, + mode: 'markers', + type: 'scatter', + })); + + this.plot = Plotly.newPlot(this.$refs.graph, traces, { + xaxis: { + title: 'Win Rate', + fixedrange: true, + tickformat: ',.0%', + }, + yaxis: { + title: 'Pick Rate', + fixedrange: true, + tickformat: ',.0%', + }, + margin: { t: 40, l: 40, b: 40, r: 40 }, + staticPlot: true, + }, { + displayModeBar: false + }); + }, + resize() { + Plotly.Plots.resize(this.$refs.graph); + }, + } +}); +</script> + +<style scoped> +.plotly { + height: 20em; +} +</style> |
