Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add platform basic implementation (fallback) (#4708)
If `window` or `document` are `undefined`, a minimal platform implementation is used instead, which one only returns a context2d read from the given canvas/context.
- Loading branch information
1 parent
e3b70e0
commit c7464eb
Showing
3 changed files
with
25 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Platform fallback implementation (minimal). | ||
* @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-319575939 | ||
*/ | ||
|
||
module.exports = { | ||
acquireContext: function(item) { | ||
if (item && item.canvas) { | ||
// Support for any object associated to a canvas (including a context2d) | ||
item = item.canvas; | ||
} | ||
|
||
return item && item.getContext('2d') || null; | ||
} | ||
}; |
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