Browse Source

[192-webreport] Fixed redundant chart data, fixed error in clusters list dialog, fixed index.ts

Evgeni 4 years ago
parent
commit
8f0b41d31b

+ 13 - 16
report-viewer/src/components/ClusterRadarChart.vue

@@ -24,7 +24,6 @@ export default defineComponent({
   },
   },
   setup(props) {
   setup(props) {
     const selectedMember = ref("")
     const selectedMember = ref("")
-    const labels = ref([])
 
 
     const createLabelsFor = (member) => {
     const createLabelsFor = (member) => {
       let matchedWith = []
       let matchedWith = []
@@ -37,18 +36,22 @@ export default defineComponent({
       return data
       return data
     }
     }
 
 
+    const chartStyle = {
+      fill: true,
+      backgroundColor: 'rgba(149, 168, 241, 0.5)',
+      borderColor: 'rgba(149, 168, 241, 1)',
+      pointBackgroundColor: 'rgba(149, 168, 241, 1)',
+      pointBorderColor: '#fff',
+      pointHoverBackgroundColor: '#fff',
+      pointHoverBorderColor: 'rgb(255, 99, 132)'
+    }
+
     const chartData = ref({
     const chartData = ref({
       labels: createLabelsFor(Object.keys(props.cluster.members)[0]),
       labels: createLabelsFor(Object.keys(props.cluster.members)[0]),
       datasets: [{
       datasets: [{
+        ...chartStyle,
         label: Object.keys(props.cluster.members)[0],
         label: Object.keys(props.cluster.members)[0],
-        data: createDataSetFor(Object.keys(props.cluster.members)[0]),
-        fill: true,
-        backgroundColor: 'rgba(149, 168, 241, 0.5)',
-        borderColor: 'rgba(149, 168, 241, 1)',
-        pointBackgroundColor: 'rgba(149, 168, 241, 1)',
-        pointBorderColor: '#fff',
-        pointHoverBackgroundColor: '#fff',
-        pointHoverBorderColor: 'rgb(255, 99, 132)'
+        data: createDataSetFor(Object.keys(props.cluster.members)[0])
       }]
       }]
     })
     })
 
 
@@ -65,15 +68,9 @@ export default defineComponent({
       chartData.value = {
       chartData.value = {
         labels: createLabelsFor(val),
         labels: createLabelsFor(val),
         datasets: [{
         datasets: [{
+          ...chartStyle,
           label: val,
           label: val,
           data: createDataSetFor(val),
           data: createDataSetFor(val),
-          fill: true,
-          backgroundColor: 'rgba(149, 168, 241, 0.5)',
-          borderColor: 'rgba(149, 168, 241, 1)',
-          pointBackgroundColor: 'rgba(149, 168, 241, 1)',
-          pointBorderColor: '#fff',
-          pointHoverBackgroundColor: '#fff',
-          pointHoverBorderColor: 'rgb(255, 99, 132)'
         }]
         }]
       }
       }
     })
     })

+ 1 - 1
report-viewer/src/components/ClustersList.vue

@@ -2,7 +2,7 @@
   <div class="wrapper">
   <div class="wrapper">
     <h1>Clusters for comparison {{ comparison.firstSubmissionId }} > {{ comparison.secondSubmissionId }}</h1>
     <h1>Clusters for comparison {{ comparison.firstSubmissionId }} > {{ comparison.secondSubmissionId }}</h1>
     <p v-for="( cluster, index ) in clusters" :key="index" @click="toggleDialog">
     <p v-for="( cluster, index ) in clusters" :key="index" @click="toggleDialog">
-      {{ index }} - {{ cluster.average_similarity }}
+      {{ index }} - {{ cluster.averageSimilarity }}
       <GDialog v-model="dialog" fullscreen>
       <GDialog v-model="dialog" fullscreen>
         <button @click="toggleDialog">Close</button>
         <button @click="toggleDialog">Close</button>
         <ClusterRadarChart :cluster="cluster"></ClusterRadarChart>
         <ClusterRadarChart :cluster="cluster"></ClusterRadarChart>

+ 8 - 7
report-viewer/src/components/ComparisonsTable.vue

@@ -13,7 +13,6 @@
             + comparison.matchPercentage"
             + comparison.matchPercentage"
         class="selectable"
         class="selectable"
     >
     >
-
       <td @click="navigateToComparisonView(comparison.firstSubmissionId, comparison.secondSubmissionId)">{{
       <td @click="navigateToComparisonView(comparison.firstSubmissionId, comparison.secondSubmissionId)">{{
           index + 1
           index + 1
         }}.
         }}.
@@ -35,10 +34,10 @@
         <img v-if="isInCluster(comparison.firstSubmissionId, comparison.secondSubmissionId)"
         <img v-if="isInCluster(comparison.firstSubmissionId, comparison.secondSubmissionId)"
              alt=">>"
              alt=">>"
              src="@/assets/keyboard_double_arrow_down_black_18dp.svg"
              src="@/assets/keyboard_double_arrow_down_black_18dp.svg"
-             @click="toggleDialog"
+             @click="toggleDialog(index)"
         />
         />
       </td>
       </td>
-      <GDialog v-model="dialog">
+      <GDialog v-model="dialog[index]">
         <ClustersList :clusters="getClustersFor(comparison.firstSubmissionId, comparison.secondSubmissionId)"
         <ClustersList :clusters="getClustersFor(comparison.firstSubmissionId, comparison.secondSubmissionId)"
                       :comparison="comparison"/>
                       :comparison="comparison"/>
       </GDialog>
       </GDialog>
@@ -67,10 +66,11 @@ export default defineComponent({
   },
   },
   setup(props) {
   setup(props) {
     let formattedMatchPercentage = (number) => number.toFixed(2)
     let formattedMatchPercentage = (number) => number.toFixed(2)
-    const dialog = ref(false)
+    const dialog = ref([])
+    props.topComparisons.forEach(() => dialog.value.push(false))
 
 
-    const toggleDialog = () => {
-      dialog.value = true
+    const toggleDialog = (index) => {
+      dialog.value[index] = true
     }
     }
 
 
     const navigateToComparisonView = (firstId, secondId) => {
     const navigateToComparisonView = (firstId, secondId) => {
@@ -111,7 +111,8 @@ export default defineComponent({
       })
       })
 
 
       return {
       return {
-        avgSim: cluster.avgSim,
+        averageSimilarity: cluster.averageSimilarity,
+        strength: cluster.strength,
         members: membersArray
         members: membersArray
       }
       }
     })
     })

