Skip to content

Commit

Permalink
Add chart title
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Jul 10, 2023
1 parent d065f70 commit ed9244c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 39 deletions.
12 changes: 10 additions & 2 deletions BTCPayServer/Services/Reporting/PaymentsReportProvider.cs
Expand Up @@ -77,10 +77,18 @@ public override ViewDefinition[] CreateViewDefinitions()
},
new ()
{
Name = "Group by Lightning Address",
Name = "Group by Lightning Address (Currency amount)",
Filters = { "typeof this.LightningAddress === 'string' && this.Crypto == \"BTC\"" },
Groups = { "LightningAddress", "Currency" },
Aggregates = { "Amount", "CurrencyAmount" },
Aggregates = { "CurrencyAmount" },
HasGrandTotal = true
},
new ()
{
Name = "Group by Lightning Address (Crypto amount)",
Filters = { "typeof this.LightningAddress === 'string' && this.Crypto == \"BTC\"" },
Groups = { "LightningAddress" },
Aggregates = { "Amount" },
HasGrandTotal = true
}
}
Expand Down
36 changes: 20 additions & 16 deletions BTCPayServer/Views/UIReports/StoreReports.cshtml
Expand Up @@ -53,22 +53,26 @@
</div>

<div id="app">
<table v-for="chart in srv.charts" class="table table-bordered">
<thead>
<tr>
<th v-for="group in chart.groups">{{ group }}</th>
<th v-for="agg in chart.aggregates">{{ agg }}</th>
</tr>
</thead>
<tbody>
<tr v-for="row in chart.rows">
<td v-for="group in row.groups" :rowspan="group.rowCount">{{ group.name }}</td>
<td v-if="row.isTotal" :colspan="row.rLevel">Total</td>
<td v-for="value in row.values">{{ value }}</td>
</tr>
<tr v-if="chart.hasGrandTotal"><td :colspan="chart.groups.length">Grand total</td><td v-for="value in chart.grandTotalValues">{{ value }}</td></tr>
</tbody>
</table>
<div v-for="chart in srv.charts">
<h3>{{ chart.name }}</h3>
<table class="table table-bordered">
<thead>
<tr>
<th v-for="group in chart.groups">{{ group }}</th>
<th v-for="agg in chart.aggregates">{{ agg }}</th>
</tr>
</thead>
<tbody>
<tr v-for="row in chart.rows">
<td v-for="group in row.groups" :rowspan="group.rowCount">{{ group.name }}</td>
<td v-if="row.isTotal" :colspan="row.rLevel">Total</td>
<td v-for="value in row.values">{{ value }}</td>
</tr>
<tr v-if="chart.hasGrandTotal"><td :colspan="chart.groups.length">Grand total</td><td v-for="value in chart.grandTotalValues">{{ value }}</td></tr>
</tbody>
</table>
</div>
<h3>Raw data</h3>
<table class="table table-bordered">
<thead>
<tr>
Expand Down
24 changes: 3 additions & 21 deletions BTCPayServer/wwwroot/js/store-reports.js
Expand Up @@ -180,30 +180,12 @@ async function fetchStoreReports() {
srv.charts = [];
for (var i = 0; i < srv.result.charts.length; i++) {
var chart = srv.result.charts[i];
srv.charts.push(createTable(chart, srv.result.fields.map(f => f.name), srv.result.data));
var table = createTable(chart, srv.result.fields.map(f => f.name), srv.result.data);
table.name = chart.name;
srv.charts.push(table);
}

app.srv = srv;


//var summaryDefinition = {
// groups: ["Crypto", "PaymentType"],
// totals: [ "Crypto" ],
// hasGrandTotal: true,
// aggregates: ["Amount", "CurrencyAmount"]
//};
// var summaryDefinition = {
// groups: ["Region", "Crypto", "PaymentType"],
// totals: [ "Region", "Crypto" ],
// hasGrandTotal: true,
// aggregates: ["Amount", "CryptoAmount"]
//};

//new Vue({
// el: '#summary',
// data: createTable(summaryDefinition, ["Region", "Crypto", "PaymentType", "Amount", "CryptoAmount"], generateRandomRows(1000))
// //data: createTable(summaryDefinition, srv.result.fields.map(f => f.name) , origData)
//});
}

function getRandomValue(arr) {
Expand Down

0 comments on commit ed9244c

Please sign in to comment.