2016-06-17 34 views

回答

0

主项目页面并不便于链接,但它看起来像标题为“定义你自己的模板”的部分是你要找的?

编辑:

OK,以更好地了解你在找什么,我发挥它周围的自己,发现画布元素的widthheight性能added to the DOM programmatically in GitGraph.prototype.render(),基于一些中等复杂的数学涉及来自template对象的一堆值,以及使用window.devicePixelRatio导出的值scalingFactor

似乎有不被修改这些值之前画布渲染的方式,但使用提供graph:render事件,你可以后做

gitGraph.canvas.addEventListener("graph:render", function(event) { 
    console.log(event.data.id, "has been rendered with a scaling factor of", gitGraph.scalingFactor); 
    rescale(); 
} 
function rescale() { 
    var g = document.getElementById('gitGraph'); 
    var w = +g.style.width.slice(0,-2) * 0.5; // < just change these two 
    var h = +g.style.height.slice(0,-2) * 0.5; // multipliers to the same 
    g.style.width = w + 'px';     // value 
    g.style.height = h + 'px'; 
}; 

下面是功能与官方的示例代码工作(注意到它搞砸了绝对定位detail格):

http://codepen.io/phoward8020/pen/ZOpERB

这是否帮助?

(编辑2:内嵌堆栈溢出示例代码不添加值来回答,因为它是不可编辑与CodePen代替以便读者可以验证通过改变乘法器的值的功能。)

+0

限定的造型和间隔信息。它是否也定义了比例尺? – chrisrhyno2003

+0

啊。现在我明白你在问什么了。 gitgraph绘制到一个HTML''元素。您是否尝试过[在画布上使用'scale()'方法](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations#Scaling)? – phoward8020

+0

Nopee。我没有尝试过。我去做。 – chrisrhyno2003