Gros progrès, statistiques 80%, reste à faire le school-info
This commit is contained in:
@@ -9,32 +9,127 @@
|
||||
<p>Moyenne des admis<span class="is-pulled-right">{state.average}</span></p>
|
||||
<p>Nombre de formations<span class="is-pulled-right">{state.courseNumber}</span></p>
|
||||
<p>Capacité<span class="is-pulled-right">{state.capacity}</span></p>
|
||||
<p>Sélectivité</p>
|
||||
<title-progress title={"Sélectivité"} value={state.selectivity} max="100"></title-progress>
|
||||
</div>
|
||||
<div class="m-4">
|
||||
<line-graph title="Répartition par genre" style="height: 6rem;"></line-graph>
|
||||
<line-graph title="Répartition par genre" data={state.genreStats} style="height: 6rem;"></line-graph>
|
||||
</div>
|
||||
<div class="m-4">
|
||||
<line-graph title="Répartition par bac" style="height: 6rem;"></line-graph>
|
||||
<line-graph title="Répartition par bac" data={state.bacStats} style="height: 6rem;"></line-graph>
|
||||
</div>
|
||||
<div class="m-4">
|
||||
<line-graph title="Répartition par mention au bac" style="height: 6rem;"></line-graph>
|
||||
<line-graph title="Répartition par mention au bac" data={state.mentionStats} style="height: 6rem;"></line-graph>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
onBeforeMount(props, state) {
|
||||
this.state = {
|
||||
state = {
|
||||
average: 0,
|
||||
capacity: 0,
|
||||
selectivity: 0,
|
||||
courseNumber: 0
|
||||
courseNumber: 0,
|
||||
bacStats: [],
|
||||
genreStats: [],
|
||||
mentionStats: []
|
||||
}
|
||||
},
|
||||
|
||||
onUpdated(props, state) {
|
||||
onBeforeUpdate(props, state) {
|
||||
if (!props.schoolList || !props.schoolList.length) return
|
||||
|
||||
let list = props.schoolList
|
||||
|
||||
let avg = list.reduce((s, e) => s + e.fields.moyenne, 0) / list.length
|
||||
let avgCap = list.reduce((s, e) => s + e.fields.capa_fin, 0) / list.length
|
||||
let avgSlc = list.reduce((s, e) => s + (e.fields.taux_acces_ens || 0), 0) / list.filter((e) => e.fields.taux_acces_ens).length
|
||||
|
||||
state.courseNumber = list.length
|
||||
state.average = Math.round(avg * 100) / 100
|
||||
state.capacity = Math.floor(avgCap)
|
||||
state.selectivity = Math.floor(avgSlc)
|
||||
|
||||
let pctFemmes = Math.round(list.reduce((s, e) => s + (e.fields.pct_f || 0), 0) / list.filter((e) => e.fields.pct_f).length)
|
||||
console.log(pctFemmes)
|
||||
state.genreStats = [
|
||||
{
|
||||
name: "Hommes",
|
||||
short: "H",
|
||||
value: (100 - pctFemmes)
|
||||
},
|
||||
{
|
||||
name: "Femmes",
|
||||
short: "F",
|
||||
value: pctFemmes
|
||||
},
|
||||
]
|
||||
|
||||
let pctBG = Math.round(list.reduce((s, e) => s + (e.fields.part_acces_gen || 0), 0) / list.filter((e) => e.fields.part_acces_gen).length)
|
||||
let pctBT = Math.round(list.reduce((s, e) => s + (e.fields.part_acces_tec || 0), 0) / list.filter((e) => e.fields.part_acces_tec).length)
|
||||
let pctBP = Math.round(list.reduce((s, e) => s + (e.fields.part_acces_pro || 0), 0) / list.filter((e) => e.fields.part_acces_pro).length)
|
||||
|
||||
state.bacStats = [
|
||||
{
|
||||
name: "Général",
|
||||
short: "Gen.",
|
||||
value: pctBG
|
||||
},
|
||||
{
|
||||
name: "Technologique",
|
||||
short: "Tech.",
|
||||
value: pctBT
|
||||
},
|
||||
{
|
||||
name: "Professionnel",
|
||||
short: "Pro.",
|
||||
value: pctBP
|
||||
},
|
||||
{
|
||||
name: "Autre",
|
||||
short: "Au.",
|
||||
value: 100 - (pctBG + pctBT + pctBP)
|
||||
}
|
||||
]
|
||||
|
||||
let pctSM = Math.round(list.reduce((s, e) => s + e.fields.pct_sansmention, 0) / list.length)
|
||||
let pctAB = Math.round(list.reduce((s, e) => s + e.fields.pct_ab, 0) / list.length)
|
||||
let pctB = Math.round(list.reduce((s, e) => s + e.fields.pct_b, 0) / list.length)
|
||||
let pctTB = Math.round(list.reduce((s, e) => s + e.fields.pct_tb, 0) / list.length)
|
||||
let pctTBF = Math.round(list.reduce((s, e) => s + e.fields.pct_tbf, 0) / list.length)
|
||||
|
||||
state.mentionStats = [
|
||||
{
|
||||
name: "Sans Mention",
|
||||
short: "SM",
|
||||
value: pctSM
|
||||
},
|
||||
{
|
||||
name: "Assez Bien",
|
||||
short: "AB",
|
||||
value: pctAB
|
||||
},
|
||||
{
|
||||
name: "Bien",
|
||||
short: "B",
|
||||
value: pctB
|
||||
},
|
||||
{
|
||||
name: "Très Bien",
|
||||
short: "TB",
|
||||
value: pctTB
|
||||
},
|
||||
{
|
||||
name: "Très Bien + Félicitations",
|
||||
short: "TBF",
|
||||
value: pctTBF
|
||||
},
|
||||
{
|
||||
name: "Non Spécifié",
|
||||
short: "NS",
|
||||
value: 100 - (pctSM + pctAB + pctB + pctTB + pctTBF)
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
updateCanvas() {
|
||||
let canvas = this.$("canvas")
|
||||
if (!canvas) return
|
||||
if (!canvas || !this.props.data || !this.props.title) return
|
||||
|
||||
canvas.width = canvas.clientWidth
|
||||
canvas.height = canvas.clientHeight
|
||||
@@ -23,13 +23,14 @@
|
||||
let height = canvas.height
|
||||
let spacing = 1
|
||||
|
||||
let data = this.state.data
|
||||
let data = this.props.data
|
||||
let colors = [
|
||||
"#003F5C",
|
||||
"#2F4B7C",
|
||||
"#665191",
|
||||
"#A05195",
|
||||
"#D45087"
|
||||
"#D45087",
|
||||
"#D47150"
|
||||
]
|
||||
|
||||
cx.clearRect(0, 0, width, height)
|
||||
@@ -48,9 +49,10 @@
|
||||
let counter = 0
|
||||
let legendWidth = 0
|
||||
for (let field of data) {
|
||||
if (field.value == 0) continue
|
||||
let start = curr + spacing
|
||||
let barWidth = field.value / total * width - spacing * 2
|
||||
let text = `${Math.round(field.value / total * 1000) / 10}% (${field.name})`
|
||||
let text = `${Math.round(field.value / total * 1000) / 10}% (${field.short || field.name})`
|
||||
|
||||
cx.fillStyle = colors[counter]
|
||||
cx.fillRect(start, 0, barWidth, height / 3)
|
||||
@@ -58,14 +60,15 @@
|
||||
cx.fillStyle = "#FFFFFF"
|
||||
if (cx.measureText(text).width < barWidth) {
|
||||
cx.fillText(text, start + barWidth / 2, height / 6)
|
||||
} else if (cx.measureText("...").width < barWidth) {
|
||||
cx.fillText("...", start + barWidth / 2, height / 6)
|
||||
} else if (cx.measureText(`${Math.round(field.value / total * 1000) / 10}%`).width < barWidth) {
|
||||
cx.fillText(`${Math.round(field.value / total * 1000) / 10}%`, start + barWidth / 2, height / 6)
|
||||
}
|
||||
|
||||
curr += field.value / total * width
|
||||
counter++
|
||||
|
||||
legendWidth += cx.measureText(field.name).width + 25 + 15 // += textWidth + squareWidth + margin
|
||||
|
||||
let legendText = field.name + (field.short ? ` (${field.short})` : "")
|
||||
legendWidth += cx.measureText(legendText).width + 25 + 15
|
||||
}
|
||||
|
||||
cx.textAlign = "left"
|
||||
@@ -74,20 +77,18 @@
|
||||
|
||||
counter = 0
|
||||
for (let field of data) {
|
||||
if (field.value == 0) continue
|
||||
cx.fillStyle = colors[counter]
|
||||
cx.fillRect(0, 0, 25, 25)
|
||||
cx.fillStyle = "#707070"
|
||||
cx.fillText(field.name, 30, 12.5)
|
||||
cx.translate(cx.measureText(field.name).width + 25 + 15, 0)
|
||||
|
||||
let legendText = field.name + (field.short ? ` (${field.short})` : "")
|
||||
cx.fillText(legendText, 30, 12.5)
|
||||
cx.translate(cx.measureText(legendText).width + 25 + 15, 0)
|
||||
counter++
|
||||
}
|
||||
},
|
||||
|
||||
state: {
|
||||
data: [],
|
||||
title: "Example"
|
||||
},
|
||||
|
||||
onMounted() {
|
||||
let canvas = this.$("canvas")
|
||||
this.updateCanvas()
|
||||
|
@@ -8,28 +8,96 @@
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<fili-info course={state.course} shouldShowInfos={state.shouldShowInfos}></fili-info>
|
||||
<school parentUpdate={state.updating} course={state.course} shouldShowInfos={state.shouldShowInfos}></school>
|
||||
<fili-info schoolList={state.schoolList} course={state.course} shouldShowInfos={state.shouldShowInfos}></fili-info>
|
||||
<school sortList={sortList} schoolList={state.schoolList} sortFields={state.sortFields} course={state.course} shouldShowInfos={state.shouldShowInfos}></school>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<school-info></school-info>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
onBeforeMount(props, state) {
|
||||
//Initial state
|
||||
this.state = {
|
||||
course: null,
|
||||
updating: false,
|
||||
shouldShowInfos: false
|
||||
|
||||
import PAPI from '../javascript/parcoursup-link.js'
|
||||
|
||||
const SORT_TABLE = [
|
||||
{name: "Nom", id: "g_ea_lib_vx"},
|
||||
{name: "Ville", id: "ville_etab"},
|
||||
{name: "Département", id: "dep"},
|
||||
{name: "Moyenne", id: "moyenne"},
|
||||
{name: "Sélectivité", id: "taux_acces_ens"}
|
||||
]
|
||||
|
||||
export default {
|
||||
sortList(sortBy) {
|
||||
//Si la liste est déjà triée par la bonne catégorie, on l'inverse
|
||||
if (sortBy == this.state.sortBy) {
|
||||
this.state.schoolList.reverse()
|
||||
}
|
||||
//Sinon on l'ordonne par la nouvelle catégorie (ascendant par défaut)
|
||||
else {
|
||||
this.state.sortBy = sortBy
|
||||
|
||||
switch (sortBy) {
|
||||
case SORT_TABLE[3].id:
|
||||
case SORT_TABLE[4].id: {
|
||||
this.state.schoolList.sort((a, b) => {
|
||||
if (a.fields[sortBy] > b.fields[sortBy]) return 1
|
||||
else return -1
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
this.state.schoolList.sort((a, b) => {
|
||||
return (a.fields[sortBy]).localeCompare(b.fields[sortBy])
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.update({
|
||||
schoolList: this.state.schoolList
|
||||
})
|
||||
},
|
||||
updateList(course) {
|
||||
course = course || this.state.course
|
||||
PAPI.fetchEtablissement(course.fili, course.sousfili, course.soussousfili).then((response) => {
|
||||
response.forEach(etablissement => {
|
||||
// calcul la moyenne
|
||||
let pct_sansmention = etablissement.fields.pct_sansmention
|
||||
let pct_AB = etablissement.fields.pct_ab
|
||||
let pct_B = etablissement.fields.pct_b
|
||||
let pct_TB = etablissement.fields.pct_tb
|
||||
let pct_TBF = etablissement.fields.pct_tbf
|
||||
|
||||
// On prend la moyenne des moyennes comprises dans la mention
|
||||
// Exemple : Assez bien est entre 12 et 14 donc 13.
|
||||
etablissement.fields.moyenne = ((pct_TBF*19)+(pct_TB*17)+(pct_B*15)+(pct_AB*13)+(pct_sansmention*11))/100
|
||||
})
|
||||
|
||||
this.update({
|
||||
schoolList: response
|
||||
})
|
||||
})
|
||||
},
|
||||
updateCourse(course){
|
||||
this.updateList(course)
|
||||
|
||||
this.update({
|
||||
course: course,
|
||||
sortFields: SORT_TABLE,
|
||||
shouldShowInfos: course != null,
|
||||
updating: !this.state.updating
|
||||
})
|
||||
},
|
||||
|
||||
onMounted(props, state) {
|
||||
this.update({
|
||||
course: null,
|
||||
sortBy: null,
|
||||
schoolList: null,
|
||||
sortFields: SORT_TABLE,
|
||||
shouldShowInfos: false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<school>
|
||||
<div if={props.shouldShowInfos} class="box p-2 m-2">
|
||||
<iframe width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
|
||||
<div if={props.shouldShowInfos} class="box p-2 m-2" disabled="true">
|
||||
<iframe if={false} width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
|
||||
src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&layer=mapnik"
|
||||
style="border-radius: 5px;"></iframe>
|
||||
<br>
|
||||
@@ -13,115 +13,23 @@
|
||||
<table class="table is-fullwidth is-hoverable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th each={sortField in state.sortFields}>
|
||||
<th each={sortField in props.sortFields}>
|
||||
{sortField.name}
|
||||
<a id={sortField.id} onclick={() => sortList(sortField.id)}>
|
||||
<a id={sortField.id} onclick={() => props.sortList(sortField.id)}>
|
||||
<span class="icon"><i class="fas fa-sort"></i></span>
|
||||
</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr each={etablissement in state.items}>
|
||||
<td>{etablissement.fields.g_ea_lib_vx}</td>
|
||||
<td>{etablissement.fields.ville_etab}</td>
|
||||
<td>{etablissement.fields.dep}</td>
|
||||
<td>{etablissement.fields.moyenne}</td>
|
||||
<td>{etablissement.fields.taux_acces_ens}</td>
|
||||
<tr each={school in props.schoolList}>
|
||||
<td>{school.fields.g_ea_lib_vx}</td>
|
||||
<td>{school.fields.ville_etab}</td>
|
||||
<td>{school.fields.dep}</td>
|
||||
<td>{school.fields.moyenne}</td>
|
||||
<td><title-progress value={school.fields.taux_acces_ens} max="100" style="margin: auto"></title-progress></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
import PAPI from '../javascript/parcoursup-link.js'
|
||||
|
||||
async function fetchEtablissement(course) {
|
||||
return PAPI.fetchEtablissement(course.fili, course.sousfili, course.soussousfili);
|
||||
}
|
||||
|
||||
const SORT_TABLE = [
|
||||
{name: "Nom", id: "g_ea_lib_vx"},
|
||||
{name: "Ville", id: "ville_etab"},
|
||||
{name: "Département", id: "dep"},
|
||||
{name: "Moyenne", id: "moyenne"},
|
||||
{name: "Sélectivité", id: "taux_acces_ens"}
|
||||
]
|
||||
|
||||
export default function search() {
|
||||
return {
|
||||
updateList() {
|
||||
fetchEtablissement(this.props.course).then((response) => {
|
||||
response.forEach(etablissement => {
|
||||
// calcul la moyenne
|
||||
let pct_sansmention = etablissement.fields.pct_sansmention
|
||||
let pct_AB = etablissement.fields.pct_ab
|
||||
let pct_B = etablissement.fields.pct_b
|
||||
let pct_TB = etablissement.fields.pct_tb
|
||||
let pct_TBF = etablissement.fields.pct_tbf
|
||||
|
||||
// On prend la moyenne des moyennes comprises dans la mention
|
||||
// Exemple : Assez bien est entre 12 et 14 donc 13.
|
||||
etablissement.fields.moyenne = ((pct_TBF*19)+(pct_TB*17)+(pct_B*15)+(pct_AB*13)+(pct_sansmention*11))/100
|
||||
})
|
||||
|
||||
this.update({
|
||||
items: response,
|
||||
parentUpdate: this.props.parentUpdate
|
||||
})
|
||||
})
|
||||
},
|
||||
sortList(sortBy) {
|
||||
//Si la liste est déjà triée par la bonne catégorie, on l'inverse
|
||||
if (sortBy == this.state.sortBy) {
|
||||
this.state.items.reverse()
|
||||
}
|
||||
//Sinon on l'ordonne par la nouvelle catégorie (ascendant par défaut)
|
||||
else {
|
||||
this.state.sortBy = sortBy
|
||||
|
||||
switch (sortBy) {
|
||||
case SORT_TABLE[3].id:
|
||||
case SORT_TABLE[4].id: {
|
||||
this.state.items.sort((a, b) => {
|
||||
if (a.fields[sortBy] > b.fields[sortBy]) return 1
|
||||
else return -1
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
this.state.items.sort((a, b) => {
|
||||
return (a.fields[sortBy]).localeCompare(b.fields[sortBy])
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.update({
|
||||
items: this.state.items
|
||||
})
|
||||
},
|
||||
onBeforeMount(props, state) {
|
||||
state = {
|
||||
items: null,
|
||||
breakCycle: false,
|
||||
sortBy: null,
|
||||
parentUpdate: null,
|
||||
sortFields: null
|
||||
}
|
||||
},
|
||||
onMounted(props, state) {
|
||||
this.update({
|
||||
sortFields: SORT_TABLE
|
||||
})
|
||||
},
|
||||
onUpdated(props, state) {
|
||||
if (!props.shouldShowInfos || state.parentUpdate == props.parentUpdate) return
|
||||
this.updateList()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</school>
|
@@ -38,7 +38,7 @@
|
||||
promise = PAPI.fetchFiliere(this.state.course.fili)
|
||||
break
|
||||
case 2:
|
||||
promise = PAPI.fetchSpecialites(this.state.course.sousfili)
|
||||
promise = PAPI.fetchSpecialites(this.state.course.fili, this.state.course.sousfili)
|
||||
break
|
||||
|
||||
default:
|
||||
|
49
components/title-progress.riot
Normal file
49
components/title-progress.riot
Normal file
@@ -0,0 +1,49 @@
|
||||
<title-progress>
|
||||
|
||||
<div style="display: flex;">
|
||||
<span if={props.title}>{props.title}</span>
|
||||
<span class="ml-1">{calcPct()}</span>
|
||||
<progress value={props.value} max={props.max} class={state.class} style="box-shadow: 0 0.5em 1em -0.125em rgb(10 10 10 / 10%), 0 0 0 1px rgb(10 10 10 / 2%);"></progress>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const DEFAULT_CLASSES = "progress is-small m-2 mt-auto mb-auto"
|
||||
const COLOR_CLASSES = [
|
||||
"is-link",
|
||||
"is-info",
|
||||
"is-success",
|
||||
"is-warning",
|
||||
"is-danger"
|
||||
]
|
||||
|
||||
|
||||
export default {
|
||||
computeClasses() {
|
||||
if (!this.props.value) return DEFAULT_CLASSES
|
||||
let n = Math.floor(this.props.value / 20)
|
||||
if (n == 5) n = 4
|
||||
|
||||
return DEFAULT_CLASSES + " " + COLOR_CLASSES[n]
|
||||
},
|
||||
|
||||
calcPct() {
|
||||
if (!this.props.value) {
|
||||
return "???"
|
||||
} else {
|
||||
return Math.round(this.props.value / this.props.max * 100) + "%"
|
||||
}
|
||||
},
|
||||
|
||||
onMounted(props, state) {
|
||||
this.update({
|
||||
class: this.computeClasses()
|
||||
})
|
||||
},
|
||||
|
||||
onBeforeUpdate(props, state) {
|
||||
state.class = this.computeClasses()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</title-progress>
|
Reference in New Issue
Block a user