Skip to content

Commit

Permalink
updated api and made experimental option
Browse files Browse the repository at this point in the history
  • Loading branch information
munteannatan committed Feb 26, 2024
1 parent 471befc commit 7eb3bd3
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 108 deletions.
38 changes: 16 additions & 22 deletions packages/nimble-components/src/wafer-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@microsoft/fast-element';
import { DesignSystem, FoundationElement } from '@microsoft/fast-foundation';
import { zoomIdentity, ZoomTransform } from 'd3-zoom';
import type { Table, Uint32, Int32, Float32 } from 'apache-arrow';
import type { Table } from 'apache-arrow';
import { template } from './template';
import { styles } from './styles';
import { DataManager } from './modules/data-manager';
Expand All @@ -18,11 +18,12 @@ import {
WaferMapDie,
WaferMapOrientation,
WaferMapOriginLocation,
WaferMapTypeMap,
WaferMapValidity
} from './types';
import { WaferMapUpdateTracker } from './modules/wafer-map-update-tracker';
import { WaferMapValidator } from './modules/wafer-map-validator';
import { MatrixRenderer } from './modules/matrix-renderer';
import { WorkerRenderer } from './modules/worker-renderer';

declare global {
interface HTMLElementTagNameMap {
Expand All @@ -38,7 +39,7 @@ export class WaferMap extends FoundationElement {
* @internal
* needs to be initialized before the properties trigger changes
*/
public readonly waferMapUpdateTracker = new WaferMapUpdateTracker(this);
public readonly waferMapUpdateTracker: WaferMapUpdateTracker = new WaferMapUpdateTracker(this);

@attr({ attribute: 'origin-location' })
public originLocation: WaferMapOriginLocation = WaferMapOriginLocation.bottomLeft;
Expand Down Expand Up @@ -88,15 +89,15 @@ export class WaferMap extends FoundationElement {
/**
* @internal
*/
public readonly dataManager = new DataManager(this);
public readonly dataManager: DataManager = new DataManager(this);
/**
* @internal
*/
public readonly listRenderer = new RenderingModule(this);
public readonly mainRenderer = new RenderingModule(this);
/**
* @internal
*/
public readonly matrixRenderer = new MatrixRenderer(this);
public readonly workerRenderer = new WorkerRenderer(this);

/**
* @internal
Expand Down Expand Up @@ -146,19 +147,12 @@ export class WaferMap extends FoundationElement {
/**
* @internal
*/
@observable public renderStrategy: 'list' | 'matrix' = 'list';
@observable public renderStrategy: 'main' | 'worker' = 'main';

@observable public highlightedTags: string[] = [];
@observable public dies: WaferMapDie[] = [];
@observable public diesTable:
| Table<{
colIndex: Int32,
rowIndex: Int32,
value: Float32,
tags: Uint32,
metadata: never
}>
| undefined;
@observable public diesTable: Table<WaferMapTypeMap> | undefined;
@observable public highlightedTable: Table<WaferMapTypeMap> | undefined;

@observable public colorScale: WaferMapColorScale = {
colors: [],
Expand Down Expand Up @@ -224,11 +218,11 @@ export class WaferMap extends FoundationElement {
}
}

private get renderer(): RenderingModule | MatrixRenderer {
if (this.renderStrategy === 'list') {
return this.listRenderer;
private get renderer(): RenderingModule | WorkerRenderer {
if (this.renderStrategy === 'main') {
return this.mainRenderer;
}
return this.matrixRenderer;
return this.workerRenderer;
}

private createResizeObserver(): ResizeObserver {
Expand Down Expand Up @@ -300,14 +294,14 @@ export class WaferMap extends FoundationElement {

private diesChanged(): void {
this.waferMapUpdateTracker.track('dies');
this.renderStrategy = 'list';
this.renderStrategy = 'main';
this.waferMapUpdateTracker.queueUpdate();
}

private diesTableChanged(): void {
this.waferMapUpdateTracker.track('dies');
if (this.diesTable !== undefined) {
this.renderStrategy = 'matrix';
this.renderStrategy = 'worker';
}
this.waferMapUpdateTracker.queueUpdate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HoverDieOpacity } from '../types';
/**
* Responsible for drawing the dies inside the wafer map, adding dieText and scaling the canvas
*/
export class MatrixRenderer {
export class WorkerRenderer {
public constructor(private readonly wafermap: WaferMap) {}

public updateSortedDiesAndDrawWafer(): void {
Expand Down
10 changes: 3 additions & 7 deletions packages/nimble-components/src/wafer-map/tests/data-generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table, Uint32, Int32, Float32, tableFromArrays } from 'apache-arrow';
import { Table, Int32, Float32, tableFromArrays } from 'apache-arrow';
import type { WaferMapDie } from '../types';
import type { IValueGenerator } from './value-generator';

Expand Down Expand Up @@ -112,9 +112,7 @@ export const generateWaferTableData = (
): Table<{
colIndex: Int32,
rowIndex: Int32,
value: Float32,
tags: Uint32,
metadata: never
value: Float32
}> => {
const colIndex = [];
const rowIndex = [];
Expand Down Expand Up @@ -159,8 +157,6 @@ export const generateWaferTableData = (
return tableFromArrays({
colIndex: Int32Array.from(colIndex),
rowIndex: Int32Array.from(rowIndex),
value: Float32Array.from(value),
tags: Uint32Array.from([]),
metadata: [] as unknown[]
value: Float32Array.from(value)
});
};
79 changes: 41 additions & 38 deletions packages/nimble-components/src/wafer-map/tests/sets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Table, Uint32, Int32, Float32, tableFromArrays } from 'apache-arrow';
import { Table, tableFromArrays } from 'apache-arrow';
import type { WaferMapDie, WaferMapColorScale } from '../types';

export const highlightedTagsSets: string[][] = [
Expand Down Expand Up @@ -101,50 +101,53 @@ export const wafermapDieSets: WaferMapDie[][] = [
]
];

export const wafermapDiesTableSets: Table<{
colIndex: Int32,
rowIndex: Int32,
value: Float32,
tags: Uint32,
metadata: never
}>[] = [
export const wafermapDiesTableSets: Table[] = [
tableFromArrays({
colIndex: Int32Array.from([0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4]),
rowIndex: Int32Array.from([2, 2, 1, 3, 2, 1, 0, 3, 4, 2, 1, 3, 2]),
value: Float32Array.from([
14.24, 76.43, 44.63, 67.93, 72.71, 79.04, 26.49, 37.79, 59.82, 52.9,
98.5, 20.83, 62.8
]),
tags: Uint32Array.from([
0b000011, // a, b
0b000110, // b, c
0b001000, // g
0b000001, // a
0b110000, // h, e
0b000010, // b
0b000100, // c
0b000000,
0b000000,
0b000000,
0b001000, // g
0b000100, // c
0b001000 // g
]),
metadata: Array.from([
'Placeholder metadata value for Die x: 0 y: 2',
'Placeholder metadata value for Die x: 1 y: 2',
'Placeholder metadata value for Die x: 1 y: 1',
'Placeholder metadata value for Die x: 1 y: 3',
'Placeholder metadata value for Die x: 2 y: 2',
'Placeholder metadata value for Die x: 2 y: 1',
'Placeholder metadata value for Die x: 2 y: 0',
'Placeholder metadata value for Die x: 2 y: 3',
'Placeholder metadata value for Die x: 2 y: 4',
'Placeholder metadata value for Die x: 3 y: 2',
'Placeholder metadata value for Die x: 3 y: 1',
'Placeholder metadata value for Die x: 3 y: 3',
'Placeholder metadata value for Die x: 4 y: 2'
]) as unknown[]
firstTag: ['a', 'b', 'g', 'a', 'h', 'b', 'c', null, null, null, 'g', 'c', 'g'],
secondTag: ['b', 'c', null, null, 'e', null, null, null, null, null, null, null, null],
metadata: [
'metadata02',
'metadata12',
'metadata11',
'metadata13',
'metadata22',
'metadata21',
'metadata20',
'metadata23',
'metadata24',
'metadata32',
'metadata31',
'metadata33',
'metadata42'
]
})
];

export const highlightedTableSets: Table[] = [
new Table(),
tableFromArrays({
colIndex: Int32Array.from([]),
rowIndex: Int32Array.from([]),
value: Float32Array.from([]),
firstTag: ['c']
}),
tableFromArrays({
colIndex: Int32Array.from([]),
rowIndex: Int32Array.from([]),
value: Float32Array.from([]),
firstTag: ['']
}),
tableFromArrays({
colIndex: Int32Array.from([]),
rowIndex: Int32Array.from([]),
value: Float32Array.from([]),
firstTag: ['a', 'b', 'c']
})
];

Expand Down
Loading

0 comments on commit 7eb3bd3

Please sign in to comment.