Skip to content

Commit

Permalink
linting fixes (whitespace removal, simplifications)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisonPearl committed Jul 20, 2020
1 parent 012a140 commit 61b6545
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
18 changes: 9 additions & 9 deletions src/components/vr-accessibility/vr-accessibility.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ export class VRAccessibilityComponent implements OnInit, OnChanges, OnDestroy, A
private vrHapticPlot: Hapticplot = new Hapticplot('a-sphere');
private shape: string;
private color: string;
@ViewChild('theScene') theScene : ElementRef;
@ViewChild('theScene') theScene: ElementRef;


constructor(
) {

constructor() {
}
ngOnInit() {

ngOnInit() {
}

ngOnDestroy() {
}

ngOnChanges(changes: SimpleChanges): void {
}
ngAfterViewInit(){
let scene = this.theScene.nativeElement;
this.vrHapticPlot.init(scene, [0, 1/5, 2/5, 3/5, 4/5, 5/5, 6/5]);

ngAfterViewInit(){
const scene = this.theScene.nativeElement;
this.vrHapticPlot.init(scene, [0, 1 / 5, 2 / 5, 3 / 5, 4 / 5, 5 / 5, 6 / 5]);
}

}
2 changes: 1 addition & 1 deletion src/d3/hapticplot.d3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('VR Haptic Plot', () => {
const result = getPosition(element, shape);
expect(result).toEqual(expectedPosArray);
});

it('places points for each element in a eight element array', () => {
hapticplot.init(element, [10, 10, 20, 20, 30, 30, 40, 40]);
const expectedPosArray = [
Expand Down
24 changes: 12 additions & 12 deletions src/d3/hapticplot.d3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export class Hapticplot{
// create a scale so that there is correspondence between data set and screen render
this.hscale = d3.scaleLinear();
this.hscale.domain([0, d3.max(this.data) as number]) // max of dataset
.range([0, 100]);
.range([0, 100]);
this.setupPoints('blue', 0.1); // linear mapping of data set values to values from 0 to 10
this.createSky();
this.createGridPlane();
}

// selects all entities of type this.shape
private getShapes(){
return d3.select(this.container).selectAll("datapoint");
return d3.select(this.container).selectAll('datapoint');
}

private setupPoints(color, size) {
Expand All @@ -35,11 +35,11 @@ export class Hapticplot{
*/
this.getShapes()
// Adds points of type this.shape to the scene
// - "enter" identifies any DOM elements to be added when # array
// - "enter" identifies any DOM elements to be added when # array
// elements & # DOM elements don't match
.data(this.data).enter().append(this.shape).classed("datapoint", true)
.data(this.data).enter().append(this.shape).classed('datapoint', true)
// Updates points positions based on ingested data
.attr('position', (d, i) => { return this.generatePositions(d, i); })
.attr('position', (d, i) => this.generatePositions(d, i))
// Adds given color property to all points
.attr('color', color)
// Sets points radius property
Expand All @@ -51,21 +51,21 @@ export class Hapticplot{
.attr('draggable', '')
.attr('dropppable', '')
// Adds listeners for state change events, which trigger a change in the
// point's color property when a hover event occurs
.on('stateadded', (d, i, g) => { this.modifyColorOnStateChange(g[i], 'hovered', 'orange') })
.on('stateremoved', (d, i, g) => { this.modifyColorOnStateChange(g[i], 'hovered', 'green') })
// point's color property when a hover event occurs
.on('stateadded', (d, i, g) => this.modifyColorOnStateChange(g[i], 'hovered', 'orange'))
.on('stateremoved', (d, i, g) => this.modifyColorOnStateChange(g[i], 'hovered', 'green'));

}

private modifyColorOnStateChange(entity, state , color){
if (d3.event.detail === state){
d3.select(entity).attr('color', color);
}
}

// Generates a world space position for each data entity, based on ingested data
private generatePositions (data, index){
const x = index/10;
private generatePositions(data, index){
const x = index / 10;
const y = data;
const z = -1;
return `${x} ${y} ${z}`;
Expand Down

0 comments on commit 61b6545

Please sign in to comment.