+ 21 - 50
report-viewer/src/components/DistributionDiagram.vue

@@ -26,16 +26,20 @@ export default defineComponent({
     //Highest count of submissions in a percentage range. We set the diagrams maximum shown value to maxVal + 5,
     //Highest count of submissions in a percentage range. We set the diagrams maximum shown value to maxVal + 5,
     //otherwise maximum is set to the highest count of submissions and is one bar always reaches the end.
     //otherwise maximum is set to the highest count of submissions and is one bar always reaches the end.
     let maxVal = ref(Math.max(...props.distribution));
     let maxVal = ref(Math.max(...props.distribution));
-
+    const labels = ['0-10%', '11-20%', '21-30%', '31-40%', '41-50%', '51-60%', '61-70%', '71-80%', '81-90%', '91-100%']
+    const dataSetStyle = {
+      label: 'Count',
+      backgroundColor: 'rgba(149, 168, 241, 0.5)',
+      borderWidth: 2,
+      borderColor: 'rgba(149, 168, 241, 1)',
+      tickColor: '#000000'
+    }
+    
     let chartData = ref({
     let chartData = ref({
-      labels: ['0-10%', '11-20%', '21-30%', '31-40%', '41-50%', '51-60%', '61-70%', '71-80%', '81-90%', '91-100%'],
+      labels: labels,
       datasets: [{
       datasets: [{
-        label: 'Count',
+        ...dataSetStyle,
         data: props.distribution,
         data: props.distribution,
-        backgroundColor: 'rgba(149, 168, 241, 0.5)',
-        borderWidth: 2,
-        borderColor: 'rgba(149, 168, 241, 1)',
-        tickColor: '#000000'
       }]
       }]
     })
     })
 
 
@@ -75,51 +79,18 @@ export default defineComponent({
     //We watch the given distributions parameter. When the distribution of another metric is passed, the diagram is
     //We watch the given distributions parameter. When the distribution of another metric is passed, the diagram is
     //updated with the new data.
     //updated with the new data.
     watch(() => props.distribution, (val) => {
     watch(() => props.distribution, (val) => {
-      chartData.value = {
-        labels: ['0-10%', '11-20%', '21-30%', '31-40%', '41-50%', '51-60%', '61-70%', '71-80%', '81-90%', '91-100%'],
-        datasets: [{
-          label: 'Count',
-          data: val,
-          backgroundColor: 'rgba(149, 168, 241, 0.5)',
-          borderWidth: 2,
-          borderColor: 'rgba(149, 168, 241, 1)',
-        }]
-      }
-
-      maxVal.value = Math.max(...val)
-      options.value = {
-        responsive: true,
-        maintainAspectRatio: false,
-        indexAxis: 'y',
-        scales: {
-          x: {
-            suggestedMax: maxVal.value + 5,
-            ticks: {
-              color: '#000000',
-            }
-          },
-          y: {
-            ticks: {
-              color: '#000000',
-            }
-          }
-        },
-        plugins: {
-          datalabels: {
-            color: '#000000',
-            font: {
-              weight: 'bold'
-            },
-            anchor: 'end',
-            align: 'end',
-            clamp: true
-          },
-          legend: {
-            display: false,
+          chartData.value = {
+            labels: labels,
+            datasets: [{
+              ...dataSetStyle,
+              data: val,
+            }]
           }
           }
+
+          maxVal.value = Math.max(...val)
+          options.value.scales.x.suggestedMax = maxVal.value + 5
         }
         }
-      }
-    })
+    )
 
 
     return {
     return {
       chartData,
       chartData,

+ 4 - 4
report-viewer/src/router/index.ts

@@ -1,5 +1,5 @@
 import {createRouter, createWebHistory, RouteRecordRaw} from "vue-router";
 import {createRouter, createWebHistory, RouteRecordRaw} from "vue-router";
-import Overview from "@/views/OverviewView.vue";
+import OverviewView from "@/views/OverviewView.vue"
 import ComparisonView from "@/views/ComparisonView.vue"
 import ComparisonView from "@/views/ComparisonView.vue"
 import FileUploadView from "@/views/FileUploadView.vue"
 import FileUploadView from "@/views/FileUploadView.vue"
 
 
@@ -12,15 +12,15 @@ const routes: Array<RouteRecordRaw> = [
     {
     {
         path: "/overview",
         path: "/overview",
         name: "OverviewView",
         name: "OverviewView",
-        component: Overview,
+        component: OverviewView,
     },
     },
     {
     {
         path: "/comparison",
         path: "/comparison",
         name: "ComparisonView",
         name: "ComparisonView",
         component: ComparisonView,
         component: ComparisonView,
         props: route => ({
         props: route => ({
-            id1: route.query.firstId,
-            id2: route.query.secondId
+            firstId: route.query.firstId,
+            secondId: route.query.secondId
         })
         })
     },
     },
 ];
 ];