2

我能够将图像附加到节点;但是我无法设置图像的高度?任何帮助将非常感激。

node.append("image")
                    .attr("xlink:href", function(d) {
                        if ( d.id.lastIndexOf("gp_", 0) === 0 )
                            return "raceflag.jpg";
                        else if (d.id === "ct_ferrari")
                            return "ferrari.jpg";
                        else if (d.id === "ct_red_bull")
                            return "redbull.jpg";
                        else if (d.id === "ct_williams")
                            return "williams.jpg";
                        else if (d.id === "ct_force_india")
                            return "forceindia.jpg";
                        else if (d.id === "ct_mclaren")
                            return "mclaren.jpg";
                        else if (d.id === "ct_mercedes")
                            return "mercedes.jpg";
                        /*
                        else if (d.id === "dr_nico_rosberg" || d.id === "dr_sebastian_vettel")
                            return "german.jpg";
                        */
                    })
                    .attr("x", 1)
                    .attr("y", 1)
                    .attr("width", sankey.nodeWidth() - 1)
                    .attr("height", 200); //this only positions the image within the node
4

0 回答 0