-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 188710376-breakup-dependency-tree-part1
- Loading branch information
Showing
24 changed files
with
594 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"buildNumber":2086} | ||
{"buildNumber":2087} |
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
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
47 changes: 47 additions & 0 deletions
47
v3/src/components/data-display/models/data-display-render-state.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,47 @@ | ||
import { graphSnapshot } from "../../graph/utilities/image-utils" | ||
import { PixiPointsArray } from "../pixi/pixi-points" | ||
|
||
export class DataDisplayRenderState { | ||
pixiPointsArray: PixiPointsArray | ||
displayElement: HTMLElement | ||
getTitle?: (() => string | undefined) | ||
dataUri?: string | ||
|
||
constructor( | ||
pixiPointsArray: PixiPointsArray, | ||
displayElement: HTMLElement, | ||
getTitle?: () => string, | ||
dataUri?: string | ||
) { | ||
this.pixiPointsArray = pixiPointsArray | ||
this.displayElement = displayElement | ||
this.getTitle = getTitle | ||
this.dataUri = dataUri | ||
} | ||
|
||
setDataUri(dataUri: string) { | ||
this.dataUri = dataUri | ||
} | ||
|
||
async updateSnapshot() { | ||
const title = this.getTitle?.() || "" | ||
const pixiPoints = this.pixiPointsArray?.[0] | ||
if (!this.displayElement || !pixiPoints) return | ||
|
||
const width = this.displayElement.getBoundingClientRect().width ?? 0 | ||
const height = this.displayElement.getBoundingClientRect().height ?? 0 | ||
const svgElementsToImageOptions = { | ||
rootEl: this.displayElement, | ||
graphWidth: width, | ||
graphHeight: height, | ||
graphTitle: title, | ||
asDataURL: true, | ||
pixiPoints | ||
} | ||
const graphImage = await graphSnapshot(svgElementsToImageOptions) | ||
const dataUri = typeof graphImage === "string" ? graphImage : undefined | ||
if (dataUri) { | ||
this.setDataUri(dataUri) | ||
} | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
v3/src/components/graph/graph-data-display-handler.test.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 { graphDataDisplayHandler } from "./graph-data-display-handler" | ||
import { ITileContentModel } from "../../models/tiles/tile-content" | ||
import { kGraphTileType } from "./graph-defs" | ||
|
||
describe("graphDataDisplayHandler", () => { | ||
it("should return an exportDataUri for a graph", async () => { | ||
const graphContent = { | ||
renderState: { | ||
updateSnapshot: jest.fn(), | ||
dataUri: "data:image/png;base64," | ||
}, | ||
type: kGraphTileType | ||
} as Partial<ITileContentModel> | ||
const result = await graphDataDisplayHandler.get(graphContent as ITileContentModel) | ||
expect(result).toEqual({ exportDataUri: "data:image/png;base64,", success: true }) | ||
}) | ||
|
||
it("should return success as false for other types", async () => { | ||
const content = { type: "table" } as ITileContentModel | ||
const result = await graphDataDisplayHandler.get(content) | ||
expect(result).toEqual({ success: false }) | ||
}) | ||
}) |
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,16 @@ | ||
import { DIDataDisplayHandler } from "../../data-interactive/handlers/data-display-handler" | ||
import { ITileContentModel } from "../../models/tiles/tile-content" | ||
import { isGraphContentModel } from "./models/graph-content-model" | ||
|
||
export const graphDataDisplayHandler: DIDataDisplayHandler = { | ||
async get(content: ITileContentModel) { | ||
|
||
if (isGraphContentModel(content)) { | ||
await content?.renderState?.updateSnapshot() | ||
const exportDataUri = content?.renderState?.dataUri | ||
return { exportDataUri, success: !!exportDataUri } | ||
} else { | ||
return { success: false } | ||
} | ||
} | ||
} |
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
Oops, something went wrong.