-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a new Experimental Prerendering module (#1955)
# Pull Request ## 🤨 Rationale Created a new experimental prerendering module. The previous prerendering oversaw calculating the `fillstyle` of each die and it's label. We want to move these expensive operations to the web worker, and to make them faster. ## 👩💻 Implementation I removed the code which prepared the dies for rendering. I created a domain splitter for linear color scales. this will reduce the number of colors displayed but will increase the performance because we are no longer finding interpolations for each individual value in the whole domain. Open Issues: - given the problems with arquero, should we implement in-house highlight or leave it unimplemented until the issue gets fixed? ## 🧪 Testing <!--- Detail the testing done to ensure this submission meets requirements. Include automated/manual test additions or modifications, testing done on a local build, private CI run results, and additional testing not covered by automatic pull request validation. If any functionality is not covered by automated testing, provide justification. --> ## ✅ Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [x] I have updated the project documentation to reflect my changes or determined no changes are needed. --------- Co-authored-by: Milan Raj <[email protected]>
- Loading branch information
1 parent
a56f5f5
commit b6e22fe
Showing
15 changed files
with
542 additions
and
199 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@ni-nimble-components-ba1be791-36da-4c55-888b-5df015121520.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Created new Experimental Prerendering Module and tests", | ||
"packageName": "@ni/nimble-components", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
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
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
86 changes: 86 additions & 0 deletions
86
packages/nimble-components/src/wafer-map/modules/experimental/prerendering.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,86 @@ | ||
import { scaleLinear } from 'd3-scale'; | ||
import { ticks } from 'd3-array'; | ||
import { WaferMapColorScaleMode } from '../../types'; | ||
import type { ColorScale, Dimensions } from '../../types'; | ||
import type { WaferMap } from '../..'; | ||
|
||
/** | ||
* Prerendering prepares render-ready dies data to be used by the rendering module | ||
*/ | ||
export class Prerendering { | ||
public get labelsFontSize(): number { | ||
return this._labelsFontSize; | ||
} | ||
|
||
public get colorScale(): ColorScale { | ||
return this._colorScale; | ||
} | ||
|
||
private _colorScale!: ColorScale; | ||
|
||
private _labelsFontSize!: number; | ||
|
||
private readonly fontSizeFactor = 0.8; | ||
private readonly colorScaleResolution = 10; | ||
|
||
public constructor(private readonly wafermap: WaferMap) {} | ||
|
||
public update(): void { | ||
this._labelsFontSize = this.calculateLabelsFontSize( | ||
this.wafermap.experimentalDataManager.dieDimensions, | ||
this.wafermap.maxCharacters | ||
); | ||
this._colorScale = this.calculateColorScale(); | ||
} | ||
|
||
private calculateColorScale(): ColorScale { | ||
if (this.wafermap.colorScaleMode === WaferMapColorScaleMode.linear) { | ||
const values = this.wafermap.colorScale.values.map(item => +item); | ||
const d3ColorScale = scaleLinear<string, string>() | ||
.domain(values) | ||
.range(this.wafermap.colorScale.colors); | ||
let min = values[0]!; | ||
let max = values[0]!; | ||
values.forEach(value => { | ||
if (value < min) { | ||
min = value; | ||
} | ||
if (value > max) { | ||
max = value; | ||
} | ||
}); | ||
// the linear color scale will not be infinite but will be limited by the color scale resolution | ||
const valueSamples = ticks( | ||
min, | ||
max, | ||
values.length * this.colorScaleResolution | ||
); | ||
return valueSamples.map(value => { | ||
return { | ||
color: d3ColorScale(value), | ||
value | ||
}; | ||
}); | ||
} | ||
// ordinal color categories have to be sorted by value | ||
return this.wafermap.colorScale.colors | ||
.map((color, index) => { | ||
return { | ||
color, | ||
value: +this.wafermap.colorScale.values[index]! | ||
}; | ||
}) | ||
.sort((a, b) => a.value - b.value); | ||
} | ||
|
||
private calculateLabelsFontSize( | ||
dieDimensions: Dimensions, | ||
maxCharacters: number | ||
): number { | ||
return Math.min( | ||
dieDimensions.height, | ||
(dieDimensions.width / (Math.max(2, maxCharacters) * 0.5)) | ||
* this.fontSizeFactor | ||
); | ||
} | ||
} |
Oops, something went wrong.