第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在D3 JavaScript中在圓對象內(nèi)添加圖像?

在D3 JavaScript中在圓對象內(nèi)添加圖像?

縹緲止盈 2019-10-28 15:19:14
我的目標(biāo)是使用d3將圖像添加到現(xiàn)有圓中。圓圈將呈現(xiàn)并與鼠標(biāo)懸停方法交互,但僅當(dāng)我使用“填充”,“顏色”,而不是諸如.append(“ image”)之類的更復(fù)雜的東西時才可以。      g.append("circle")         .attr("class", "logo")         .attr("cx", 700)         .attr("cy", 300)         .attr("r", 10)         .attr("fill", "black")       // this code works OK         .attr("stroke", "white")     // displays small black dot         .attr("stroke-width", 0.25)         .on("mouseover", function(){ // when I use .style("fill", "red") here, it works                d3.select(this)                           .append("svg:image")                   .attr("xlink:href", "/assets/images/logo.jpeg")                   .attr("cx", 700)                   .attr("cy", 300)                   .attr("height", 10)                   .attr("width", 10);         });鼠標(biāo)懸停后圖像未顯示。使用Ruby on Rails應(yīng)用程序,我的圖像“ logo.jpeg”存儲在assets / images /目錄中。對讓我的徽標(biāo)在圈子中顯示有什么幫助嗎?謝謝。
查看完整描述

2 回答

?
墨色風(fēng)雨

TA貢獻(xiàn)1853條經(jīng)驗 獲得超6個贊

nodeEnter.append("svg:image")

            .attr('x',-9)

            .attr('y',-12)

            .attr('width', 20)

            .attr('height', 24)

            .attr("xlink:href", function(d) { 

         if(d.type=="root"){

            return "resources/images/test.png";}

            else if(d.type.toLowerCase()=="A"){

                return "resources/icon01/test1.png";}

            else if(d.type=="B"){

                return "resources/icon01/test2.png";}

            })

            .append("svg:title")

              .text(function(d){

              if(d.type=="root"){

                return "Root Name:"+d.name;}

              else if(d.type=="test"){

                return "Name:"+d.name;}

            });


查看完整回答
反對 回復(fù) 2019-10-28
  • 2 回答
  • 0 關(guān)注
  • 2397 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號