admin管理员组文章数量:1415491
I am designing a UI that uses jointjs to draw a graph.
I need to change the background color of the Paper but I see that changing the .viewport css (e.g. background-color: #ff0000;
) this doesn't affect the appearance of the svg.
How can I add color in the background of the jointjs Paper?
thanks
I am designing a UI that uses jointjs to draw a graph.
I need to change the background color of the Paper but I see that changing the .viewport css (e.g. background-color: #ff0000;
) this doesn't affect the appearance of the svg.
How can I add color in the background of the jointjs Paper?
thanks
Share Improve this question asked Sep 24, 2015 at 14:02 theosemtheosem 1,2043 gold badges12 silver badges22 bronze badges 2- 1 create a rect the size of the viewport and set it to the colour you want. – Robert Longson Commented Sep 24, 2015 at 14:08
- @RobertLongson thanks for the answer. I don't see this as a clean approach, meaning that I should then keep track of another cell in case of resize etc. Are you sure there is no other way to do this? thanks – theosem Commented Sep 24, 2015 at 14:11
4 Answers
Reset to default 3When initializing paper, add background option to paper
var paper = new joint.dia.Paper({
background: {
color: '#ff0000'
}
});
You can find more info at Jointjs paper documentation.
The paper is just a normal HTML <div>
element so you can set the background-color: #ff00000
on that <div>
element rather than on the internal .viewport
SVG <g>
element.
I changed the svg element style in css to change the paper background color and it works for me. Here is an example.
svg {
background-color: blue;
}
If you want to change the background of a paper on runtime:
paper.options.background = { color: '#FF0000' };
paper.render()
Testet with jointjs v4.1
本文标签: javascriptjointjs paper background colorStack Overflow
版权声明:本文标题:javascript - jointjs paper background color - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745154233a2645069.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论