久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 arbor.js 中為邊緣添加標簽(查詢插件)

Add label to edges in arbor.js (Query plugin)(在 arbor.js 中為邊緣添加標簽(查詢插件))
本文介紹了在 arbor.js 中為邊緣添加標簽(查詢插件)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何在 arbor.js 中為邊緣添加標簽它是一個圖形可視化庫.

How do I add labels to edges in arbor.js It is a graph visualization library.

假設 A 和 B 是節點,E 是邊一種粗略的方法是插入一個文本節點"T并加入 A-T 和 T-B

Suppose A and B are nodes and E is the edge One crude way would be insert a "text node" T and join A-T and T-B

但我不想這樣,有沒有其他辦法?

But i don't want to this, is there any other way?

這是示例代碼

var theUI = {
  nodes:{A:{color:"red", shape:"dot", alpha:1}, 
      B:{color:"#b2b19d", shape:"dot", alpha:1}, 
      C:{color:"#b2b19d", shape:"dot", alpha:1}, 
      D:{color:"#b2b19d", shape:"dot", alpha:1},
  },
  edges:{
      A:{
          B:{length:.8},
          C:{length:.8},
          D:{length:.8}
           }
  }
}

var sys = arbor.ParticleSystem()
sys.parameters({stiffness:900, repulsion:2000, gravity:true, dt:0.015})
sys.renderer = Renderer("#sitemap")
sys.graft(theUI) 

在此,A 連接到 B、C 和 D.如何為邊緣提供標簽?

In this, A is connected to B, C and D. How to supply label to edges?

推薦答案

arbor.js 允許您編寫代碼來呈現整個圖形.您可以在渲染方法中做任何您想做的事情,包括繪制邊緣標題,您可以將其存儲在單獨的地圖中.

arbor.js allows you to write a code to render the whole graph. You can do whatever you want in render method including drawing edges titles which you can store in a separate map.

只需用這種方式覆蓋 Renderer 中的方法渲染:

Just override method render in Renderer this way:

redraw:function()
{
    ctx.fillStyle = "white";
    ctx.fillRect (0,0, canvas.width, canvas.height);

    particleSystem.eachEdge (function (edge, pt1, pt2)
    {
        ctx.strokeStyle = "rgba(0,0,0, .333)";
        ctx.lineWidth = 1;
        ctx.beginPath ();
        ctx.moveTo (pt1.x, pt1.y);
        ctx.lineTo (pt2.x, pt2.y);
        ctx.stroke ();

        ctx.fillStyle = "black";
        ctx.font = 'italic 13px sans-serif';
        ctx.fillText (edge.data.name, (pt1.x + pt2.x) / 2, (pt1.y + pt2.y) / 2);

    });

    particleSystem.eachNode (function (node, pt)
    {
        var w = 10;
        ctx.fillStyle = "orange";
        ctx.fillRect (pt.x-w/2, pt.y-w/2, w,w);
        ctx.fillStyle = "black";
        ctx.font = 'italic 13px sans-serif';
        ctx.fillText (node.name, pt.x+8, pt.y+8);
    });       
   };

此代碼期望在初始化時填充每條邊的數據屬性.

This code expected data property of each edge to be filled while initialization.

我使用自定義地圖和方法 addNode/addEdge 手動創建所有節點和邊,但我想您可以更改一些代碼以通過這種方式使用自定義數據初始化邊:

I create all nodes and edges manually using my custom map and methods addNode/addEdge, bu I suppose you can change a little your code to initialize edges with custom data this way:

var theUI = {
  nodes:{A:{color:"red", shape:"dot", alpha:1}, 
      B:{color:"#b2b19d", shape:"dot", alpha:1}, 
      C:{color:"#b2b19d", shape:"dot", alpha:1}, 
      D:{color:"#b2b19d", shape:"dot", alpha:1},
  },
  edges:{
      A:{
          B:{length:.8, data:{name:"A->B"}},
          C:{length:.8, data:{name:"A->C"}},
          D:{length:.8, data:{name:"A->D"}}
           }
  }
}

PS:看看這個例子,我從中學到了很多它.

P.S.: take a look at this example, I learned a lot from it.

這篇關于在 arbor.js 中為邊緣添加標簽(查詢插件)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 欧美精品久久久久 | 亚洲精品一区中文字幕乱码 | 国产一卡二卡三卡 | 国产成人精品一区二区三区视频 | 亚洲国产偷 | 一区在线播放 | 久久久免费 | 欧美日韩国产高清 | 中文字幕一区二区三区不卡 | 一级a性色生活片久久毛片 一级特黄a大片 | 伊人中文字幕 | 日韩av美女电影 | 亚洲精品www| 国产精品久久av | 国产精品久久久久久福利一牛影视 | 欧美日韩中文国产一区发布 | 国产高清一区二区三区 | 成年无码av片在线 | 成人性生交大片免费看r链接 | 欧州一区二区三区 | 伊人免费观看视频 | 日韩高清中文字幕 | 日韩在线一区二区 | 午夜影院在线观看免费 | 国产精品久久久久久久久久久免费看 | 一级黄色淫片 | 在线日韩欧美 | 亚洲一区在线播放 | 国产精品高清在线 | 成人免费视频网址 | www国产精 | 毛片一区 | 国产精品观看 | 狠狠操婷婷 | 99成人| 国产精品区二区三区日本 | 免费国产视频在线观看 | 岛国精品| 久久精品视频12 | 亚洲一区二区中文字幕 | 拍拍无遮挡人做人爱视频免费观看 |