Skip to main content

Chart Sharing Provider

ChartSharingProvider is a way to share user's chart screenshots with other people across the Internet.

ChartSharingProvider is only provides you a Blob with the screenshot of the chart. You can then operate with this Blob as you want.

Basically for an integration you need to use/implement some image hosting service, that will store given Blob and give you an URL for that Blob in turn, which then can be used by users to access the screenshot.

Example

/** Copyright ©2024 Devexperts LLC.
All rights reserved. Any unauthorized use will constitute an infringement of copyright.
In case of any questions regarding types of use, please contact legal@devexperts.com.
This notice must remain intact.
**/
/**
* Creates mock implementation of {@link ChartSharingProvider}.
*/
export function createMockChartSharingProvider() {
/**
* For mock purposes there's no image service to upload a snapshot to generate a URL.
* Therefore we just encode image blob via URL.createObjectURL(blob) and return the result.
* It is not a real URL, but it can be used for demo purposes.
*
* NOTE: You can use any image hosting service you want here or implement your own.
*/
const uploadChartSnapshot = (blob) => {
return new Promise(resolve => resolve({
url: URL.createObjectURL(blob),
}));
};
return {
uploadChartSnapshot,
};
}

API Reference

ChartSharingProvider

To share chart snapshot images

ChartSharingProvider.uploadChartSnapshot
ChartSharingProvider.uploadChartSnapshot(blob: Blob, options: UploadOptions): Promise<UploadResult>

Uploads image on server and returns a link to uploaded image

Parameters
blob: Blob
image to share
options: UploadOptions
Returns
Promise<UploadResult>