Skip to content

Commit

Permalink
This modifies jqPlot to support retina displays.
Browse files Browse the repository at this point in the history
  • Loading branch information
halfdan committed Dec 17, 2013
1 parent 5d44202 commit 9c58e9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libs/jqplot/build_minified_script.sh
Expand Up @@ -21,6 +21,6 @@ cat plugins/jqplot.categoryAxisRenderer.js >> jqplot-custom.min.js-temp
cat plugins/jqplot.canvasTextRenderer.js >> jqplot-custom.min.js-temp
cat plugins/jqplot.canvasAxisTickRenderer.js >> jqplot-custom.min.js-temp

java -jar ../../js/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar --type js --line-break 1000 jqplot-custom.min.js-temp > jqplot-custom.min.js
java -jar ../../js/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar --type js --line-break 1000 jqplot-custom.min.js-temp > jqplot-custom.min.js

rm ./jqplot-custom.min.js-temp
4 changes: 2 additions & 2 deletions libs/jqplot/jqplot-custom.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions libs/jqplot/jqplot.core.js
Expand Up @@ -295,6 +295,24 @@
if ($.jqplot.use_excanvas) {
return window.G_vmlCanvasManager.initElement(canvas);
}
var cctx = canvas.getContext('2d');

var canvasBackingScale = 1;
if (window.devicePixelRatio > 1 && (cctx.webkitBackingStorePixelRatio === undefined ||
cctx.webkitBackingStorePixelRatio < 2)) {
canvasBackingScale = window.devicePixelRatio;
}
var oldWidth = canvas.width;
var oldHeight = canvas.height;

canvas.width = canvasBackingScale * canvas.width;
canvas.height = canvasBackingScale * canvas.height;
canvas.style.width = oldWidth + 'px';
canvas.style.height = oldHeight + 'px';
cctx.save();

cctx.scale(canvasBackingScale, canvasBackingScale);

return canvas;
};

Expand Down

0 comments on commit 9c58e9d

Please sign in to comment.