久久久久久久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 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 亚洲国产一 | 日韩三区| 天堂久久天堂综合色 | 91精品国产91久久久久久最新 | 国产欧美在线 | 国产视频中文字幕 | 欧美性乱 | k8久久久一区二区三区 | 草草视频在线播放 | 久久久久久久久久久高潮一区二区 | 精品日韩一区二区三区av动图 | 五月花丁香婷婷 | 在线免费国产视频 | 在线观看亚洲 | cao在线| 成人欧美一区二区三区在线观看 | 精品1区2区3区4区 | 精品无码久久久久国产 | 欧美阿v | 日韩欧美在线观看一区 | 亚洲成人动漫在线观看 | 国产精品久久久久久久久久久久午夜片 | 国产专区在线 | 国产在线精品一区二区三区 | 色爱综合网 | 国产精品久久久久久亚洲调教 | 欧洲精品一区 | 久久成人免费视频 | 精品三级在线观看 | av手机在线免费观看 | 视频精品一区二区三区 | 国产91丝袜在线播放 | 欧美日韩亚洲一区 | 亚洲欧美一区二区三区国产精品 | 欧美精品日韩精品国产精品 | 日韩精品成人网 | 美女日批免费视频 | 国产激情在线 | 99国内精品 | 亚洲最色网站 | 中文字幕日韩一区 |