-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f03468
commit e3d34ff
Showing
4 changed files
with
244 additions
and
3 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
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
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,194 @@ | ||
<svelte:options customElement={{ tag: 'ga-shield-graph', shadow: 'open' }}/> | ||
|
||
<script lang="ts"> | ||
import {onMount} from 'svelte'; | ||
import {Service} from '../shared/utils/service'; | ||
import {calculateSliderPosition, getColorRedToBlue, suffix} from '../shared/functions/helpers'; | ||
export let report: string; | ||
export let service: Service = window.GaReportService; | ||
let reportData: any; | ||
let min = 0; // Sxmin | ||
let mid = 0; // Sxaverage | ||
let max = 0; // Sxmax | ||
let result = 0; // Syourscore | ||
let percentile = 0; // Spercentile | ||
let show = false; | ||
onMount(async () => { | ||
reportData = await service.getReport(report); | ||
min = Number(reportData.Sxmin); | ||
mid = Number(reportData.Sxaverage); | ||
max = Number(reportData.Sxmax); | ||
result = Number(reportData.Syourscore); | ||
percentile = Number(reportData.Spercentile); | ||
show = true; | ||
}); | ||
</script> | ||
|
||
{#if show} | ||
<div class="parent"> | ||
<div class="colorBoxShort" style="background-color: #DF2120;"></div> | ||
<div class="colorBox" style="background-color: #DF2120;"></div> | ||
<div class="colorBox" style="background-color: #F2800D;"></div> | ||
<div class="colorBox" style="background-color: #66CCAA;"></div> | ||
<div class="colorBox" style="background-color: #66CCAA;"></div> | ||
<div class="colorBox" style="background-color: #13A195;"></div> | ||
<div class="colorBox" style="background-color: #015566;"></div> | ||
<div class="colorBoxShort" style="background-color: #015566;"></div> | ||
|
||
<div class="slider" style="left: {calculateSliderPosition(min, mid, max, result)}%;"> | ||
<p style="font-size: 1rem;"> | ||
Your result | ||
</p> | ||
<p style="font-size: 1.5rem;"> | ||
<b>{result}</b> | ||
</p> | ||
<svg class="rotateImg" width="14%" height="14%" viewBox="0 0 42 37" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M14.0718 4C17.151 -1.33334 24.849 -1.33333 27.9282 4.00001L40.0525 25C43.1317 30.3333 39.2827 37 33.1243 37L8.87563 37C2.71722 37 -1.13177 30.3333 1.94743 25L14.0718 4Z" fill="#09371F"/> | ||
</svg> | ||
</div> | ||
|
||
<div class="bottom-triangle" style="left: 9.5%;"> | ||
<svg width="40%" height="40%" viewBox="0 0 42 37" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M14.0718 4C17.151 -1.33334 24.849 -1.33333 27.9282 4.00001L40.0525 25C43.1317 30.3333 39.2827 37 33.1243 37L8.87563 37C2.71722 37 -1.13177 30.3333 1.94743 25L14.0718 4Z" fill="#6B8779"/> | ||
</svg> | ||
<div><b>{min}</b></div> | ||
</div> | ||
|
||
<div class="bottom-triangle" style="left: 50%;"> | ||
<svg width="40%" height="40%" viewBox="0 0 42 37" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M14.0718 4C17.151 -1.33334 24.849 -1.33333 27.9282 4.00001L40.0525 25C43.1317 30.3333 39.2827 37 33.1243 37L8.87563 37C2.71722 37 -1.13177 30.3333 1.94743 25L14.0718 4Z" fill="#6B8779"/> | ||
</svg> | ||
<div><b>{mid}</b></div> | ||
</div> | ||
|
||
<div class="bottom-triangle" style="left: 90.5%;"> | ||
<svg width="40%" height="40%" viewBox="0 0 42 37" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M14.0718 4C17.151 -1.33334 24.849 -1.33333 27.9282 4.00001L40.0525 25C43.1317 30.3333 39.2827 37 33.1243 37L8.87563 37C2.71722 37 -1.13177 30.3333 1.94743 25L14.0718 4Z" fill="#6B8779"/> | ||
</svg> | ||
<div><b>{max}</b></div> | ||
</div> | ||
|
||
<div class="message-one"> | ||
<p>This result ranks you in the</p> | ||
<div class="colored-percentile" style="background-color: {getColorRedToBlue(min, mid, max, result)};"> | ||
<b>{percentile}<sup>{suffix(percentile)}</sup> percentile</b> | ||
</div> | ||
<p>*</p> | ||
</div> | ||
<div class="message-two"> | ||
<p>Having a</p> | ||
<div class="higher">higher</div> | ||
<p>percentile ranking <b>is better</b> for this index.</p> | ||
</div> | ||
</div> | ||
{/if} | ||
|
||
<style> | ||
.parent { | ||
display: flex; | ||
width: 100%; | ||
height: 10px; | ||
position: relative; | ||
font-family: 'Sen', 'Noto Sans JP', sans-serif; | ||
} | ||
.slider { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
position: absolute; | ||
transform: translate(-50%, -110%); | ||
width: 24%; | ||
max-height: 85px; | ||
} | ||
.bottom-triangle { | ||
position: absolute; | ||
top: 100%; | ||
transform: translate(-50%, 10%); | ||
width: 8%; | ||
max-height: 60px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
color: #6B8779; | ||
} | ||
.message-one { | ||
position: absolute; | ||
top: 5rem; | ||
width: 55%; | ||
height: 3rem; | ||
transform: translate(-50%, 0%); | ||
left: 50%; | ||
max-height: 40px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 1.1rem; | ||
gap: .25rem; | ||
} | ||
.message-two { | ||
position: absolute; | ||
top: 8rem; | ||
width: 55%; | ||
height: 2rem; | ||
transform: translate(-50%, 0%); | ||
left: 50%; | ||
max-height: 30px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 0.7rem; | ||
gap: .25rem; | ||
} | ||
.colored-percentile { | ||
height: 90%; | ||
width: 32%; | ||
color: white; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 7px; | ||
} | ||
.higher { | ||
height: 60%; | ||
width: 10%; | ||
background-color: #015566; | ||
color: white; | ||
border-radius: 5px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.colorBox { | ||
width: 14%; | ||
border-radius: 24px; | ||
margin-left: 0.2%; | ||
margin-right: 0.2%; | ||
} | ||
.colorBoxShort { | ||
width: 10%; | ||
border-radius: 24px; | ||
} | ||
.rotateImg { | ||
transform: rotate(180deg); | ||
} | ||
p { | ||
margin: 0; | ||
} | ||
</style> |