|
|
@ -44,6 +44,15 @@ var gitGraph = function (canvas, rawGraphList, config) { |
|
|
|
|
|
|
|
|
|
|
|
var ctx = canvas.getContext("2d"); |
|
|
|
var ctx = canvas.getContext("2d"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var devicePixelRatio = window.devicePixelRatio || 1; |
|
|
|
|
|
|
|
var backingStoreRatio = ctx.webkitBackingStorePixelRatio || |
|
|
|
|
|
|
|
ctx.mozBackingStorePixelRatio || |
|
|
|
|
|
|
|
ctx.msBackingStorePixelRatio || |
|
|
|
|
|
|
|
ctx.oBackingStorePixelRatio || |
|
|
|
|
|
|
|
ctx.backingStorePixelRatio || 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ratio = devicePixelRatio / backingStoreRatio; |
|
|
|
|
|
|
|
|
|
|
|
var init = function () { |
|
|
|
var init = function () { |
|
|
|
var maxWidth = 0; |
|
|
|
var maxWidth = 0; |
|
|
|
var i; |
|
|
|
var i; |
|
|
@ -61,12 +70,20 @@ var gitGraph = function (canvas, rawGraphList, config) { |
|
|
|
graphList.unshift(row); |
|
|
|
graphList.unshift(row); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
canvas.width = maxWidth * config.unitSize; |
|
|
|
var width = maxWidth * config.unitSize; |
|
|
|
canvas.height = graphList.length * config.unitSize; |
|
|
|
var height = graphList.length * config.unitSize; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
canvas.width = width * ratio; |
|
|
|
|
|
|
|
canvas.height = height * ratio; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
canvas.style.width = width + 'px'; |
|
|
|
|
|
|
|
canvas.style.height = height + 'px'; |
|
|
|
|
|
|
|
|
|
|
|
ctx.lineWidth = config.lineWidth; |
|
|
|
ctx.lineWidth = config.lineWidth; |
|
|
|
ctx.lineJoin = "round"; |
|
|
|
ctx.lineJoin = "round"; |
|
|
|
ctx.lineCap = "round"; |
|
|
|
ctx.lineCap = "round"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.scale(ratio, ratio); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var genRandomStr = function () { |
|
|
|
var genRandomStr = function () { |
|
|
@ -186,7 +203,7 @@ var gitGraph = function (canvas, rawGraphList, config) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
y = canvas.height - config.unitSize * 0.5; |
|
|
|
y = (canvas.height / ratio) - config.unitSize * 0.5; |
|
|
|
|
|
|
|
|
|
|
|
//iterate
|
|
|
|
//iterate
|
|
|
|
for (i = 0, l = graphList.length; i < l; i++) { |
|
|
|
for (i = 0, l = graphList.length; i < l; i++) { |
|
|
|