-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
274 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...pp/components/volcano-plot/color-by-category-modal/color-by-category-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<div class="modal-header"> | ||
<div class="modal-title"> | ||
Assign Colors by Category | ||
</div> | ||
</div> | ||
<div class="modal-body"> | ||
@if (data) { | ||
<form [formGroup]="form"> | ||
<div> | ||
<label>Categorical value column</label> | ||
<select class="form-control" formControlName="selectedColumn"> | ||
@for (o of data.getColumnNames(); track o) { | ||
<option [value]="o">{{o}}</option> | ||
} | ||
</select> | ||
</div> | ||
</form> | ||
} | ||
|
||
|
||
@for (c of categories; track c) { | ||
<div> | ||
<div class="form-group"> | ||
<label for="color{{c}}">Color for {{c}}</label> | ||
<input [(ngModel)]="categoryMap[c].color" [(colorPicker)]="categoryMap[c].color" class="form-control" [style.background-color]="categoryMap[c].color"> | ||
<small class="text-muted">Count: {{categoryMap[c].count}}</small> | ||
<button type="button" class="btn btn-danger" (click)="removeGroup(c)"><i class="bi bi-trash"></i></button> | ||
</div> | ||
</div> | ||
|
||
} | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" (click)="close()">Cancel</button> | ||
<button type="button" class="btn btn-primary" (click)="submit()">Apply</button> | ||
</div> |
Empty file.
23 changes: 23 additions & 0 deletions
23
...components/volcano-plot/color-by-category-modal/color-by-category-modal.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ColorByCategoryModalComponent } from './color-by-category-modal.component'; | ||
|
||
describe('ColorByCategoryModalComponent', () => { | ||
let component: ColorByCategoryModalComponent; | ||
let fixture: ComponentFixture<ColorByCategoryModalComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ColorByCategoryModalComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ColorByCategoryModalComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
75 changes: 75 additions & 0 deletions
75
src/app/components/volcano-plot/color-by-category-modal/color-by-category-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import {Component, Input} from '@angular/core'; | ||
import {DataFrame, IDataFrame} from "data-forge"; | ||
import {FormBuilder, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms"; | ||
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap"; | ||
import {ColorPickerModule} from "ngx-color-picker"; | ||
|
||
@Component({ | ||
selector: 'app-color-by-category-modal', | ||
imports: [ | ||
ReactiveFormsModule, | ||
FormsModule, | ||
ColorPickerModule | ||
], | ||
templateUrl: './color-by-category-modal.component.html', | ||
styleUrl: './color-by-category-modal.component.scss' | ||
}) | ||
export class ColorByCategoryModalComponent { | ||
@Input() data: IDataFrame = new DataFrame() | ||
@Input() primaryIDColumn: string = "" | ||
@Input() comparisonCol: string = "" | ||
|
||
form = this.fb.group({ | ||
selectedColumn: ['', Validators.required], | ||
}) | ||
|
||
categoryMap: any = {} | ||
categories: string[] = [] | ||
constructor(private fb: FormBuilder, private activeModal: NgbActiveModal) { | ||
this.form.controls.selectedColumn.valueChanges.subscribe((value) => { | ||
if (value && this.data) { | ||
this.data.forEach((row) => { | ||
const primaryID = row[this.primaryIDColumn] | ||
const comparison = "1" | ||
if (row[this.comparisonCol]) { | ||
const comparison: string = row[this.comparisonCol] | ||
} | ||
const category = row[value] | ||
const title = `${value} ${category} (${comparison})` | ||
if (!this.categoryMap[title]) { | ||
this.categoryMap[title] = { | ||
count: 1, | ||
color: "", | ||
comparison: comparison, | ||
primaryIDs: [primaryID] | ||
} | ||
} else { | ||
this.categoryMap[title].count++ | ||
this.categoryMap[title].primaryIDs.push(primaryID) | ||
} | ||
}) | ||
this.categories = Object.keys(this.categoryMap) | ||
} | ||
}) | ||
} | ||
|
||
close() { | ||
this.activeModal.dismiss() | ||
} | ||
|
||
submit() { | ||
if (this.form.invalid) { | ||
return | ||
} | ||
this.activeModal.close({ | ||
column: this.form.controls.selectedColumn.value, | ||
categoryMap: this.categoryMap | ||
}) | ||
} | ||
|
||
removeGroup(category: string) { | ||
delete this.categoryMap[category] | ||
this.categories = Object.keys(this.categoryMap) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters