var links = [{ "source": "2168", "source_name": "Chohakkai", "target": "139", "target_name": "Monkey" }, { "source": "2168", "source_name": "Chohakkai", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2167", "source_name": "Sanzohoshi", "target": "139", "target_name": "Monkey" }, { "source": "2167", "source_name": "Sanzohoshi", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2165", "source_name": "Inkaizan, in fact Chinkozui", "target": "139", "target_name": "Monkey" }, { "source": "2165", "source_name": "Inkaizan, in fact Chinkozui", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2164", "source_name": "Flower peddler, in fact Hakuren", "target": "139", "target_name": "Monkey" }, { "source": "2164", "source_name": "Flower peddler, in fact Hakuren", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2163", "source_name": "Nikuryokan, in fact Rihyo", "target": "139", "target_name": "Monkey" }, { "source": "2163", "source_name": "Nikuryokan, in fact Rihyo", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2162", "source_name": "Chinkozui, in fact Ryuko", "target": "139", "target_name": "Monkey" }, { "source": "2162", "source_name": "Chinkozui, in fact Ryuko", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "943", "source_name": "Feudal lord", "target": "136", "target_name": "The Story of Matsukaza and Murasame" }, { "source": "943", "source_name": "Feudal lord", "target": "176", "target_name": "The Monkey Dance" }, { "source": "2159", "source_name": "Secondhand goods dealer", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "2159", "source_name": "Secondhand goods dealer", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "2158", "source_name": "Street performers", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "2158", "source_name": "Street performers", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "2157", "source_name": "Monkey", "target": "136", "target_name": "The Story of Matsukaza and Murasame" }, { "source": "2157", "source_name": "Monkey", "target": "176", "target_name": "The Monkey Dance" }, { "source": "942", "source_name": "Saizo", "target": "165", "target_name": "The Street Entertainers" }, { "source": "942", "source_name": "Saizo", "target": "64", "target_name": "The Dances of the Four Seasons" }, { "source": "941", "source_name": "Tayu", "target": "165", "target_name": "The Street Entertainers" }, { "source": "941", "source_name": "Tayu", "target": "64", "target_name": "The Dances of the Four Seasons" }, { "source": "425", "source_name": "Boatman", "target": "25", "target_name": "The Cherry Trees Along the Hidaka River" }, { "source": "425", "source_name": "Boatman", "target": "147", "target_name": "The Cherry Blossoms of the Dojoji Temple" }, { "source": "419", "source_name": "Kiyohime", "target": "25", "target_name": "The Cherry Trees Along the Hidaka River" }, { "source": "419", "source_name": "Kiyohime", "target": "147", "target_name": "The Cherry Blossoms of the Dojoji Temple" }, { "source": "418", "source_name": "Toyonari", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "418", "source_name": "Toyonari", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "417", "source_name": "Chujohime", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "417", "source_name": "Chujohime", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "416", "source_name": "Hirotsugu", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "416", "source_name": "Hirotsugu", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "415", "source_name": "Takunai, a servant", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "415", "source_name": "Takunai, a servant", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "414", "source_name": "Kakunai, a servant", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "414", "source_name": "Kakunai, a servant", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "413", "source_name": "Lady Iwane", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "413", "source_name": "Lady Iwane", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "412", "source_name": "Kirinoya", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "412", "source_name": "Kirinoya", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "2166", "source_name": "Sanzohoshi, in fact Songoku", "target": "139", "target_name": "Monkey" }, { "source": "2166", "source_name": "Sanzohoshi, in fact Songoku", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "316", "source_name": "Fuyo, in fact Ginkaku", "target": "139", "target_name": "Monkey" }, { "source": "316", "source_name": "Fuyo, in fact Ginkaku", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "110", "source_name": "Kinezo", "target": "138", "target_name": "The Dumpling Peddlers" }, { "source": "110", "source_name": "Kinezo", "target": "74", "target_name": "The Dumpling Peddlers" }, { "source": "944", "source_name": "Retainer", "target": "136", "target_name": "The Story of Matsukaza and Murasame" }, { "source": "944", "source_name": "Retainer", "target": "176", "target_name": "The Monkey Dance" }, { "source": "1707", "source_name": "Katota", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "1707", "source_name": "Katota", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "1800", "source_name": "Manzai", "target": "64", "target_name": "The Dances of the Four Seasons" }, { "source": "1800", "source_name": "Manzai", "target": "165", "target_name": "The Street Entertainers" }, { "source": "707", "source_name": "Konami", "target": "63", "target_name": "The League of the 47 Ronin" }, { "source": "707", "source_name": "Konami", "target": "143", "target_name": "The Bridal Journey" }, { "source": "708", "source_name": "Tonase", "target": "63", "target_name": "The League of the 47 Ronin" }, { "source": "708", "source_name": "Tonase", "target": "143", "target_name": "The Bridal Journey" }, { "source": "711", "source_name": "Benkei", "target": "31", "target_name": "The Subscription List" }, { "source": "711", "source_name": "Benkei", "target": "49", "target_name": "The New Barrier of Ataka" }, { "source": "712", "source_name": "Togashi", "target": "31", "target_name": "The Subscription List" }, { "source": "712", "source_name": "Togashi", "target": "49", "target_name": "The New Barrier of Ataka" }, { "source": "713", "source_name": "Yoshitsune Minamoto", "target": "31", "target_name": "The Subscription List" }, { "source": "713", "source_name": "Yoshitsune Minamoto", "target": "49", "target_name": "The New Barrier of Ataka" }, { "source": "714", "source_name": "Ise", "target": "31", "target_name": "The Subscription List" }, { "source": "714", "source_name": "Ise", "target": "49", "target_name": "The New Barrier of Ataka" }, { "source": "2189", "source_name": "Sagojo", "target": "139", "target_name": "Monkey" }, { "source": "2189", "source_name": "Sagojo", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2187", "source_name": "Old Woman", "target": "139", "target_name": "Monkey" }, { "source": "2187", "source_name": "Old Woman", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2186", "source_name": "Emperor Taiso", "target": "139", "target_name": "Monkey" }, { "source": "2186", "source_name": "Emperor Taiso", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2185", "source_name": "Sadakuro", "target": "139", "target_name": "Monkey" }, { "source": "2185", "source_name": "Sadakuro", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2184", "source_name": "Green Ogre", "target": "139", "target_name": "Monkey" }, { "source": "2184", "source_name": "Green Ogre", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "2183", "source_name": "Red Ogre", "target": "139", "target_name": "Monkey" }, { "source": "2183", "source_name": "Red Ogre", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "715", "source_name": "Suruga", "target": "31", "target_name": "The Subscription List" }, { "source": "715", "source_name": "Suruga", "target": "49", "target_name": "The New Barrier of Ataka" }, { "source": "716", "source_name": "Hachiro Kataoka", "target": "31", "target_name": "The Subscription List" }, { "source": "716", "source_name": "Hachiro Kataoka", "target": "49", "target_name": "The New Barrier of Ataka" }, { "source": "717", "source_name": "Hitachibo", "target": "31", "target_name": "The Subscription List" }, { "source": "717", "source_name": "Hitachibo", "target": "49", "target_name": "The New Barrier of Ataka" }, { "source": "718", "source_name": "Barrier guards", "target": "31", "target_name": "The Subscription List" }, { "source": "718", "source_name": "Barrier guards", "target": "49", "target_name": "The New Barrier of Ataka" }, { "source": "945", "source_name": "Monkey trainer", "target": "136", "target_name": "The Story of Matsukaza and Murasame" }, { "source": "945", "source_name": "Monkey trainer", "target": "176", "target_name": "The Monkey Dance" }, { "source": "411", "source_name": "Ukifune", "target": "65", "target_name": "The Pines on Mount Hibari" }, { "source": "411", "source_name": "Ukifune", "target": "89", "target_name": "The Pines on Mount Hibari" }, { "source": "388", "source_name": "Sagimusume", "target": "64", "target_name": "The Dances of the Four Seasons" }, { "source": "388", "source_name": "Sagimusume", "target": "166", "target_name": "The Heron Girl" }, { "source": "385", "source_name": "Saizo", "target": "64", "target_name": "The Dances of the Four Seasons" }, { "source": "385", "source_name": "Saizo", "target": "165", "target_name": "The Street Entertainers" }, { "source": "384", "source_name": "Tayu", "target": "64", "target_name": "The Dances of the Four Seasons" }, { "source": "384", "source_name": "Tayu", "target": "165", "target_name": "The Street Entertainers" }, { "source": "326", "source_name": "Boatman", "target": "139", "target_name": "Monkey" }, { "source": "326", "source_name": "Boatman", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "325", "source_name": "Shabbily-clothed woman", "target": "139", "target_name": "Monkey" }, { "source": "325", "source_name": "Shabbily-clothed woman", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "324", "source_name": "Jagatara-no-gon", "target": "139", "target_name": "Monkey" }, { "source": "324", "source_name": "Jagatara-no-gon", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "323", "source_name": "Gaikotsu, later known as Sagojo", "target": "139", "target_name": "Monkey" }, { "source": "323", "source_name": "Gaikotsu, later known as Sagojo", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "322", "source_name": "Chogohachi, later known as Chohakkai", "target": "139", "target_name": "Monkey" }, { "source": "322", "source_name": "Chogohachi, later known as Chohakkai", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "321", "source_name": "Ryuko's wife", "target": "139", "target_name": "Monkey" }, { "source": "321", "source_name": "Ryuko's wife", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "320", "source_name": "Teremen", "target": "139", "target_name": "Monkey" }, { "source": "320", "source_name": "Teremen", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "319", "source_name": "Saikakuen", "target": "139", "target_name": "Monkey" }, { "source": "319", "source_name": "Saikakuen", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "318", "source_name": "Priest Homei", "target": "139", "target_name": "Monkey" }, { "source": "318", "source_name": "Priest Homei", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "317", "source_name": "Friend of Fuyo's", "target": "139", "target_name": "Monkey" }, { "source": "317", "source_name": "Friend of Fuyo's", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "306", "source_name": "Ryuko", "target": "139", "target_name": "Monkey" }, { "source": "306", "source_name": "Ryuko", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "307", "source_name": "Rihyo", "target": "139", "target_name": "Monkey" }, { "source": "307", "source_name": "Rihyo", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "308", "source_name": "Chinkozui", "target": "139", "target_name": "Monkey" }, { "source": "308", "source_name": "Chinkozui", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "309", "source_name": "Hakuren", "target": "139", "target_name": "Monkey" }, { "source": "309", "source_name": "Hakuren", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "310", "source_name": "King of Hell", "target": "139", "target_name": "Monkey" }, { "source": "310", "source_name": "King of Hell", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "311", "source_name": "Ogre", "target": "139", "target_name": "Monkey" }, { "source": "311", "source_name": "Ogre", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "312", "source_name": "Dead man", "target": "139", "target_name": "Monkey" }, { "source": "312", "source_name": "Dead man", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "313", "source_name": "Songoku", "target": "139", "target_name": "Monkey" }, { "source": "313", "source_name": "Songoku", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "314", "source_name": "Ungai", "target": "139", "target_name": "Monkey" }, { "source": "314", "source_name": "Ungai", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "327", "source_name": "Buddha", "target": "139", "target_name": "Monkey" }, { "source": "327", "source_name": "Buddha", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "328", "source_name": "Flower peddler", "target": "139", "target_name": "Monkey" }, { "source": "328", "source_name": "Flower peddler", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "329", "source_name": "Donketsu", "target": "139", "target_name": "Monkey" }, { "source": "329", "source_name": "Donketsu", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "1944", "source_name": "Chuzaburo's wife (Chuza's wife)", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1944", "source_name": "Chuzaburo's wife (Chuza's wife)", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "885", "source_name": "Sambaso", "target": "100", "target_name": "The Dance of Sambaso" }, { "source": "885", "source_name": "Sambaso", "target": "129", "target_name": "The Dance of Sambaso" }, { "source": "884", "source_name": "Okina", "target": "100", "target_name": "The Dance of Sambaso" }, { "source": "884", "source_name": "Okina", "target": "129", "target_name": "The Dance of Sambaso" }, { "source": "883", "source_name": "Senzai", "target": "100", "target_name": "The Dance of Sambaso" }, { "source": "883", "source_name": "Senzai", "target": "129", "target_name": "The Dance of Sambaso" }, { "source": "1381", "source_name": "Sato Tadanobu, in fact Fox Tadanobu", "target": "62", "target_name": "Yoshitsune and a Thousand Cherry Trees" }, { "source": "1381", "source_name": "Sato Tadanobu, in fact Fox Tadanobu", "target": "91", "target_name": "The Travel on Mt. Yoshino" }, { "source": "1367", "source_name": "Shizuka-Gozen", "target": "62", "target_name": "Yoshitsune and a Thousand Cherry Trees" }, { "source": "1367", "source_name": "Shizuka-Gozen", "target": "91", "target_name": "The Travel on Mt. Yoshino" }, { "source": "332", "source_name": "Gyumao", "target": "139", "target_name": "Monkey" }, { "source": "332", "source_name": "Gyumao", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "331", "source_name": "Rasetsujo", "target": "139", "target_name": "Monkey" }, { "source": "331", "source_name": "Rasetsujo", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "1945", "source_name": "Hachiemon", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1945", "source_name": "Hachiemon", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1943", "source_name": "Chubei", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1943", "source_name": "Chubei", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "330", "source_name": "Townsman", "target": "139", "target_name": "Monkey" }, { "source": "330", "source_name": "Townsman", "target": "51", "target_name": "Pilgrimage to the West" }, { "source": "1942", "source_name": "Umegawa", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1942", "source_name": "Umegawa", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1941", "source_name": "Mizuemon", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1941", "source_name": "Mizuemon", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1940", "source_name": "Okizukin", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1940", "source_name": "Okizukin", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1939", "source_name": "Chief of a police squad", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1939", "source_name": "Chief of a police squad", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1938", "source_name": "Tojibei", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1938", "source_name": "Tojibei", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1937", "source_name": "Magoemon", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1937", "source_name": "Magoemon", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1936", "source_name": "Doan", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1936", "source_name": "Doan", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1935", "source_name": "Dengababa", "target": "97", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "1935", "source_name": "Dengababa", "target": "116", "target_name": "The Amorous Courier on the Yamato Highway" }, { "source": "111", "source_name": "Ousu", "target": "138", "target_name": "The Dumpling Peddlers" }, { "source": "111", "source_name": "Ousu", "target": "74", "target_name": "The Dumpling Peddlers" }, { "source": "315", "source_name": "Genjo, later known as Sanzohoshi", "target": "139", "target_name": "Monkey" }, { "source": "315", "source_name": "Genjo, later known as Sanzohoshi", "target": "51", "target_name": "Pilgrimage to the West" }]; var svg = d3.select("#canvas") .attr("width", 600) .attr("height", 800); var nodes = {}; links.forEach(function(link) { link.source = nodes[link.source] || (nodes[link.source] = { name: link.source_name, id: link.source, is_src: true }); link.target = nodes[link.target] || (nodes[link.target] = { name: link.target_name, id: link.target, is_src: false }); }); var force = d3.layout.force() .nodes(d3.values(nodes)) .links(links) .size([800, 800]) .linkDistance(100) .charge(-100) .gravity(0.1) .on("tick", tick) .start(); var tip = d3.tip() .attr('class', 'd3-tip') .offset([-5, 0]) .html(function (d) { if (d.is_src){ return "<b>Character: </b><br/>" + d.name + "</span>"; } else { return "<b>Play: </b><br/><em>" + d.name + "</em></span>"; } }) svg.call(tip); var link = svg.selectAll(".link") .data(force.links()) .enter().append("line") .attr("class", "link"); var node = svg.selectAll(".node") .data(force.nodes()) .enter().append("g") .attr("class", "node") .call(force.drag) .on('mouseover', tip.show) //Added .on('mouseout', tip.hide); node.append("circle") .attr("r", function(d) { if (d.is_src) { return 10;} else { return 30; } }) .style("fill", function(d) { if (d.is_src) { return "#c63d2d"; } else { return "#436577"; } }) .on('mouseover', function(d){ return d3.select(this).style("cursor", "pointer"); }) .on('mouseout', function(d){ return d3.select(this).style("cursor", "default"); }) function tick() { link.attr("x1", function(d) { return d.source.x; }) .attr("y1", function(d) { return d.source.y; }) .attr("x2", function(d) { return d.target.x; }) .attr("y2", function(d) { return d.target.y; }); node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }); }