mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-04 07:24:02 +01:00
21 lines
734 B
JavaScript
21 lines
734 B
JavaScript
/**
|
|
* Platform fallback implementation (minimal).
|
|
* @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-319575939
|
|
*/
|
|
|
|
import BasePlatform from './platform.base';
|
|
|
|
/**
|
|
* Platform class for charts without access to the DOM or to many element properties
|
|
* This platform is used by default for any chart passed an OffscreenCanvas.
|
|
* @extends BasePlatform
|
|
*/
|
|
export default class BasicPlatform extends BasePlatform {
|
|
acquireContext(item) {
|
|
// To prevent canvas fingerprinting, some add-ons undefine the getContext
|
|
// method, for example: https://github.com/kkapsner/CanvasBlocker
|
|
// https://github.com/chartjs/Chart.js/issues/2807
|
|
return item && item.getContext && item.getContext('2d') || null;
|
|
}
|
|
}
|