Skip to content
Snippets Groups Projects
Commit a2ad10d1 authored by Jonathan Foucher's avatar Jonathan Foucher
Browse files

add future risks to results graph. Fixes https://app.asana.com/0/1202404842967175/1202775629585966

parent 2240a28a
No related branches found
No related tags found
No related merge requests found
Pipeline #30578 failed
...@@ -71,12 +71,17 @@ public function getExpositionDataForEvaluation(Evaluation $evaluation): array ...@@ -71,12 +71,17 @@ public function getExpositionDataForEvaluation(Evaluation $evaluation): array
return $dl->danger_id === $danger->id; return $dl->danger_id === $danger->id;
}); });
// the points for this danger are the total points for this danger,
// divided by the number of appllicable scenarios
$values[] = $v / $danger->scenarios->count() * $dangerLevel->level->getPointsAttribute(); $values[] = $v / $danger->scenarios->count() * $dangerLevel->level->getPointsAttribute();
} }
$total = collect($values)->sum(); $total = collect($values)->sum();
$percentages = collect($values)->map(function ($val) use ($total) { $percentages = collect($values)->map(function ($val) use ($total) {
if ($val === 0.0 || $total === 0.0) {
return 0;
}
return $val / $total * 100; return $val / $total * 100;
}); });
......
...@@ -101,7 +101,7 @@ export default { ...@@ -101,7 +101,7 @@ export default {
this.$store.dispatch('getAllGraphsForEvaluation', this.evaluation.id) this.$store.dispatch('getAllGraphsForEvaluation', this.evaluation.id)
this.drafting = false this.drafting = false
//this.$router.push('/evaluations') // this.$router.push('/evaluations')
}, },
async next () { async next () {
this.saving = true this.saving = true
......
...@@ -31,10 +31,12 @@ export default { ...@@ -31,10 +31,12 @@ export default {
responsive: true, responsive: true,
scales: { scales: {
r: { r: {
min: 0,
ticks: { ticks: {
color: '#000', color: '#000',
backdropColor: 'rgba(255,255,255, 0.5)', backdropColor: 'rgba(255,255,255, 0.5)',
z: 10, z: 10,
callback: function (value) { if (Number.isInteger(value)) { return value; } },
}, },
pointLabels: { pointLabels: {
display: true, display: true,
......
...@@ -33,6 +33,11 @@ export default { ...@@ -33,6 +33,11 @@ export default {
maxRotation: 40, maxRotation: 40,
minRotation: 40 minRotation: 40
} }
},
y: {
min: 0,
max: 100,
beginAtZero: true,
} }
}, },
}, },
......
<template> <template>
<div class="graph-element row" v-if="singleData.labels.length"> <div v-if="singleData.labels.length" class="graph-element row">
<div class="graph-legend col-3 mr-0 pr-0 text-muted"> <div class="graph-legend col-3 mr-0 pr-0 text-muted">
<span :title="fullLabel">{{singleData.labels[0]}}</span> <span :title="fullLabel">{{singleData.labels[0]}}</span>
</div> </div>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
:expected-level="measureLevel.expected_level" :expected-level="measureLevel.expected_level"
/> />
<!-- EN ATTENTE RETOUR CLIENT --> <!-- EN ATTENTE RETOUR CLIENT -->
<!-- <p class="text-center my-4">Efficacité <i class="fas fa-angle-double-right px-2"></i> Efficacité</p>--> <!-- <p class="text-center my-4">Efficacité <i class="fas fa-angle-double-right px-2"></i> Efficacité</p>-->
<MeasureActionForm <MeasureActionForm
ref="MeasureActionForm" ref="MeasureActionForm"
......
<template>
<Bar v-if="loaded && chartData" :chart-data="chartData" :chart-options="options" />
<div v-else class=" text-center">
<i class="fas fa-spin fa-spinner"></i>
</div>
</template>
<script>
import { Bar } from 'vue-chartjs/legacy'
import { Chart as ChartJS, Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale} from 'chart.js'
ChartJS.register(Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale)
export default {
name: 'FutureRiskGraph',
components: {
Bar,
},
props: ['evaluation'],
data() {
return {
loaded: this.$store.state.graphs[this.evaluation.id] && this.$store.state.graphs[this.evaluation.id].risks && this.$store.state.graphs[this.evaluation.id].futurerisks,
options: {
plugins: {
legend: {
display: false
},
},
scales: {
x: {
ticks: {
autoSkip: false,
maxRotation: 40,
minRotation: 40,
}
},
y: {
min: 0,
max: 100,
beginAtZero: true,
}
},
},
}
},
computed: {
chartData() {
if (!this.$store.state.graphs[this.evaluation.id] || !this.$store.state.graphs[this.evaluation.id].risks) {
return null;
}
const labels = this.$store.state.graphs[this.evaluation.id].risks.labels.map(l => {
return l.match(/.{1,40}(\s|$)/g)
});
const data = this.$store.state.graphs[this.evaluation.id].risks.data;
const data2 = this.$store.state.graphs[this.evaluation.id].futurerisks.data;
return {
labels,
datasets: [
{
data,
backgroundColor: 'black',
borderColor: 'black',
// barThickness : 1,
},
{
data: data2,
backgroundColor: 'white',
borderColor: 'black',
borderWidth: 2,
// barThickness : 1,
},
]
}
}
},
async mounted () {
this.loaded = false
if (typeof this.$store.state.graphs[this.evaluation.id] === 'undefined' || typeof this.$store.state.graphs[this.evaluation.id].risks === 'undefined') {
await this.$store.dispatch('getGraphForEvaluation', {
name: 'risks',
id: this.evaluation.id
})
}
if (typeof this.$store.state.graphs[this.evaluation.id] === 'undefined' || typeof this.$store.state.graphs[this.evaluation.id].futurerisks === 'undefined') {
await this.$store.dispatch('getGraphForEvaluation', {
name: 'futurerisks',
id: this.evaluation.id
})
}
this.loaded = true
}
}
</script>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
</div> </div>
</div> </div>
<div class="card-body"> <div class="card-body">
<ExpositionGraph :evaluation="evaluation" /> <FutureRiskGraph :evaluation="evaluation" />
</div> </div>
</div> </div>
</div> </div>
...@@ -59,13 +59,13 @@ import PlanAction from '../Components/Results/PlanAction' ...@@ -59,13 +59,13 @@ import PlanAction from '../Components/Results/PlanAction'
import MaturityCyber from '../Components/Results/MaturityCyber' import MaturityCyber from '../Components/Results/MaturityCyber'
import Historic from '../Components/Results/Historic' import Historic from '../Components/Results/Historic'
import NotFound from "../../../Errors/NotFound"; import NotFound from "../../../Errors/NotFound";
import ExpositionGraph from "../Components/Step3/ExpositionGraph"; import FutureRiskGraph from "../Components/Step5/FutureRiskGraph";
export default { export default {
name: 'SingleEvaluationView', name: 'SingleEvaluationView',
components: { components: {
ExpositionGraph, FutureRiskGraph,
NotFound, NotFound,
Dangers, Dangers,
Measures, Measures,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment