响应式联合js图
Responsive joint js diagram
我正在使用联合 js 库在 html 中创建一个图表,但我需要它像 mi site.Thing 一样响应,我把它放在 div 中 [= =22=] class 使用此代码打开和关闭:
$('.open-down-up').click(function(){
var nameMore = $(this).attr("name");
var valMore = $(this).attr("value");
if(valMore == 0){
$(this).find('span').empty();
$(this).find('span').append("▼");
$('div[id='+nameMore+']').slideDown("normal");
$(this).attr("value","1");
}else if(valMore == 1){
$(this).find('span').empty();
$(this).find('span').append("►");
var n = nameMore.indexOf("process_process");
$('div[id='+nameMore+']').slideUp("normal", function(){
var n = nameMore.indexOf("process_process");
if(n > -1){
hide_panel_all();
}
});
$(this).attr("value","0");
}
});
所以,我已经尝试过类似的东西:
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: $('#modelCanvas'),
gridSize: 10,
height: $('#modelCanvas').height(),
width: $('#modelCanvas').width(),
gridSize: 1,
model: graph,
});
但它不起作用...我可以应用任何想法或方法吗??
提前致谢。
我找到了一种方法,它可能对需要它的人有帮助(用于调整大小响应):
需要将整张纸随着window一起缩放,所以,我们在上面创建一个javascript事件:
window.onresize = function(event) {
paper.setDimensions($('#your_div_id').width());
paper.scaleContentToFit({minScaleX: 0.3, minScaleY: 0.3, maxScaleX: 1 , maxScaleY: 1});
};
使用联合 js 属性,根据该事件调整 canvas 和 div 的大小但仅影响宽度,然后为 X 轴和 Y 轴设置最大比例。当然,您可以根据需要调整它的条件。
希望对我有所帮助!
我正在使用联合 js 库在 html 中创建一个图表,但我需要它像 mi site.Thing 一样响应,我把它放在 div 中 [= =22=] class 使用此代码打开和关闭:
$('.open-down-up').click(function(){
var nameMore = $(this).attr("name");
var valMore = $(this).attr("value");
if(valMore == 0){
$(this).find('span').empty();
$(this).find('span').append("▼");
$('div[id='+nameMore+']').slideDown("normal");
$(this).attr("value","1");
}else if(valMore == 1){
$(this).find('span').empty();
$(this).find('span').append("►");
var n = nameMore.indexOf("process_process");
$('div[id='+nameMore+']').slideUp("normal", function(){
var n = nameMore.indexOf("process_process");
if(n > -1){
hide_panel_all();
}
});
$(this).attr("value","0");
}
});
所以,我已经尝试过类似的东西:
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: $('#modelCanvas'),
gridSize: 10,
height: $('#modelCanvas').height(),
width: $('#modelCanvas').width(),
gridSize: 1,
model: graph,
});
但它不起作用...我可以应用任何想法或方法吗??
提前致谢。
我找到了一种方法,它可能对需要它的人有帮助(用于调整大小响应):
需要将整张纸随着window一起缩放,所以,我们在上面创建一个javascript事件:
window.onresize = function(event) {
paper.setDimensions($('#your_div_id').width());
paper.scaleContentToFit({minScaleX: 0.3, minScaleY: 0.3, maxScaleX: 1 , maxScaleY: 1});
};
使用联合 js 属性,根据该事件调整 canvas 和 div 的大小但仅影响宽度,然后为 X 轴和 Y 轴设置最大比例。当然,您可以根据需要调整它的条件。
希望对我有所帮助!