Added basic navigation fixed svg sizing

This commit is contained in:
Lorenz Padberg 2022-06-27 13:53:50 +02:00
parent 2286bbbf96
commit 0ccec140a4
4 changed files with 34 additions and 57 deletions

View File

View File

@ -149,17 +149,18 @@ export default {
}, },
width: { width: {
default: 800, default: 1440,
type: Number, type: Number,
}, },
height: { height: {
default: 350, default: 256,
type: Number, type: Number,
}, },
}, },
computed: { computed: {
viewBox() { viewBox() {
return `0 0 ${this.width} ${this.height}` console.log(this.width, this.height)
return `0 0 ${this.width} ${this.height* 1.5}`
}, },
circles() { circles() {
let internalCircles = _.flatten(_.pluck(this.learninglearningPathContents.topics, 'circles')) let internalCircles = _.flatten(_.pluck(this.learninglearningPathContents.topics, 'circles'))
@ -175,26 +176,17 @@ export default {
return internalCircles return internalCircles
}, },
svg() { svg() {
const width = '100%' return d3.select('.learning-path-visualization')
const height = 350
const div_w = d3.select('.svg-container').style('width').split('px').shift()
const div_h = d3.select('.svg-container').style('height').split('px').shift()
console.log("my height", div_h, div_w)
return d3
.select('.learning-path-visualization')
.attr('viewBox', '0 0 ' + div_w + ' ' + div_h)
.attr('preserveAspectRatio', 'xMinYMin meet') //.attr('width', width).attr('height', height)
},
render() {
console.log('skljdnfksldnjf' + this.width)
}, },
}, },
mounted() { mounted() {
console.log(this.width, this.height) console.log(this.width, this.height)
const circleWidth = 200 const circleWidth = 200
const radius = (circleWidth * 0.7) / 2 const radius = (circleWidth * 0.8) / 2
const blue900 = '#00224D', const blue900 = '#00224D',
blue700 = '#1A5197', blue700 = '#1A5197',
gray100 = '#EDF2F6', gray100 = '#EDF2F6',
@ -203,6 +195,8 @@ export default {
sky400 = '#72CAFF', sky400 = '#72CAFF',
sky500 = '#41B5FA' sky500 = '#41B5FA'
let vueRouter = this.$router
// Create append pie charts to the main svg // Create append pie charts to the main svg
const circle_groups = this.svg const circle_groups = this.svg
.selectAll('.circle') .selectAll('.circle')
@ -232,6 +226,10 @@ export default {
return d.done ? sky500 : gray300 return d.done ? sky500 : gray300
}) })
}) })
.on('click', function (d, i) {
vueRouter.push('/circle/'+i.slug)
})
.attr('role', 'button') .attr('role', 'button')
const arcGenerator = d3 const arcGenerator = d3
@ -346,32 +344,11 @@ export default {
} }
</script> </script>
<style scoped>
.svg-container {
display: inline-block;
position: relative;
width: 100%;
padding-bottom: 100%;
vertical-align: top;
overflow: hidden;
background: white;
}
.learning-path-visualization {
display: inline-block;
position: absolute;
top: 0;
left: 0;
background: white;
}
</style>
<template> <template>
<div class="svg-container"> <div class="svg-container h-full content-start ">
<svg> <svg class="learning-path-visualization h-full" :viewBox="viewBox">
<rect style="fill: rgb(0, 170, 0); stroke-width: 1; stroke: rgb(0, 0, 0)" />
</svg> </svg>
</div> </div>
<!-- <svg class="learning-path-visualization" width="10%" height="10%" viewBox="0 0 50 50">-->
<!-- </svg>-->
</template> </template>

View File

@ -10,7 +10,7 @@ import MainNavigationBar from '@/components/MainNavigationBar.vue';</script>
<div class="mt-8 flex flex-col lg:flex-row justify-start gap-4"> <div class="mt-8 flex flex-col lg:flex-row justify-start gap-4">
<router-link class="link text-xl" to="/styleguide">Styelguide</router-link> <router-link class="link text-xl" to="/styleguide">Styelguide</router-link>
<a class="link text-xl" href="/login/">Login</a> <a class="link text-xl" href="/login/">Login</a>
<!-- <router-link class="link text-xl" to="/learningpath/versicherungsvermittlerin">Lernpfad "Versicherungsvermittlerin" (Login benötigt)</router-link>--> <router-link class="link text-xl" to="/learningpath/versicherungsvermittlerin">Lernpfad "Versicherungsvermittlerin" (Login benötigt)</router-link>
<router-link class="link text-xl" to="/circle/analyse">Circle "Analyse" (Login benötigt)</router-link> <router-link class="link text-xl" to="/circle/analyse">Circle "Analyse" (Login benötigt)</router-link>
</div> </div>
</main> </main>

View File

@ -53,7 +53,6 @@ export default {
learningPathContents.topics.push(topic) learningPathContents.topics.push(topic)
this.learningPathContents = learningPathContents; this.learningPathContents = learningPathContents;
}); });
@ -72,9 +71,10 @@ export default {
<div class="learningpath flex flex-col"> <div class="learningpath flex flex-col">
<div class="flex flex-col h-max p-6"> <div class="flex flex-col h-max">
<div class="bg-green-500 h-64"> <div class="bg-white h-80 pt-8">
<SimpleCircleDiagram class="object-scale-down" :learning-path-contents="learningPathContents.topics"></SimpleCircleDiagram> <!-- <img src="@/assets/learning_path.svg" alt="" class="h-full">-->
<SimpleCircleDiagram :learning-path-contents="learningPathContents.topics"></SimpleCircleDiagram>
</div> </div>
<div class="text-blue-dark font-bold text-7xl m-12"> <div class="text-blue-dark font-bold text-7xl m-12">