Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format numbers for better readability #896

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions GW2EIBuilders/Resources/JS/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

var numberComponent = {
methods: {
// https://stackoverflow.com/questions/16637051/adding-space-between-numbers
integerWithSpaces: function(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
formatNumber: function(x) {
return x.toLocaleString("fr").replace(",", "."); // french formatting uses spaces for thousands
},
round: function (value) {
if (isNaN(value) || !isFinite(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
},
methods: {
tableRound: function (value) {
return this.graphdata.damagemode == GraphType.Breakbar ? this.round1(value) : this.round(value)
return this.formatNumber(this.graphdata.damagemode == GraphType.Breakbar ? this.round1(value) : this.round(value));
},
sortBy: function (key, index) {
this.sortByBase(this.sortdata, key, index);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="d-flex flex-column justify-content-center align-items-center">
<div class="target-status" :style="{'background': getHPGradient(time, status)}" @click="select" :title="target.name + ' - ' + target.health + ' health'">
<div class="target-status" :style="{'background': getHPGradient(time, status)}" @click="select" :title="target.name + ' - ' + formatNumber(target.health) + ' health'">
<h6 class="actor-shorten-cr text-center">
<img v-for="(marker, index) in activeMarkers()" :src="marker.imageUrl" height="16" width="16">
<img :src="target.icon" height="18" width="18"/>
Expand All @@ -26,6 +26,7 @@ <h6 class="actor-shorten-cr text-center">

<script>
Vue.component("combat-replay-target-status-component", {
mixins: [numberComponent],
props: ["targetindex", "time"],
template: `${template}`,
methods: {
Expand Down
10 changes: 9 additions & 1 deletion GW2EIBuilders/Resources/ei.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function compileTemplates() {
template: '<div :id="id" class="d-flex flex-row justify-content-center"></div>',
activated: function () {
var div = document.querySelector(this.queryID);
Plotly.react(div, this.data, this.layout, { showEditInChartStudio: true, plotlyServerURL: "https://chart-studio.plotly.com" });
Plotly.react(div, this.data, this.layout, { locale: "custom", showEditInChartStudio: true, plotlyServerURL: "https://chart-studio.plotly.com" });
var _this = this;
div.on('plotly_animated', function () {
Plotly.relayout(div, _this.layout);
Expand Down Expand Up @@ -277,6 +277,14 @@ function mainLoad() {

window.onload = function () {
Vue.config.devtools = true;
Plotly.register({
moduleType: "locale",
name: "custom",
format: {
decimal: ".",
thousands: " "
}
});
// trick from
var img = document.createElement("img");
img.style.display = "none";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@
<td :class="getBodyClass('Data', 0)">
{{ round3(100*getBarrierOutput(row)/barrierdist.contributedBarrier) }}%
</td>
<td :class="getBodyClass('Data', 1)" :data-original-title="round2(getBarrierOutput(row)/phase.durationS) +' hps'">
{{ getBarrierOutput(row) }}
<td :class="getBodyClass('Data', 1)" :data-original-title="formatNumber(round2(getBarrierOutput(row)/phase.durationS)) +' hps'">
{{ formatNumber(getBarrierOutput(row)) }}
</td>
<td :class="getBodyClass('Data', 2)">
{{ getMinBarrier(row) }}
{{ formatNumber(getMinBarrier(row)) }}
</td>
<td :class="getBodyClass('Data', 3)">
{{ round(getBarrierOutput(row)/getConnectedHits(row)) }}
{{ formatNumber(round(getBarrierOutput(row)/getConnectedHits(row))) }}
</td>
<td :class="getBodyClass('Data', 4)">
{{ getMaxBarrier(row) }}
{{ formatNumber(getMaxBarrier(row)) }}
</td>
<td :class="getCastBodyClass('Data', 5, row)" v-if="actor !== null">
{{ (!getSkill(row).condi && getCast(row)) ? getCast(row) : ''}}
Expand Down Expand Up @@ -162,7 +162,7 @@
<td class="text-left">Total</td>
<td></td>
<td :data-original-title="Math.round(barrierdist.contributedBarrier/phase.durationS) +' hps'">
{{barrierdist.contributedBarrier}}
{{ formatNumber(barrierdist.contributedBarrier) }}
</td>
<td></td>
<td></td>
Expand All @@ -171,7 +171,7 @@
<td></td>
<td v-if="actor !== null"></td>
<td v-if="actor !== null">
{{round2(barrierdist.contributedBarrier/(0.001 * barrierdist.totalCasting))}}
{{ formatNumber(round2(barrierdist.contributedBarrier/(0.001 * barrierdist.totalCasting))) }}
</td>
<td v-if="actor !== null"></td>
<td v-if="actor !== null"></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,19 @@
{{ round3(100*getHealingOutput(row)/healingdist.contributedHealing) }}%
</td>
<td :class="getBodyClass('Data', 1)" :data-original-title="round2(getHealingOutput(row)/phase.durationS) +' hps'">
{{ getHealingOutput(row) }}
{{ formatNumber(getHealingOutput(row)) }}
</td>
<td :class="getBodyClass('Data', 2)" :data-original-title="round2(getDownedHealingOutput(row)/phase.durationS) +' hps'">
{{ getDownedHealingOutput(row) }}
{{ formatNumber(getDownedHealingOutput(row)) }}
</td>
<td :class="getBodyClass('Data', 3)">
{{ getMinHealing(row) }}
{{ formatNumber(getMinHealing(row)) }}
</td>
<td :class="getBodyClass('Data', 4)">
{{ round(getHealingOutput(row)/getConnectedHits(row)) }}
{{ formatNumber(round(getHealingOutput(row)/getConnectedHits(row))) }}
</td>
<td :class="getBodyClass('Data', 5)">
{{ getMaxHealing(row) }}
{{ formatNumber(getMaxHealing(row)) }}
</td>
<td :class="getCastBodyClass('Data', 6, row)" v-if="actor !== null">
{{ (!getSkill(row).condi && getCast(row)) ? getCast(row) : ''}}
Expand All @@ -145,7 +145,7 @@
{{(!getSkill(row).condi && getConnectedHits(row) && getCast(row)) ? round2(getConnectedHits(row)/getCast(row)) : ''}}
</td>
<td :class="getBodyClass('Data', 9)" v-if="actor !== null">
{{(!getSkill(row).condi && getConnectedHits(row) && getCastDuration(row)) ? round2(getHealingOutput(row)/(0.001 * getCastDuration(row))) : ''}}
{{(!getSkill(row).condi && getConnectedHits(row) && getCastDuration(row)) ? formatNumber(round2(getHealingOutput(row)/(0.001 * getCastDuration(row)))) : ''}}
</td>
<td :class="getBodyClass('Data', 12)" v-if="actor !== null" >
{{ getCastDurationNoInterrupt(row) ? round3(0.001 * getMinCastingTimeNoInterrupt(row)) + 's': ' '}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{{row.player.acc}}
</td>
<td v-for="(value, index) in row.incomingHeal" :class="getBodyClass('Data', index)">
{{value}}
{{ formatNumber(value) }}
</td>
</tr>
</tbody>
Expand All @@ -68,7 +68,7 @@
</td>
<td></td>
<td v-for="(value, index) in sum.incomingHeal">
{{value}}
{{ formatNumber(value) }}
</td>
</tr>
</tfoot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@
{{row.player.acc}}
</td>
<td v-if="!showHealing" v-for="(value, index) in row.hps" :class="getBodyClass('Data', index)"
:data-original-title="value + ' total' + '<br>' + computeTotalContribution(index, row.hps,tableData.sums)+ '<br>'+ computeGroupContribution(row.player.group, index, row.hps,tableData.sums)">
{{round(value/phase.durationS)}}
:data-original-title="formatNumber(value) + ' total' + '<br>' + computeTotalContribution(index, row.hps,tableData.sums)+ '<br>'+ computeGroupContribution(row.player.group, index, row.hps,tableData.sums)">
{{ formatNumber(round(value/phase.durationS)) }}
</td>
<td v-if="showHealing" v-for="(value, index) in row.hps" :class="getBodyClass('Data', index)"
:data-original-title="round(value/phase.durationS) + ' per second' + '<br>' + computeTotalContribution(index, row.hps,tableData.sums)+ '<br>'+ computeGroupContribution(row.player.group, index, row.hps,tableData.sums)">
{{value}}
:data-original-title="formatNumber(round(value/phase.durationS)) + ' per second' + '<br>' + computeTotalContribution(index, row.hps,tableData.sums)+ '<br>'+ computeGroupContribution(row.player.group, index, row.hps,tableData.sums)">
{{ formatNumber(value) }}
</td>
</tr>
</tbody>
Expand All @@ -102,11 +102,11 @@
{{sum.name}}
</td>
<td></td>
<td v-if="!showHealing" v-for="(value, index) in sum.hps" :data-original-title="value + ' healing'">
{{round(value/phase.durationS)}}
<td v-if="!showHealing" v-for="(value, index) in sum.hps" :data-original-title="formatNumber(value) + ' healing'">
{{ formatNumber(round(value/phase.durationS)) }}
</td>
<td v-if="showHealing" v-for="(value, index) in sum.hps" :data-original-title="round(value/phase.durationS) + ' hps'">
{{value}}
<td v-if="showHealing" v-for="(value, index) in sum.hps" :data-original-title="formatNumber(round(value/phase.durationS)) + ' hps'">
{{ formatNumber(value) }}
</td>
</tr>
</tfoot>
Expand Down
40 changes: 20 additions & 20 deletions GW2EIBuilders/Resources/htmlTemplates/tmplDamageDistTable.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
<div v-if="isminion">
<p style="display: table-row;">
{{actor.name}} did {{round3(100*dmgdist.contributedDamage/dmgdist.totalDamage)}}% of its master's total
{{istarget ? 'Target' :''}} damage ({{dmgdist.contributedDamage}})
{{istarget ? 'Target' :''}} damage ({{ formatNumber(dmgdist.contributedDamage) }})
</p>
<p v-if="hasBreakbarDamage && dmgdist.contributedBreakbarDamage > 0" style="display: table-row;">
{{actor.name}} did {{round3(100*dmgdist.contributedBreakbarDamage/dmgdist.totalBreakbarDamage)}}% of its master's total
{{istarget ? 'Target' :''}} breakbar damage ({{round1(dmgdist.contributedBreakbarDamage)}})
{{istarget ? 'Target' :''}} breakbar damage ({{ formatNumber(round1(dmgdist.contributedBreakbarDamage)) }})
</p>
</div>
<div v-else>
<p style="display: table-row;">
{{actor.name}} did {{round3(100*dmgdist.contributedDamage/dmgdist.totalDamage)}}% of their total {{istarget ?
'Target' :''}} damage ({{dmgdist.contributedDamage}})
'Target' :''}} damage ({{ formatNumber(dmgdist.contributedDamage) }})
</p>
<p v-if="hasBreakbarDamage && dmgdist.contributedBreakbarDamage > 0" style="display: table-row;">
{{actor.name}} did {{round3(100*dmgdist.contributedBreakbarDamage/dmgdist.totalBreakbarDamage)}}% of their total
{{istarget ? 'Target' :''}} breakbar damage ({{round1(dmgdist.contributedBreakbarDamage)}})
{{istarget ? 'Target' :''}} breakbar damage ({{ formatNumber(round1(dmgdist.contributedBreakbarDamage)) }})
</p>
</div>
</div>
Expand Down Expand Up @@ -164,31 +164,31 @@
{{getSkill(row).name.length > 15 ? (getSkill(row).name.slice(0, 15)) + '...': getSkill(row).name}}
</td>
<td :class="getBodyClass('Data', 0)">
{{ round3(100*getDamage(row)/dmgdist.contributedDamage) }}%
{{ formatNumber(round3(100*getDamage(row)/dmgdist.contributedDamage)) }}%
</td>
<td :class="getBodyClass('Data', 1)"
:data-original-title="round2(getDamage(row)/phase.durationS) +' dps'">
{{ getDamage(row) }}
:data-original-title="formatNumber(round2(getDamage(row)/phase.durationS)) +' dps'">
{{ formatNumber(getDamage(row)) }}
</td>
<td :class="getBodyClass('Data', 2)"
:data-original-title="round2(getBarrierDamage(row)/phase.durationS) +' dps'">
{{ getBarrierDamage(row) }}
:data-original-title="formatNumber(round2(getBarrierDamage(row)/phase.durationS)) +' dps'">
{{ formatNumber(getBarrierDamage(row)) }}
</td>
<td :class="getBodyClass('Data', 3)">
{{ getMinDamage(row) }}
{{ formatNumber(getMinDamage(row)) }}
</td>
<td :class="getBodyClass('Data', 4)">
{{ round(getDamage(row)/getConnectedHits(row)) }}
{{ formatNumber(round(getDamage(row)/getConnectedHits(row))) }}
</td>
<td :class="getBodyClass('Data', 5)">
{{ getMaxDamage(row) }}
{{ formatNumber(getMaxDamage(row)) }}
</td>
<td :class="getBodyClass('Data', 6)" v-if="hasBreakbarDamage">
{{ round3(100*getBreakbarDamage(row)/dmgdist.contributedBreakbarDamage) }}%
{{ formatNumber(round3(100*getBreakbarDamage(row)/dmgdist.contributedBreakbarDamage)) }}%
</td>
<td :class="getBodyClass('Data', 7)" v-if="hasBreakbarDamage"
:data-original-title="round2(getBreakbarDamage(row)/phase.durationS) +' bps'">
{{ getBreakbarDamage(row) }}
{{ formatNumber(getBreakbarDamage(row)) }}
</td>
<td :class="getCastBodyClass('Data', 8, row)" v-if="actor !== null">
{{ (!getSkill(row).condi && getCast(row)) ? getCast(row) : ''}}
Expand All @@ -202,7 +202,7 @@
{{(!getSkill(row).condi && getConnectedHits(row) && getCast(row)) ? round2(getConnectedHits(row)/getCast(row)) : ''}}
</td>
<td :class="getBodyClass('Data', 11)" v-if="actor !== null">
{{(!getSkill(row).condi && getConnectedHits(row) && getCastDuration(row)) ? round2(getDamage(row)/(0.001 * getCastDuration(row))) : ''}}
{{(!getSkill(row).condi && getConnectedHits(row) && getCastDuration(row)) ? formatNumber(round2(getDamage(row)/(0.001 * getCastDuration(row)))) : ''}}
</td>
<td :class="getBodyClass('Data', 18)" v-if="actor !== null" >
{{ getCastDurationNoInterrupt(row) ? round3(0.001 * getMinCastingTimeNoInterrupt(row)) + 's': ' '}}
Expand Down Expand Up @@ -245,11 +245,11 @@
Total
</td>
<td></td>
<td :data-original-title="Math.round(dmgdist.contributedDamage/phase.durationS) +' dps'">
{{dmgdist.contributedDamage}}
<td :data-original-title="formatNumber(Math.round(dmgdist.contributedDamage/phase.durationS)) +' dps'">
{{ formatNumber(dmgdist.contributedDamage) }}
</td>
<td :data-original-title="Math.round(dmgdist.contributedShieldDamage/phase.durationS) +' dps'">
{{dmgdist.contributedShieldDamage}}
<td :data-original-title="formatNumber(Math.round(dmgdist.contributedShieldDamage/phase.durationS)) +' dps'">
{{ formatNumber(dmgdist.contributedShieldDamage) }}
</td>
<td></td>
<td></td>
Expand All @@ -262,7 +262,7 @@
<td></td>
<td v-if="actor !== null"></td>
<td v-if="actor !== null">
{{round2(dmgdist.contributedDamage/(0.001 * dmgdist.totalCasting))}}
{{ formatNumber(round2(dmgdist.contributedDamage/(0.001 * dmgdist.totalCasting))) }}
</td>
<td v-if="actor !== null"></td>
<td v-if="actor !== null"></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@
} else {
gain = "Pure Damage: ";
}
gain += this.round(item[2]);
gain += this.formatNumber(this.round(item[2]));
if (mod.nonMultiplier) {
gain += "<br>Total Damage: " + this.round3(100.0 * item[2] / item[3]) + "%";
gain += "<br>Total Damage: " + this.formatNumber(this.round3(100.0 * item[2] / item[3])) + "%";
}
return res + "<br>" + gain;
},
Expand All @@ -314,7 +314,7 @@
if (Math.abs(damageIncrease) < 1e-6 || isNaN(damageIncrease) || !isFinite(damageIncrease)) {
return "-";
}
return damageIncrease + '%';
return this.formatNumber(damageIncrease) + '%';
}
},
});
Expand Down
Loading