Skip to content
Snippets Groups Projects
Commit 6b652ed7 authored by Karolína Dočkalová Burská's avatar Karolína Dočkalová Burská
Browse files

Add check for NaN and 0

parent cd88e959
No related branches found
No related tags found
1 merge request!4Resolve "Indicate insufficient data"
Pipeline #210194 passed
# KYPO Trainings Clustering Visualization # KYPO Trainings Clustering Visualization
## Prerequisites The visualization provides three views with distinct processing of collected data - a subset of features that define the trainee behavior and enable us to explore outliers or trainee strategies during their gameplay.
To use the library you need to have installed:
## How to use json-server as mock backend with provided dummy data ## How to use json-server as mock backend with provided dummy data
......
This diff is collapsed.
...@@ -2,7 +2,6 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angu ...@@ -2,7 +2,6 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angu
import { D3, D3Service } from '@muni-kypo-crp/d3-service'; import { D3, D3Service } from '@muni-kypo-crp/d3-service';
import { AppConfig } from '../../../../app.config'; import { AppConfig } from '../../../../app.config';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import {VisualizationData} from "../../../models/visualization-data";
@Component({ @Component({
selector: 'kypo-viz-clustering-line-chart', selector: 'kypo-viz-clustering-line-chart',
...@@ -57,14 +56,18 @@ export class LineChartComponent implements OnChanges, OnInit { ...@@ -57,14 +56,18 @@ export class LineChartComponent implements OnChanges, OnInit {
if (this.gChart != undefined) { if (this.gChart != undefined) {
this.clear(); this.clear();
} }
this.checkData(); if (this.checkData()) {
this.createSvg(); this.createSvg();
this.drawPlot(); this.drawPlot();
}
} }
checkData() { checkData() {
// TODO const isAllNothing = this.visualizationData.every((value) => value === 0 || Number.isNaN(value) || value === null);
console.log(this.visualizationData); if (isAllNothing) {
this.insufficientData.emit(true);
}
return !isAllNothing;
} }
private createSvg(): void { private createSvg(): void {
......
<ng-container> <ng-container *ngIf="!hideChart">
<!-- the line chart is available for every graph type (it can be hidden in the form of a button) --> <!-- the line chart is available for every graph type (it can be hidden in the form of a button) -->
<kypo-viz-clustering-line-chart <kypo-viz-clustering-line-chart
[visualizationData]="lineData$" [visualizationData]="lineData$"
......
...@@ -4,7 +4,6 @@ import { VisualizationData } from '../../models/visualization-data'; ...@@ -4,7 +4,6 @@ import { VisualizationData } from '../../models/visualization-data';
import { VisualizationsDataService } from '../../services/visualizations-data.service'; import { VisualizationsDataService } from '../../services/visualizations-data.service';
import { Clusterables } from '../../models/clusterables-enum'; import { Clusterables } from '../../models/clusterables-enum';
import { Components } from '../../models/components-enum'; import { Components } from '../../models/components-enum';
import { RadarChartComponent } from './radar-chart/radar-chart.component';
@Component({ @Component({
selector: 'kypo-clustering-visualization', selector: 'kypo-clustering-visualization',
...@@ -21,8 +20,10 @@ export class VisualizationsComponent implements OnInit, OnChanges { ...@@ -21,8 +20,10 @@ export class VisualizationsComponent implements OnInit, OnChanges {
@Input() selectedFeature: Clusterables = Clusterables.WrongFlags; // (wf 1, tah 2, nd 3) @Input() selectedFeature: Clusterables = Clusterables.WrongFlags; // (wf 1, tah 2, nd 3)
@Output() viewOpen: EventEmitter<boolean> = new EventEmitter(); @Output() viewOpen: EventEmitter<boolean> = new EventEmitter();
@Output() chartIsHidden: EventEmitter<boolean> = new EventEmitter();
elbowNumClusters = 15; // this ensures we don't load data after every line chart change (15 clusters should be more than enough) hideChart = false;
elbowNumClusters = 15; // this ensures we don't load different data after every line chart change (15 clusters should be just enough)
lineData$: Observable<VisualizationData>; lineData$: Observable<VisualizationData>;
visualizationData$: Observable<VisualizationData>; visualizationData$: Observable<VisualizationData>;
...@@ -78,7 +79,10 @@ export class VisualizationsComponent implements OnInit, OnChanges { ...@@ -78,7 +79,10 @@ export class VisualizationsComponent implements OnInit, OnChanges {
} }
} }
checkData(displayChart: boolean) { checkData(hideChart: boolean) {
// if we don't have enough data for sse, we should hide the remaining related
// charts as well, since they will also lack data for visualization
this.hideChart = hideChart;
if (hideChart) this.chartIsHidden.emit(true);
} }
} }
...@@ -1656,6 +1656,18 @@ clusteringDB = function() { ...@@ -1656,6 +1656,18 @@ clusteringDB = function() {
7.665157027831233, 7.665157027831233,
3.286652416172358 3.286652416172358
], ],
sseWrong:[
NaN,
0,
0,
NaN,
NaN,
NaN,
NaN,
NaN,
NaN,
NaN
],
sseNDim: [ sseNDim: [
165, 165,
144.16192694574772, 144.16192694574772,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment