diff --git a/packages/nimble-components/src/wafer-map/index.ts b/packages/nimble-components/src/wafer-map/index.ts index 05a806cc0b..85db26effa 100644 --- a/packages/nimble-components/src/wafer-map/index.ts +++ b/packages/nimble-components/src/wafer-map/index.ts @@ -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'; @@ -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 { @@ -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; @@ -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 @@ -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 | undefined; + @observable public highlightedTable: Table | undefined; @observable public colorScale: WaferMapColorScale = { colors: [], @@ -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 { @@ -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(); } diff --git a/packages/nimble-components/src/wafer-map/modules/matrix-renderer.ts b/packages/nimble-components/src/wafer-map/modules/worker-renderer.ts similarity index 98% rename from packages/nimble-components/src/wafer-map/modules/matrix-renderer.ts rename to packages/nimble-components/src/wafer-map/modules/worker-renderer.ts index ab2178a14a..a4c6387d9f 100644 --- a/packages/nimble-components/src/wafer-map/modules/matrix-renderer.ts +++ b/packages/nimble-components/src/wafer-map/modules/worker-renderer.ts @@ -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 { diff --git a/packages/nimble-components/src/wafer-map/tests/data-generator.ts b/packages/nimble-components/src/wafer-map/tests/data-generator.ts index 1f6cd4977e..dc08665e4d 100644 --- a/packages/nimble-components/src/wafer-map/tests/data-generator.ts +++ b/packages/nimble-components/src/wafer-map/tests/data-generator.ts @@ -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'; @@ -112,9 +112,7 @@ export const generateWaferTableData = ( ): Table<{ colIndex: Int32, rowIndex: Int32, - value: Float32, - tags: Uint32, - metadata: never + value: Float32 }> => { const colIndex = []; const rowIndex = []; @@ -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) }); }; diff --git a/packages/nimble-components/src/wafer-map/tests/sets.ts b/packages/nimble-components/src/wafer-map/tests/sets.ts index 4c72d2f488..99352f1d82 100644 --- a/packages/nimble-components/src/wafer-map/tests/sets.ts +++ b/packages/nimble-components/src/wafer-map/tests/sets.ts @@ -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[][] = [ @@ -101,13 +101,7 @@ 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]), @@ -115,36 +109,45 @@ export const wafermapDiesTableSets: Table<{ 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'] }) ]; diff --git a/packages/nimble-components/src/wafer-map/tests/wafer-map.stories.ts b/packages/nimble-components/src/wafer-map/tests/wafer-map.stories.ts index 5485e51edc..3b0f4e98f1 100644 --- a/packages/nimble-components/src/wafer-map/tests/wafer-map.stories.ts +++ b/packages/nimble-components/src/wafer-map/tests/wafer-map.stories.ts @@ -1,6 +1,6 @@ import { html } from '@microsoft/fast-element'; import type { Meta, StoryObj } from '@storybook/html'; -import type { Table, Uint32, Int32, Float32 } from 'apache-arrow'; +import type { Table, Int32, Float32 } from 'apache-arrow'; import { createUserSelectedThemeStory, incubatingWarning @@ -25,7 +25,8 @@ import { highlightedTagsSets, wafermapDieSets, waferMapColorScaleSets, - wafermapDiesTableSets + wafermapDiesTableSets, + highlightedTableSets } from './sets'; import { waferMapTag } from '..'; @@ -34,8 +35,11 @@ interface WaferMapArgs { colorScaleMode: WaferMapColorScaleMode; dieLabelsHidden: boolean; dieLabelsSuffix: string; + apiVersion: 'stable' | 'experimental'; dies: string; + highlightedTags: string; diesTable: string; + highlightedTable: string; maxCharacters: number; orientation: WaferMapOrientation; originLocation: WaferMapOriginLocation; @@ -45,7 +49,6 @@ interface WaferMapArgs { gridMaxY: number | undefined; dieHover: unknown; validity: WaferMapValidity; - highlightedTags: string; } const getDiesSet = ( @@ -90,17 +93,13 @@ const getDiesTableSet = ( sets: Table<{ colIndex: Int32, rowIndex: Int32, - value: Float32, - tags: Uint32, - metadata: never + value: Float32 }>[] ): | Table<{ colIndex: Int32, rowIndex: Int32, - value: Float32, - tags: Uint32, - metadata: never + value: Float32 }> | undefined => { const seed = 0.5; @@ -108,9 +107,7 @@ const getDiesTableSet = ( | Table<{ colIndex: Int32, rowIndex: Int32, - value: Float32, - tags: Uint32, - metadata: never + value: Float32 }> | undefined; switch (setName) { @@ -163,9 +160,44 @@ const getHighlightedTags = (setName: string, sets: string[][]): string[] => { return returnedValue; }; +const getHighlightedTable = (setName: string, sets: Table<{ + colIndex: Int32, + rowIndex: Int32, + value: Float32 +}>[]): Table<{ + colIndex: Int32, + rowIndex: Int32, + value: Float32 +}> | undefined => { + let returnedValue: Table<{ + colIndex: Int32, + rowIndex: Int32, + value: Float32 + }> | undefined; + switch (setName) { + case 'set1': + returnedValue = sets[0]!; + break; + case 'set2': + returnedValue = sets[1]!; + break; + case 'set3': + returnedValue = sets[2]!; + break; + case 'set4': + returnedValue = sets[3]!; + break; + default: + returnedValue = undefined; + break; + } + return returnedValue; +}; + const metadata: Meta = { title: 'Incubating/Wafer Map', parameters: { + viewMode: 'docs', actions: { handles: ['click', 'die-hover'] } @@ -184,8 +216,9 @@ const metadata: Meta = { grid-max-y=${x => x.gridMaxY} :colorScale="${x => x.colorScale}" :dies="${x => getDiesSet(x.dies, wafermapDieSets)}" - :diesTable="${x => getDiesTableSet(x.diesTable, wafermapDiesTableSets)}" :highlightedTags="${x => getHighlightedTags(x.highlightedTags, highlightedTagsSets)}" + :diesTable="${x => getDiesTableSet(x.diesTable, wafermapDiesTableSets)}" + :highlightedTable="${x => getHighlightedTable(x.highlightedTable, highlightedTableSets)}" >