Skip to content

Commit

Permalink
Responsive printing docs (#5167)
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg authored Jan 21, 2018
1 parent 26c44cf commit 9a0117a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/general/responsive.md
Original file line number Diff line number Diff line change
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 9a0117a

Please sign in to comment.