UNPKG

1.75 kBMarkdownView Raw
1## jquery.flot.composeImages.js
2
3This plugin is used to expose a function used to overlap several canvases and
4SVGs, for the purpose of creating a snaphot out of them.
5
6### When composeImages is used:
7When multiple canvases and SVGs have to be overlapped into a single image
8and their offset on the page, must be preserved.
9
10### Where can be used:
11In creating a downloadable snapshot of the plots, axes, cursors etc of a graph.
12
13### How it works:
14The entry point is composeImages function. It expects an array of objects,
15which should be either canvases or SVGs (or a mix). It does a prevalidation
16of them, by verifying if they will be usable or not, later in the flow.
17After selecting only usable sources, it passes them to getGenerateTempImg
18function, which generates temporary images out of them. This function
19expects that some of the passed sources (canvas or SVG) may still have
20problems being converted to an image and makes sure the promises system,
21used by composeImages function, moves forward. As an example, SVGs with
22missing information from header or with unsupported content, may lead to
23failure in generating the temporary image. Temporary images are required
24mostly on extracting content from SVGs, but this is also where the x/y
25offsets are extracted for each image which will be added. For SVGs in
26particular, their CSS rules have to be applied.
27After all temporary images are generated, they are overlapped using
28getExecuteImgComposition function. This is where the destination canvas
29is set to the proper dimensions. It is then output by composeImages.
30This function returns a promise, which can be used to wait for the whole
31composition process. It requires to be asynchronous, because this is how
32temporary images load their data.