From 1ba30fd663f4c2a5bc6f542db6a975c32b9bcd13 Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Tue, 14 Jun 2022 17:46:30 +0200 Subject: [PATCH 01/10] f --- .../src/components/circle/CircleDiagram.vue | 79 +++----- .../circle/LearningPathCircleDiagram.vue | 171 ++++++++---------- client/src/components/circle/italy.json | 0 client/src/components/circle/map.html | 10 + client/src/views/LearningPathView.vue | 4 +- 5 files changed, 121 insertions(+), 143 deletions(-) create mode 100644 client/src/components/circle/italy.json create mode 100644 client/src/components/circle/map.html diff --git a/client/src/components/circle/CircleDiagram.vue b/client/src/components/circle/CircleDiagram.vue index e850a3a7..3f2e4ef6 100644 --- a/client/src/components/circle/CircleDiagram.vue +++ b/client/src/components/circle/CircleDiagram.vue @@ -1,75 +1,58 @@ - - diff --git a/client/src/components/circle/LearningPathCircleDiagram.vue b/client/src/components/circle/LearningPathCircleDiagram.vue index 8cc97a90..0e1cc1a4 100644 --- a/client/src/components/circle/LearningPathCircleDiagram.vue +++ b/client/src/components/circle/LearningPathCircleDiagram.vue @@ -2,7 +2,6 @@ import * as d3 from 'd3' import * as _ from 'underscore' - export default { props: { learninglearningPathContents: { @@ -102,51 +101,115 @@ export default { }, }, computed: { - viewBox() { return `0 0 ${this.width} ${this.height}` }, circles() { - return _.flatten(_.pluck(this.learninglearningPathContents.topics, 'circles')); + + let internalCircles = _.flatten(_.pluck(this.learninglearningPathContents.topics, 'circles')) + _.forEach(internalCircles, function (circle) { + let pieWeights = new Array(Math.max(circle.learning_sequences.length, 1)).fill(1) + let pieGenerator = d3.pie() + let pieData = pieGenerator(pieWeights) + circle.pieData = pieData + }); + return internalCircles }, svg() { - const width = this.width const height = this.height return d3.select(this.$el).append('svg').attr('width', width).attr('height', height) - } - + }, }, mounted() { - function getPieDataForCircle(circle) { - const newArray = new Array(Math.max(d[2].learning_sequences.length, 1)).fill(1) - return newArray + return new Array(Math.max(circle.learning_sequences.length, 1)).fill(1) } - const learningPathContents = [] + console.log(this.circles) - const data = this.pieData const circleWidth = 150 - - const radius = (circleWidth * 0.7) / 2 - console.log(this.viewBox) - const cicles = this.svg - .selectAll('circle') + // Create append pie charts to the main svg + const pie = this.svg.selectAll('.pie') + .data(this.circles) + + pie + .enter() + .append('g') + .attr('class', 'pie') + .attr('fill', 'red') + .attr('transform', (d, i) => { + let x_coord = (i + 1) * circleWidth - radius + 100 + return 'translate(' + x_coord + ', 40)' + }) + + let g = this.svg.selectAll('.pie') + // .append('circle') + // .attr('r', d => { + // return 30 + // }) + // .attr('fill', 'green') + // .attr('class', 'test') + + + + // + // let g = this.svg.selectAll('g').data(d => { + // if (d) { + // console.log(d.pieData + 'sdfklm'); + // return d.pieData + // } else { + // console.log('sdf') + // return [] + // } + // }) + + + g.enter().append('g').attr('class', 'arc') + + const arc = d3.arc() + .outerRadius(300) + .innerRadius(0); + + g.append('path').attr('fill', 'red').attr('d', arc) + + + + // //Generate groups + // const arcs = g + // .selectAll('arc') + // .data(pie([5, 5, 5, 5])) + // .enter() + // .append('path') + // .attr('d', arc) + + // const pies = g.selectAll('arcs') + // .data([1, 2, 3]) + // .enter() + // .append('g') + // .attr('cx', (d, i) => { + // return (i + 1) * circleWidth - radius + // }) + // .attr('cy', 150) + // .attr('d', arcs) + + const circles = this.svg + .selectAll('.blunt_circles') .data(this.circles) .enter() .append('circle') + .attr('class', 'blunt_circles') .attr('cx', (d, i) => { return (i + 1) * circleWidth - radius }) .attr('cy', 150) .attr('r', radius) - .attr('fill', '#99C7E7') + .attr('stroke', 'black') const circlesText = this.svg .selectAll('.circlesText') @@ -196,80 +259,6 @@ export default { .attr('y2', 270) .attr('class', 'stroke-gray-500') .attr('stroke-width', 1.76) - - - const g = this.svg.append('g').attr('transform', 'translate(' + this.width / 2 + ',' + this.height / 2 + ')') - - - // Generate the pie - const pie = d3.pie() - - // Generate the arcs - const arc = d3 - .arc() - .innerRadius(radius / 2) - .padAngle(12 / 360) - .outerRadius(radius) - - - //Generate groups - const arcs = g.selectAll('arc') - .data(pie(d => getPieDataForCircle(d))) - .enter() - .append('g') - .attr('class', 'arc') - - - //Draw arc paths - arcs.append('path') - .attr('d', arc) - - // Add the path using this helper function - - // console.log(this.pieData) - // const data = this.pieData - // - // const width = this.width - // const height = this.height - // const radius = Math.min(width, height) / 2.5 - // console.log(this.viewBox) - // - // - // const svg = d3.select(this.$el) - // .append('svg') - // .attr('width', width) - // .attr('height', height) - // - // - // const g = svg.append('g').attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')') - // - // - // // Generate the pie - // const pie = d3.pie() - // - // // Generate the arcs - // const arc = d3 - // .arc() - // .innerRadius(radius / 2) - // .padAngle(12 / 360) - // .outerRadius(radius) - // - // - // //Generate groups - // const arcs = g.selectAll('arc') - // .data(pie(data)) - // .enter() - // .append('g') - // .attr('class', 'arc') - // - // - // //Draw arc paths - // arcs.append('path') - // .attr('d', arc) - // - // - // } - // }, } diff --git a/client/src/components/circle/italy.json b/client/src/components/circle/italy.json new file mode 100644 index 00000000..e69de29b diff --git a/client/src/components/circle/map.html b/client/src/components/circle/map.html new file mode 100644 index 00000000..6b6499c3 --- /dev/null +++ b/client/src/components/circle/map.html @@ -0,0 +1,10 @@ + + + + + $Title$ + + +$END$ + + diff --git a/client/src/views/LearningPathView.vue b/client/src/views/LearningPathView.vue index 1f54ea75..7fbca5dd 100644 --- a/client/src/views/LearningPathView.vue +++ b/client/src/views/LearningPathView.vue @@ -47,13 +47,11 @@ export default { topic.circles = [] } if (child.type === 'learnpath.Circle') { - console.log(child) topic.circles.push(child) } }); learningPathContents.topics.push(topic) - console.log(learningPathContents) - console.log('oskadfjnmlasdmflkmsadlf') + this.learningPathContents = learningPathContents; From 21f69338b624ee243c82bf9737ca5b105544811f Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Tue, 14 Jun 2022 17:46:30 +0200 Subject: [PATCH 02/10] f --- .../src/components/circle/CircleDiagram.vue | 79 +++----- .../circle/LearningPathCircleDiagram.vue | 171 ++++++++---------- client/src/components/circle/italy.json | 0 client/src/components/circle/map.html | 10 + client/src/views/LearningPathView.vue | 4 +- 5 files changed, 121 insertions(+), 143 deletions(-) create mode 100644 client/src/components/circle/italy.json create mode 100644 client/src/components/circle/map.html diff --git a/client/src/components/circle/CircleDiagram.vue b/client/src/components/circle/CircleDiagram.vue index e850a3a7..3f2e4ef6 100644 --- a/client/src/components/circle/CircleDiagram.vue +++ b/client/src/components/circle/CircleDiagram.vue @@ -1,75 +1,58 @@ - - diff --git a/client/src/components/circle/LearningPathCircleDiagram.vue b/client/src/components/circle/LearningPathCircleDiagram.vue index 8cc97a90..0e1cc1a4 100644 --- a/client/src/components/circle/LearningPathCircleDiagram.vue +++ b/client/src/components/circle/LearningPathCircleDiagram.vue @@ -2,7 +2,6 @@ import * as d3 from 'd3' import * as _ from 'underscore' - export default { props: { learninglearningPathContents: { @@ -102,51 +101,115 @@ export default { }, }, computed: { - viewBox() { return `0 0 ${this.width} ${this.height}` }, circles() { - return _.flatten(_.pluck(this.learninglearningPathContents.topics, 'circles')); + + let internalCircles = _.flatten(_.pluck(this.learninglearningPathContents.topics, 'circles')) + _.forEach(internalCircles, function (circle) { + let pieWeights = new Array(Math.max(circle.learning_sequences.length, 1)).fill(1) + let pieGenerator = d3.pie() + let pieData = pieGenerator(pieWeights) + circle.pieData = pieData + }); + return internalCircles }, svg() { - const width = this.width const height = this.height return d3.select(this.$el).append('svg').attr('width', width).attr('height', height) - } - + }, }, mounted() { - function getPieDataForCircle(circle) { - const newArray = new Array(Math.max(d[2].learning_sequences.length, 1)).fill(1) - return newArray + return new Array(Math.max(circle.learning_sequences.length, 1)).fill(1) } - const learningPathContents = [] + console.log(this.circles) - const data = this.pieData const circleWidth = 150 - - const radius = (circleWidth * 0.7) / 2 - console.log(this.viewBox) - const cicles = this.svg - .selectAll('circle') + // Create append pie charts to the main svg + const pie = this.svg.selectAll('.pie') + .data(this.circles) + + pie + .enter() + .append('g') + .attr('class', 'pie') + .attr('fill', 'red') + .attr('transform', (d, i) => { + let x_coord = (i + 1) * circleWidth - radius + 100 + return 'translate(' + x_coord + ', 40)' + }) + + let g = this.svg.selectAll('.pie') + // .append('circle') + // .attr('r', d => { + // return 30 + // }) + // .attr('fill', 'green') + // .attr('class', 'test') + + + + // + // let g = this.svg.selectAll('g').data(d => { + // if (d) { + // console.log(d.pieData + 'sdfklm'); + // return d.pieData + // } else { + // console.log('sdf') + // return [] + // } + // }) + + + g.enter().append('g').attr('class', 'arc') + + const arc = d3.arc() + .outerRadius(300) + .innerRadius(0); + + g.append('path').attr('fill', 'red').attr('d', arc) + + + + // //Generate groups + // const arcs = g + // .selectAll('arc') + // .data(pie([5, 5, 5, 5])) + // .enter() + // .append('path') + // .attr('d', arc) + + // const pies = g.selectAll('arcs') + // .data([1, 2, 3]) + // .enter() + // .append('g') + // .attr('cx', (d, i) => { + // return (i + 1) * circleWidth - radius + // }) + // .attr('cy', 150) + // .attr('d', arcs) + + const circles = this.svg + .selectAll('.blunt_circles') .data(this.circles) .enter() .append('circle') + .attr('class', 'blunt_circles') .attr('cx', (d, i) => { return (i + 1) * circleWidth - radius }) .attr('cy', 150) .attr('r', radius) - .attr('fill', '#99C7E7') + .attr('stroke', 'black') const circlesText = this.svg .selectAll('.circlesText') @@ -196,80 +259,6 @@ export default { .attr('y2', 270) .attr('class', 'stroke-gray-500') .attr('stroke-width', 1.76) - - - const g = this.svg.append('g').attr('transform', 'translate(' + this.width / 2 + ',' + this.height / 2 + ')') - - - // Generate the pie - const pie = d3.pie() - - // Generate the arcs - const arc = d3 - .arc() - .innerRadius(radius / 2) - .padAngle(12 / 360) - .outerRadius(radius) - - - //Generate groups - const arcs = g.selectAll('arc') - .data(pie(d => getPieDataForCircle(d))) - .enter() - .append('g') - .attr('class', 'arc') - - - //Draw arc paths - arcs.append('path') - .attr('d', arc) - - // Add the path using this helper function - - // console.log(this.pieData) - // const data = this.pieData - // - // const width = this.width - // const height = this.height - // const radius = Math.min(width, height) / 2.5 - // console.log(this.viewBox) - // - // - // const svg = d3.select(this.$el) - // .append('svg') - // .attr('width', width) - // .attr('height', height) - // - // - // const g = svg.append('g').attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')') - // - // - // // Generate the pie - // const pie = d3.pie() - // - // // Generate the arcs - // const arc = d3 - // .arc() - // .innerRadius(radius / 2) - // .padAngle(12 / 360) - // .outerRadius(radius) - // - // - // //Generate groups - // const arcs = g.selectAll('arc') - // .data(pie(data)) - // .enter() - // .append('g') - // .attr('class', 'arc') - // - // - // //Draw arc paths - // arcs.append('path') - // .attr('d', arc) - // - // - // } - // }, } diff --git a/client/src/components/circle/italy.json b/client/src/components/circle/italy.json new file mode 100644 index 00000000..e69de29b diff --git a/client/src/components/circle/map.html b/client/src/components/circle/map.html new file mode 100644 index 00000000..6b6499c3 --- /dev/null +++ b/client/src/components/circle/map.html @@ -0,0 +1,10 @@ + + + + + $Title$ + + +$END$ + + diff --git a/client/src/views/LearningPathView.vue b/client/src/views/LearningPathView.vue index 1f54ea75..7fbca5dd 100644 --- a/client/src/views/LearningPathView.vue +++ b/client/src/views/LearningPathView.vue @@ -47,13 +47,11 @@ export default { topic.circles = [] } if (child.type === 'learnpath.Circle') { - console.log(child) topic.circles.push(child) } }); learningPathContents.topics.push(topic) - console.log(learningPathContents) - console.log('oskadfjnmlasdmflkmsadlf') + this.learningPathContents = learningPathContents; From b24bbc3f6280e1c276eaffa9d4a12ca295604c34 Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Wed, 15 Jun 2022 14:12:50 +0200 Subject: [PATCH 03/10] circles working --- .../circle/LearningPathCircleDiagram.vue | 103 +++++------------- 1 file changed, 26 insertions(+), 77 deletions(-) diff --git a/client/src/components/circle/LearningPathCircleDiagram.vue b/client/src/components/circle/LearningPathCircleDiagram.vue index 0e1cc1a4..314d49b9 100644 --- a/client/src/components/circle/LearningPathCircleDiagram.vue +++ b/client/src/components/circle/LearningPathCircleDiagram.vue @@ -123,106 +123,55 @@ export default { }, mounted() { - function getPieDataForCircle(circle) { - return new Array(Math.max(circle.learning_sequences.length, 1)).fill(1) - } + console.log(this.circles) - - const circleWidth = 150 + const circleWidth = 200 const radius = (circleWidth * 0.7) / 2 // Create append pie charts to the main svg - const pie = this.svg.selectAll('.pie') + const circle_groups = this.svg.selectAll('.circle') .data(this.circles) - - pie .enter() .append('g') - .attr('class', 'pie') - .attr('fill', 'red') + .attr('class', 'circle') .attr('transform', (d, i) => { - let x_coord = (i + 1) * circleWidth - radius + 100 - return 'translate(' + x_coord + ', 40)' + let x_coord = (i + 1) * circleWidth - radius + return 'translate(' + x_coord + ', 150)' }) - let g = this.svg.selectAll('.pie') - // .append('circle') - // .attr('r', d => { - // return 30 - // }) - // .attr('fill', 'green') - // .attr('class', 'test') - - // - // let g = this.svg.selectAll('g').data(d => { - // if (d) { - // console.log(d.pieData + 'sdfklm'); - // return d.pieData - // } else { - // console.log('sdf') - // return [] - // } - // }) + // Arc Generator + const arc = d3 + .arc() + .innerRadius(radius / 2) + .padAngle(12 / 360) + .outerRadius(radius) - g.enter().append('g').attr('class', 'arc') - - const arc = d3.arc() - .outerRadius(300) - .innerRadius(0); - - g.append('path').attr('fill', 'red').attr('d', arc) - - - - // //Generate groups - // const arcs = g - // .selectAll('arc') - // .data(pie([5, 5, 5, 5])) - // .enter() - // .append('path') - // .attr('d', arc) - - // const pies = g.selectAll('arcs') - // .data([1, 2, 3]) - // .enter() - // .append('g') - // .attr('cx', (d, i) => { - // return (i + 1) * circleWidth - radius - // }) - // .attr('cy', 150) - // .attr('d', arcs) - - const circles = this.svg - .selectAll('.blunt_circles') - .data(this.circles) +//Generate groups + const arcs = this.svg + .selectAll('g') + .selectAll('.arc') + .data(d => { return d.pieData}) .enter() - .append('circle') - .attr('class', 'blunt_circles') - .attr('cx', (d, i) => { - return (i + 1) * circleWidth - radius - }) - .attr('cy', 150) - .attr('r', radius) - .attr('stroke', 'black') + .append('g') + .attr('class', 'arc') - const circlesText = this.svg - .selectAll('.circlesText') - .data(this.circles) - .enter() + +//Draw arc paths + arcs.append('path') + .attr('d', arc) + + const circlesText = circle_groups .append('text') - .attr('x', (d, i) => { - return (i + 1) * circleWidth - radius - }) - .attr('y', 150 + radius + 30) .attr('fill', '#00224D') .style('font-size', 19) .text((d) => d.title) + .attr('y', radius + 30) .attr('class', 'circlesText') .style('text-anchor', 'middle') From 14b2ce0176636c9ec312beee599bb7a4da8f7f1b Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Wed, 15 Jun 2022 16:14:19 +0200 Subject: [PATCH 04/10] aded hover and done state --- .../circle/LearningPathCircleDiagram.vue | 155 ++++++++++++++---- 1 file changed, 122 insertions(+), 33 deletions(-) diff --git a/client/src/components/circle/LearningPathCircleDiagram.vue b/client/src/components/circle/LearningPathCircleDiagram.vue index 314d49b9..b3ef788c 100644 --- a/client/src/components/circle/LearningPathCircleDiagram.vue +++ b/client/src/components/circle/LearningPathCircleDiagram.vue @@ -21,7 +21,17 @@ export default { slug: 'basis', type: 'learnpath.Circle', translation_key: '13951cfd-b36d-42d5-b84a-178f0a7da106', - learning_sequences: [], + learning_sequences: [{ + id: 11, + title: 'Starten', + done: false + }, + { + id: 13, + title: 'Beobachten', + done: false + + }], }, ], }, @@ -39,7 +49,37 @@ export default { slug: 'gewinnen', type: 'learnpath.Circle', translation_key: '23b689c9-8800-4783-9842-725ee5f3a3f1', - learning_sequences: [], + learning_sequences: [ { + id: 11, + title: 'Starten', + done: true + }, + { + id: 13, + title: 'Beobachten', + done: false + + },{ + id: 11, + title: 'Starten', + done: false + }, + { + id: 13, + title: 'Beobachten', + done: false + + },{ + id: 11, + title: 'Starten', + done: true + }, + { + id: 13, + title: 'Beobachten', + done: false + + },], }, ], }, @@ -57,7 +97,17 @@ export default { slug: 'einstieg', type: 'learnpath.Circle', translation_key: 'a608ce8c-1482-491d-becd-2280787285b3', - learning_sequences: [], + learning_sequences: [ { + id: 11, + title: 'Starten', + done: true + }, + { + id: 13, + title: 'Beobachten', + done: false + + },], }, { id: 10, @@ -69,18 +119,25 @@ export default { { id: 11, title: 'Starten', + done: true }, { id: 13, title: 'Beobachten', + done: true + }, { id: 18, title: 'Anwenden', + done: true + }, { id: 30, title: 'Üben', + done: false + }, ], }, @@ -92,11 +149,11 @@ export default { }, width: { - default: 1024, + default: 1200, type: Number, }, height: { - default: 250, + default: 350, type: Number, }, }, @@ -105,14 +162,26 @@ export default { return `0 0 ${this.width} ${this.height}` }, circles() { - let internalCircles = _.flatten(_.pluck(this.learninglearningPathContents.topics, 'circles')) _.forEach(internalCircles, function (circle) { let pieWeights = new Array(Math.max(circle.learning_sequences.length, 1)).fill(1) let pieGenerator = d3.pie() let pieData = pieGenerator(pieWeights) + _.forEach(pieData, function(pie){ + let index = parseInt(pie.index) + console.log(circle) + if (circle.learning_sequences.length == 0) { + pie.done = false + } + else { + pie.done = circle.learning_sequences[parseInt(pie.index)].done + } + }) + + + circle.pieData = pieData - }); + }) return internalCircles }, svg() { @@ -123,59 +192,78 @@ export default { }, mounted() { - - console.log(this.circles) const circleWidth = 200 const radius = (circleWidth * 0.7) / 2 + const blue900 = '#00224D', + blue700 = '#1A5197', + gray100 = '#EDF2F6', + gray300 = '#E0E5EC', + gray500 = '#B1C1CA', + sky400 = '#72CAFF', + sky500 = '#41B5FA' + // Create append pie charts to the main svg - const circle_groups = this.svg.selectAll('.circle') + const circle_groups = this.svg + .selectAll('.circle') .data(this.circles) .enter() .append('g') .attr('class', 'circle') .attr('transform', (d, i) => { let x_coord = (i + 1) * circleWidth - radius - return 'translate(' + x_coord + ', 150)' + return 'translate(' + x_coord + ', 200)' + }) + .on('mouseover', function (d, i) { + d3.select(this).selectAll('.learningSegmentArc').transition().duration('200').attr('fill', d => {return d.done ? sky400 : gray100}) + }) + .on('mouseout', function (d, i) { + d3.select(this).selectAll('.learningSegmentArc').transition().duration('200').attr('fill', d => {return d.done ? sky500 : gray300}) }) - - - // Arc Generator - const arc = d3 + const arcGenerator = d3 .arc() .innerRadius(radius / 2) .padAngle(12 / 360) .outerRadius(radius) -//Generate groups + //Generate groups const arcs = this.svg .selectAll('g') - .selectAll('.arc') - .data(d => { return d.pieData}) + .selectAll('.learningSegmentArc') + .attr('fill', (d) => { + let color = 'red' + return color + } ) + .data((d) => { + return d.pieData + }) .enter() .append('g') - .attr('class', 'arc') + .attr('class', 'learningSegmentArc') + .attr('fill', gray300) -//Draw arc paths - arcs.append('path') - .attr('d', arc) + arcs.transition().duration('1000').attr('fill', d => {return d.done ? sky500 : gray300}) + + + + //Draw arc paths + arcs.append('path').attr('d', arcGenerator) const circlesText = circle_groups .append('text') - .attr('fill', '#00224D') + .attr('fill', blue900) .style('font-size', 19) .text((d) => d.title) .attr('y', radius + 30) - .attr('class', 'circlesText') + .attr('class', 'circlesText text-xl font-bold') .style('text-anchor', 'middle') - const topicTitles = this.svg .selectAll('.topicTitles') .data(this.learninglearningPathContents.topics) @@ -185,13 +273,10 @@ export default { return i * circleWidth * d.circles.length + 50 }) .attr('y', 50) - .attr('fill', '#00224D') - - + .attr('fill', blue900) .style('font-size', 19) .text((d) => d.title) - .attr('class', 'topicTitles') - + .attr('class', 'topicTitles font-bold') const topicLines = this.svg .selectAll('lines') @@ -205,9 +290,11 @@ export default { .attr('x2', (d, i) => { return i * circleWidth * d.circles.length + 30 }) - .attr('y2', 270) + .attr('y2', 0) .attr('class', 'stroke-gray-500') .attr('stroke-width', 1.76) + + topicLines.transition().duration('1000').attr('y2',350) }, } @@ -220,7 +307,8 @@ export default { padding-bottom: 100%; vertical-align: top; overflow: hidden; - fill: rgb(65 181 250); + background: white; + } .svg-content { @@ -228,7 +316,8 @@ export default { position: absolute; top: 0; left: 0; - fill: rgb(65 181 250); + background: white; + } From 7ddcd13b1009936667f2ba81ed63f8892f8acd2a Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Wed, 15 Jun 2022 16:45:06 +0200 Subject: [PATCH 05/10] added text wrapping --- .../circle/LearningPathCircleDiagram.vue | 105 +++++++++++------- 1 file changed, 62 insertions(+), 43 deletions(-) diff --git a/client/src/components/circle/LearningPathCircleDiagram.vue b/client/src/components/circle/LearningPathCircleDiagram.vue index b3ef788c..7e65ac56 100644 --- a/client/src/components/circle/LearningPathCircleDiagram.vue +++ b/client/src/components/circle/LearningPathCircleDiagram.vue @@ -22,10 +22,10 @@ export default { type: 'learnpath.Circle', translation_key: '13951cfd-b36d-42d5-b84a-178f0a7da106', learning_sequences: [{ - id: 11, - title: 'Starten', - done: false - }, + id: 11, + title: 'Starten', + done: false + }, { id: 13, title: 'Beobachten', @@ -49,17 +49,17 @@ export default { slug: 'gewinnen', type: 'learnpath.Circle', translation_key: '23b689c9-8800-4783-9842-725ee5f3a3f1', - learning_sequences: [ { - id: 11, - title: 'Starten', - done: true - }, + learning_sequences: [{ + id: 11, + title: 'Starten', + done: true + }, { id: 13, title: 'Beobachten', done: false - },{ + }, { id: 11, title: 'Starten', done: false @@ -69,7 +69,7 @@ export default { title: 'Beobachten', done: false - },{ + }, { id: 11, title: 'Starten', done: true @@ -97,11 +97,11 @@ export default { slug: 'einstieg', type: 'learnpath.Circle', translation_key: 'a608ce8c-1482-491d-becd-2280787285b3', - learning_sequences: [ { - id: 11, - title: 'Starten', - done: true - }, + learning_sequences: [{ + id: 11, + title: 'Starten', + done: true + }, { id: 13, title: 'Beobachten', @@ -111,7 +111,7 @@ export default { }, { id: 10, - title: 'Analyse', + title: 'Analyse des letzten Falles', slug: 'analyse', type: 'learnpath.Circle', translation_key: '2ca5ba7a-98b8-4511-ba50-bc190714886d', @@ -167,19 +167,9 @@ export default { let pieWeights = new Array(Math.max(circle.learning_sequences.length, 1)).fill(1) let pieGenerator = d3.pie() let pieData = pieGenerator(pieWeights) - _.forEach(pieData, function(pie){ - let index = parseInt(pie.index) - console.log(circle) - if (circle.learning_sequences.length == 0) { - pie.done = false - } - else { - pie.done = circle.learning_sequences[parseInt(pie.index)].done - } + _.forEach(pieData, function (pie) { + pie.done = circle.learning_sequences.length == 0 ? false : circle.learning_sequences[parseInt(pie.index)].done }) - - - circle.pieData = pieData }) return internalCircles @@ -192,8 +182,6 @@ export default { }, mounted() { - console.log(this.circles) - const circleWidth = 200 const radius = (circleWidth * 0.7) / 2 const blue900 = '#00224D', @@ -202,8 +190,7 @@ export default { gray300 = '#E0E5EC', gray500 = '#B1C1CA', sky400 = '#72CAFF', - sky500 = '#41B5FA' - + sky500 = '#41B5FA' // Create append pie charts to the main svg @@ -218,11 +205,16 @@ export default { return 'translate(' + x_coord + ', 200)' }) .on('mouseover', function (d, i) { - d3.select(this).selectAll('.learningSegmentArc').transition().duration('200').attr('fill', d => {return d.done ? sky400 : gray100}) + d3.select(this).selectAll('.learningSegmentArc').transition().duration('200').attr('fill', d => { + return d.done ? sky400 : gray100 + }) }) .on('mouseout', function (d, i) { - d3.select(this).selectAll('.learningSegmentArc').transition().duration('200').attr('fill', d => {return d.done ? sky500 : gray300}) + d3.select(this).selectAll('.learningSegmentArc').transition().duration('200').attr('fill', d => { + return d.done ? sky500 : gray300 + }) }) + .attr('role', 'button') const arcGenerator = d3 .arc() @@ -238,7 +230,7 @@ export default { .attr('fill', (d) => { let color = 'red' return color - } ) + }) .data((d) => { return d.pieData }) @@ -248,8 +240,9 @@ export default { .attr('fill', gray300) - arcs.transition().duration('1000').attr('fill', d => {return d.done ? sky500 : gray300}) - + arcs.transition().duration('1000').attr('fill', d => { + return d.done ? sky500 : gray300 + }) //Draw arc paths @@ -263,6 +256,7 @@ export default { .attr('y', radius + 30) .attr('class', 'circlesText text-xl font-bold') .style('text-anchor', 'middle') + .call(wrap, 200-20); const topicTitles = this.svg .selectAll('.topicTitles') @@ -294,7 +288,34 @@ export default { .attr('class', 'stroke-gray-500') .attr('stroke-width', 1.76) - topicLines.transition().duration('1000').attr('y2',350) + topicLines.transition().duration('1000').attr('y2', 350) + + + function wrap(text, width) { + text.each(function () { + let text = d3.select(this), + words = text.text().split(/\s+/).reverse(), + word, + line = [], + lineNumber = 0, + lineHeight = 1.1, // ems + y = text.attr('y'), + dy = 0,//parseFloat(text.attr('dy')), + tspan = text.text(null).append('tspan').attr('x', 0).attr('y', y).attr('dy', dy + 'em'); + while (word = words.pop()) { + line.push(word); + tspan.text(line.join(' ')); + if (tspan.node().getComputedTextLength() > width) { + line.pop(); + tspan.text(line.join(' ')); + line = [word]; + + tspan = text.append('tspan').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(word); + } + } + }); + } + }, } @@ -307,8 +328,7 @@ export default { padding-bottom: 100%; vertical-align: top; overflow: hidden; - background: white; - + background: white; } .svg-content { @@ -316,8 +336,7 @@ export default { position: absolute; top: 0; left: 0; - background: white; - + background: white; } From 46275fe775b1cdd14bb19aedb06b19cbd77604e4 Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Mon, 27 Jun 2022 11:07:35 +0200 Subject: [PATCH 06/10] some fixes --- .../circle/LearningPathCircleDiagram.vue | 178 +++++++++++------- client/src/views/LearningPathView.vue | 8 +- 2 files changed, 110 insertions(+), 76 deletions(-) diff --git a/client/src/components/circle/LearningPathCircleDiagram.vue b/client/src/components/circle/LearningPathCircleDiagram.vue index 7e65ac56..5ff3451a 100644 --- a/client/src/components/circle/LearningPathCircleDiagram.vue +++ b/client/src/components/circle/LearningPathCircleDiagram.vue @@ -21,17 +21,18 @@ export default { slug: 'basis', type: 'learnpath.Circle', translation_key: '13951cfd-b36d-42d5-b84a-178f0a7da106', - learning_sequences: [{ - id: 11, - title: 'Starten', - done: false - }, + learning_sequences: [ + { + id: 11, + title: 'Starten', + done: false, + }, { id: 13, title: 'Beobachten', - done: false - - }], + done: false, + }, + ], }, ], }, @@ -49,37 +50,38 @@ export default { slug: 'gewinnen', type: 'learnpath.Circle', translation_key: '23b689c9-8800-4783-9842-725ee5f3a3f1', - learning_sequences: [{ - id: 11, - title: 'Starten', - done: true - }, + learning_sequences: [ { - id: 13, - title: 'Beobachten', - done: false - - }, { id: 11, title: 'Starten', - done: false + done: true, }, { id: 13, title: 'Beobachten', - done: false - - }, { + done: false, + }, + { id: 11, title: 'Starten', - done: true + done: false, }, { id: 13, title: 'Beobachten', - done: false - - },], + done: false, + }, + { + id: 11, + title: 'Starten', + done: true, + }, + { + id: 13, + title: 'Beobachten', + done: false, + }, + ], }, ], }, @@ -97,17 +99,18 @@ export default { slug: 'einstieg', type: 'learnpath.Circle', translation_key: 'a608ce8c-1482-491d-becd-2280787285b3', - learning_sequences: [{ - id: 11, - title: 'Starten', - done: true - }, + learning_sequences: [ + { + id: 11, + title: 'Starten', + done: true, + }, { id: 13, title: 'Beobachten', - done: false - - },], + done: false, + }, + ], }, { id: 10, @@ -119,25 +122,22 @@ export default { { id: 11, title: 'Starten', - done: true + done: true, }, { id: 13, title: 'Beobachten', - done: true - + done: true, }, { id: 18, title: 'Anwenden', - done: true - + done: true, }, { id: 30, title: 'Üben', - done: false - + done: false, }, ], }, @@ -149,7 +149,7 @@ export default { }, width: { - default: 1200, + default: 800, type: Number, }, height: { @@ -175,13 +175,24 @@ export default { return internalCircles }, svg() { - const width = this.width - const height = this.height - return d3.select(this.$el).append('svg').attr('width', width).attr('height', height) + const width = '100%' + 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() { + console.log(this.width, this.height) const circleWidth = 200 const radius = (circleWidth * 0.7) / 2 const blue900 = '#00224D', @@ -192,7 +203,6 @@ export default { sky400 = '#72CAFF', sky500 = '#41B5FA' - // Create append pie charts to the main svg const circle_groups = this.svg .selectAll('.circle') @@ -205,14 +215,22 @@ export default { return 'translate(' + x_coord + ', 200)' }) .on('mouseover', function (d, i) { - d3.select(this).selectAll('.learningSegmentArc').transition().duration('200').attr('fill', d => { - return d.done ? sky400 : gray100 - }) + d3.select(this) + .selectAll('.learningSegmentArc') + .transition() + .duration('200') + .attr('fill', (d) => { + return d.done ? sky400 : gray100 + }) }) .on('mouseout', function (d, i) { - d3.select(this).selectAll('.learningSegmentArc').transition().duration('200').attr('fill', d => { - return d.done ? sky500 : gray300 - }) + d3.select(this) + .selectAll('.learningSegmentArc') + .transition() + .duration('200') + .attr('fill', (d) => { + return d.done ? sky500 : gray300 + }) }) .attr('role', 'button') @@ -222,7 +240,6 @@ export default { .padAngle(12 / 360) .outerRadius(radius) - //Generate groups const arcs = this.svg .selectAll('g') @@ -239,11 +256,12 @@ export default { .attr('class', 'learningSegmentArc') .attr('fill', gray300) - - arcs.transition().duration('1000').attr('fill', d => { - return d.done ? sky500 : gray300 - }) - + arcs + .transition() + .duration('1000') + .attr('fill', (d) => { + return d.done ? sky500 : gray300 + }) //Draw arc paths arcs.append('path').attr('d', arcGenerator) @@ -256,7 +274,7 @@ export default { .attr('y', radius + 30) .attr('class', 'circlesText text-xl font-bold') .style('text-anchor', 'middle') - .call(wrap, 200-20); + .call(wrap, 200 - 20) const topicTitles = this.svg .selectAll('.topicTitles') @@ -290,7 +308,6 @@ export default { topicLines.transition().duration('1000').attr('y2', 350) - function wrap(text, width) { text.each(function () { let text = d3.select(this), @@ -300,22 +317,31 @@ export default { lineNumber = 0, lineHeight = 1.1, // ems y = text.attr('y'), - dy = 0,//parseFloat(text.attr('dy')), - tspan = text.text(null).append('tspan').attr('x', 0).attr('y', y).attr('dy', dy + 'em'); - while (word = words.pop()) { - line.push(word); - tspan.text(line.join(' ')); + dy = 0, //parseFloat(text.attr('dy')), + tspan = text + .text(null) + .append('tspan') + .attr('x', 0) + .attr('y', y) + .attr('dy', dy + 'em') + while ((word = words.pop())) { + line.push(word) + tspan.text(line.join(' ')) if (tspan.node().getComputedTextLength() > width) { - line.pop(); - tspan.text(line.join(' ')); - line = [word]; + line.pop() + tspan.text(line.join(' ')) + line = [word] - tspan = text.append('tspan').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(word); + tspan = text + .append('tspan') + .attr('x', 0) + .attr('y', y) + .attr('dy', ++lineNumber * lineHeight + dy + 'em') + .text(word) } } - }); + }) } - }, } @@ -331,7 +357,7 @@ export default { background: white; } -.svg-content { +.learning-path-visualization { display: inline-block; position: absolute; top: 0; @@ -341,5 +367,11 @@ export default { diff --git a/client/src/views/LearningPathView.vue b/client/src/views/LearningPathView.vue index 7fbca5dd..90568c77 100644 --- a/client/src/views/LearningPathView.vue +++ b/client/src/views/LearningPathView.vue @@ -65,16 +65,18 @@ export default {