Skip to content

Commit

Permalink
Responsive printing docs (chartjs#5167)
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Jan 21, 2018
1 parent 4e7864a commit 32cf39b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/general/responsive.md
Expand Up @@ -33,3 +33,15 @@ The chart can also be programmatically resized by modifying the container size:
```javascript
chart.canvas.parentNode.style.height = '128px';
```

## Printing Resizeable Charts

CSS media queries allow changing styles when printing a page. The CSS applied from these media queries may cause charts to need to resize. However, the resize won't happen automatically. To support resizing charts when printing, one needs to hook the [onbeforeprint](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint) event and manually trigger resizing of each chart.

```javascript
function beforePrintHandler () {
for (var id in Chart.instances) {
Chart.instances[id].resize()
}
}
```

0 comments on commit 32cf39b

Please sign in to comment.