Kind: global class
- CanvasRenderService
- new CanvasRenderService(width, height, chartCallback, type, chartJsFactory)
- .renderToDataURL(configuration, mimeType)
- .renderToDataURLSync(configuration, mimeType)
- .renderToBuffer(configuration, mimeType)
- .renderToBufferSync(configuration, mimeType)
- .renderToStream(configuration, mimeType)
- .registerFont(path, options)
Create a new instance of CanvasRenderService.
| Param | Description |
|---|---|
| width | The width of the charts to render, in pixels. |
| height | The height of the charts to render, in pixels. |
| chartCallback | optional callback which is called once with a new ChartJS global reference as the only parameter. |
| type | optional The canvas type ('PDF' or 'SVG'), see the canvas pdf doc. |
| chartJsFactory | optional provider for chart.js. |
Render to a data url.
Kind: instance method of CanvasRenderService
See: https://github.com/Automattic/node-canvas#canvastodataurl
| Param | Default | Description |
|---|---|---|
| configuration | The Chart JS configuration for the chart to render. | |
| mimeType | image/png |
The image format, image/png or image/jpeg. |
Render to a data url synchronously.
Kind: instance method of CanvasRenderService
See: https://github.com/Automattic/node-canvas#canvastodataurl
| Param | Default | Description |
|---|---|---|
| configuration | The Chart JS configuration for the chart to render. | |
| mimeType | image/png |
The image format, image/png or image/jpeg. |
Render to a buffer.
Kind: instance method of CanvasRenderService
See: https://github.com/Automattic/node-canvas#canvastobuffer
| Param | Default | Description |
|---|---|---|
| configuration | The Chart JS configuration for the chart to render. | |
| mimeType | image/png |
A string indicating the image format. Valid options are image/png, image/jpeg (if node-canvas was built with JPEG support) or raw (unencoded ARGB32 data in native-endian byte order, top-to-bottom). Defaults to image/png for image canvases, or the corresponding type for PDF or SVG canvas. |
Render to a buffer synchronously.
Kind: instance method of CanvasRenderService
See: https://github.com/Automattic/node-canvas#canvastobuffer
| Param | Default | Description |
|---|---|---|
| configuration | The Chart JS configuration for the chart to render. | |
| mimeType | image/png |
A string indicating the image format. Valid options are image/png, image/jpeg (if node-canvas was built with JPEG support), raw (unencoded ARGB32 data in native-endian byte order, top-to-bottom), application/pdf (for PDF canvases) and image/svg+xml (for SVG canvases). Defaults to image/png for image canvases, or the corresponding type for PDF or SVG canvas. |
Render to a stream.
Kind: instance method of CanvasRenderService
See: https://github.com/Automattic/node-canvas#canvascreatepngstream
| Param | Default | Description |
|---|---|---|
| configuration | The Chart JS configuration for the chart to render. | |
| mimeType | image/png |
A string indicating the image format. Valid options are image/png, image/jpeg (if node-canvas was built with JPEG support), application/pdf (for PDF canvases) and image/svg+xml (for SVG canvases). Defaults to image/png for image canvases, or the corresponding type for PDF or SVG canvas. |
Use to register the font with Canvas to use a font file that is not installed as a system font, this must be done before the Canvas is created.
Kind: instance method of CanvasRenderService
| Param | Description |
|---|---|
| path | The path to the font file. |
| options | The font options. |
Example
registerFont('comicsans.ttf', { family: 'Comic Sans' });