-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from bcgov/feature/AB#9260-dashboard-economic…
…-region Feature/AB#9260 Economic Region in Dashboard
- Loading branch information
Showing
10 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...er/src/Unity.GrantManager.Application.Contracts/GrantApplications/GetEconomicRegionDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Unity.GrantManager.GrantApplications; | ||
|
||
public class GetEconomicRegionDto | ||
{ | ||
public string? EconomicRegion { get; set; } | ||
public int? Count { get; set; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
applications/Unity.GrantManager/src/Unity.GrantManager.Web/Pages/Dashboard/Index.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@page | ||
@model Unity.GrantManager.Web.Pages.Dashboard.IndexModel | ||
@using Unity.GrantManager.Web.Pages.Dashboard | ||
@{ | ||
} | ||
@section styles { | ||
<abp-style src="/Pages/Dashboard/Index.css" /> | ||
} | ||
@section scripts | ||
{ | ||
<abp-script src="/Pages/Dashboard/Index.js" /> | ||
} | ||
|
||
|
||
<div class="application-dashboard"> | ||
<div class="chartBox"> | ||
<canvas id="economicRegionChart"></canvas> | ||
</div> | ||
|
||
</div> |
12 changes: 12 additions & 0 deletions
12
applications/Unity.GrantManager/src/Unity.GrantManager.Web/Pages/Dashboard/Index.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace Unity.GrantManager.Web.Pages.Dashboard | ||
{ | ||
public class IndexModel : PageModel | ||
{ | ||
public void OnGet() | ||
{ | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
applications/Unity.GrantManager/src/Unity.GrantManager.Web/Pages/Dashboard/Index.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.application-dashboard { | ||
height: calc(100vh - 190px); | ||
} | ||
|
||
.chartBox { | ||
width: 80%; | ||
} |
66 changes: 66 additions & 0 deletions
66
applications/Unity.GrantManager/src/Unity.GrantManager.Web/Pages/Dashboard/Index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
$(function () { | ||
unity.grantManager.grantApplications.grantApplication.getEconomicRegionCount().then(economicRegion => { | ||
|
||
// setup | ||
const data = { | ||
labels: economicRegion.map(obj => obj.economicRegion), | ||
datasets: [{ | ||
label: 'SUBMISSION BREAKDOWN BY ECONOMIC REGION', | ||
data: economicRegion.map(obj => obj.count), | ||
borderWidth: 1 | ||
}] | ||
}; | ||
|
||
const sum = economicRegion.map(obj => obj.count).reduce((partialSum, a) => partialSum + a, 0); | ||
|
||
// innerBarText plugin block | ||
const innerBarText = { | ||
id: 'innerBarText', | ||
afterDatasetDraw(chart, args, pluginOption) { | ||
const { ctx, data, chartArea: { left }, scales: { x, y } } = chart; | ||
ctx.save(); | ||
data.datasets[0].data.forEach((dataPoint, index) => { | ||
const percent = (dataPoint / sum) * 100; | ||
ctx.fillText(`${percent.toFixed(2)}%`, left + 10, y.getPixelForValue(index)); | ||
}); | ||
} | ||
} | ||
|
||
// config | ||
const config = { | ||
type: 'bar', | ||
data, | ||
options: { | ||
indexAxis: 'y', | ||
scales: { | ||
x: { | ||
beginAtZero: true, | ||
suggestedMin: 0, | ||
ticks: { | ||
precision:0 | ||
}, | ||
title: { | ||
display: true, | ||
text:'Number of Submissions' | ||
} | ||
}, | ||
y: { | ||
title: { | ||
display: true, | ||
text: 'Economic Regions' | ||
} | ||
} | ||
} | ||
}, | ||
plugins: [innerBarText] | ||
}; | ||
|
||
// render init block | ||
const myChart = new Chart( | ||
document.getElementById('economicRegionChart'), | ||
config | ||
); | ||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters