Added green state to learning path diagramm
This commit is contained in:
parent
3767edce04
commit
67545f474a
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import * as d3 from "d3";
|
import * as d3 from "d3";
|
||||||
import {computed, onMounted} from "vue";
|
import {computed, onMounted} from "vue";
|
||||||
import * as _ from 'underscore'
|
import * as _ from 'lodash'
|
||||||
import {useCircleStore} from '@/stores/circle';
|
import {useCircleStore} from '@/stores/circle';
|
||||||
import * as log from 'loglevel';
|
import * as log from 'loglevel';
|
||||||
|
|
||||||
|
|
@ -227,7 +227,6 @@ function render() {
|
||||||
return d3.select(this.nodes()[last]);
|
return d3.select(this.nodes()[last]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const all_arows = g.selectAll('.arrow')
|
const all_arows = g.selectAll('.arrow')
|
||||||
all_arows.last().remove()
|
all_arows.last().remove()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import * as d3 from 'd3';
|
import * as d3 from 'd3';
|
||||||
import {useLearningPathStore} from '../../stores/learningPath';
|
import {useLearningPathStore} from '../../stores/learningPath';
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
width: {
|
width: {
|
||||||
|
|
@ -25,22 +26,41 @@ export default {
|
||||||
const learningPathStore = useLearningPathStore()
|
const learningPathStore = useLearningPathStore()
|
||||||
return {learningPathStore}
|
return {learningPathStore}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
viewBox() {
|
viewBox() {
|
||||||
return `0 0 ${this.width} ${this.height * 1.5}`
|
return `0 0 ${this.width} ${this.height * 1.5}`
|
||||||
},
|
},
|
||||||
circles() {
|
circles() {
|
||||||
|
|
||||||
|
function someFinished(circle, learningSequence) {
|
||||||
|
if (circle) {
|
||||||
|
return circle.someFinishedInLearningSequence(learningSequence.translation_key);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function allFinished(circle, learningSequence) {
|
||||||
|
if (circle) {
|
||||||
|
return circle.allFinishedInLearningSequence(learningSequence.translation_key);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.learningPathStore.learningPath) {
|
if (this.learningPathStore.learningPath) {
|
||||||
let internalCircles = []
|
let internalCircles = []
|
||||||
this.learningPathStore.learningPath.circles.forEach((circle) => {
|
this.learningPathStore.learningPath.circles.forEach((circle) => {
|
||||||
let pieWeights = new Array(Math.max(circle.learningSequences.length, 1)).fill(1)
|
const pieWeights = new Array(Math.max(circle.learningSequences.length, 1)).fill(1)
|
||||||
let pieGenerator = d3.pie()
|
const pieGenerator = d3.pie()
|
||||||
let pieData = pieGenerator(pieWeights)
|
let pieData = pieGenerator(pieWeights)
|
||||||
pieData.forEach((pie) => {
|
pieData.forEach((pie) => {
|
||||||
|
const thisLearningSequence = circle.learningSequences[parseInt(pie.index)]
|
||||||
pie.startAngle = pie.startAngle + Math.PI
|
pie.startAngle = pie.startAngle + Math.PI
|
||||||
pie.endAngle = pie.endAngle + Math.PI
|
pie.endAngle = pie.endAngle + Math.PI
|
||||||
const lp = circle.learningSequences[parseInt(pie.index)];
|
pie.done = circle.someFinishedInLearningSequence(thisLearningSequence.translation_key);
|
||||||
pie.done = circle.someFinishedInLearningSequence(lp.translation_key);
|
pie.someFinished = someFinished(circle, thisLearningSequence)
|
||||||
|
pie.allFinished = allFinished(circle, thisLearningSequence)
|
||||||
});
|
});
|
||||||
let newCircle = {}
|
let newCircle = {}
|
||||||
newCircle.pieData = pieData.reverse()
|
newCircle.pieData = pieData.reverse()
|
||||||
|
|
@ -76,6 +96,29 @@ export default {
|
||||||
green500 = '#54CE8B',
|
green500 = '#54CE8B',
|
||||||
green400 = '#78DEA3'
|
green400 = '#78DEA3'
|
||||||
|
|
||||||
|
|
||||||
|
function getColor(d) {
|
||||||
|
let color = gray300
|
||||||
|
if (d.someFinished) {
|
||||||
|
color = sky500
|
||||||
|
}
|
||||||
|
if (d.allFinished) {
|
||||||
|
color = green500
|
||||||
|
}
|
||||||
|
return color
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHoverColor(d) {
|
||||||
|
let color = gray100
|
||||||
|
if (d.someFinished) {
|
||||||
|
color = sky400
|
||||||
|
}
|
||||||
|
if (d.allFinished) {
|
||||||
|
color = green400
|
||||||
|
}
|
||||||
|
return color
|
||||||
|
}
|
||||||
|
|
||||||
let vueRouter = this.$router
|
let vueRouter = this.$router
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -92,7 +135,7 @@ export default {
|
||||||
.transition()
|
.transition()
|
||||||
.duration(200)
|
.duration(200)
|
||||||
.attr('fill', (d) => {
|
.attr('fill', (d) => {
|
||||||
return d.done ? green400 : gray100
|
return getHoverColor(d)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.on('mouseout', function (d, i) {
|
.on('mouseout', function (d, i) {
|
||||||
|
|
@ -101,7 +144,7 @@ export default {
|
||||||
.transition()
|
.transition()
|
||||||
.duration(200)
|
.duration(200)
|
||||||
.attr('fill', (d) => {
|
.attr('fill', (d) => {
|
||||||
return d.done ? green500 : gray300
|
return getColor(d)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.on('click', function (d, i) {
|
.on('click', function (d, i) {
|
||||||
|
|
@ -132,7 +175,7 @@ export default {
|
||||||
.transition()
|
.transition()
|
||||||
.duration(1000)
|
.duration(1000)
|
||||||
.attr('fill', (d) => {
|
.attr('fill', (d) => {
|
||||||
return d.done ? green500 : gray300
|
return getColor(d)
|
||||||
})
|
})
|
||||||
|
|
||||||
//Draw arc paths
|
//Draw arc paths
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue