{"id":4246,"date":"2015-05-07T09:45:49","date_gmt":"2015-05-07T00:45:49","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=4246"},"modified":"2018-03-05T17:13:02","modified_gmt":"2018-03-05T08:13:02","slug":"post-4246","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/d3v4\/4246","title":{"rendered":"Path\u30c8\u30e9\u30f3\u30b8\u30b7\u30e7\u30f3\u5165\u9580"},"content":{"rendered":"<p><a href=\"https:\/\/bl.ocks.org\/shimizu\/cbd93e1b735939a9ebfd3708c2a860b3\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/05\/pathTransition150507.jpg\" alt=\"Path Transition\" width=\"681\" height=\"573\" class=\"aligncenter size-full wp-image-4247 border\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/05\/pathTransition150507.jpg 681w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/05\/pathTransition150507-178x150.jpg 178w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/bl.ocks.org\/shimizu\/cbd93e1b735939a9ebfd3708c2a860b3\">example<\/a><\/p>\n<p>\u5148\u65e5\u304b\u3089Path\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092<a href=\"https:\/\/gunmagisgeek.com\/blog\/d3-js\/4222\">\u3044\u308d<\/a><a href=\"https:\/\/gunmagisgeek.com\/blog\/d3-js\/4233\">\u3044\u308d<\/a>\u8a66\u3057\u3066\u3044\u308b\u308f\u3051\u3067\u3059\u304c\u3001D3\u306etransition\u95a2\u6570\u3092\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u5165\u308c\u66ff\u3048\u3066path\u306b\u9069\u7528\u3057\u305f\u969b\u306e\u52d5\u4f5c\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u3063\u305f\u306e\u3067\u516c\u958b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<br \/>\nrun\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u305d\u308c\u305e\u308c\u3001\u5ea7\u6a19\u70b9(\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u6570)\u304c\u540c\u3058\u5834\u5408\u3001\u5897\u3048\u308b\u5834\u5408\u3001\u6e1b\u308b\u5834\u5408\u306e\u52d5\u4f5c\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30b5\u30f3\u30d7\u30eb<\/h2>\n<pre class=\"lang:js decode:true \" >const dataSet1 = [\n    {x:20, y:10},\n    {x:940, y:130},\n]\n\nconst dataSet2 = [\n    {x:20, y:10},\n    {x:340, y:130},\n    {x:940, y:10},\n]\n\nconst dataSet3 = [\n    {x:20, y:130},\n    {x:340, y:10},\n    {x:940, y:130},\n]\n\n\nconst path = d3.line()\n    .x(d => d.x )\n    .y(d => d.y )\n\n\n\n\/*****************************************************************************\n * path 1\u3000\u9802\u70b9\uff13\u2192\uff13(\u540c\u3058\u5834\u5408)\n ******************************************************************************\/\n\nconst svg1 = d3.select(\"#svg1\")\n    \nconst path1 = svg1.append(\"path\")\n    .attr(\"d\", d => {\n        const lineStr = path(dataSet2);\n        document.querySelector(\"#pahtd1\").value = lineStr;\n        return lineStr;\n    })\n\n\/\/\u5b9f\u884c\u30dc\u30bf\u30f3 \nd3.select(\"#run1\").on(\"click\", function(){\n    path1.transition().duration(1000).attr(\"d\", function(){\n        const lineStr = path(dataSet3);\n        document.querySelector(\"#pahtd1\").value = lineStr;\n        return lineStr;\n    })\n});\n\n\/\/\u30ea\u30bb\u30c3\u30c8\u30dc\u30bf\u30f3\nd3.select(\"#reset1\").on(\"click\", function(){\n    path1.attr(\"d\", function(){\n        const lineStr = path(dataSet2);\n        document.querySelector(\"#pahtd1\").value = lineStr;\n        return lineStr;\n    })\n});\n\n\n\/*****************************************************************************\n * path 2 \u9802\u70b9\uff12\u2192\uff13(\u5897\u3048\u308b\u5834\u5408)\n ******************************************************************************\/\n\n\nconst svg2 = d3.select(\"#svg2\")\n    \nconst path2 = svg2.append(\"path\")\n    .attr(\"d\", d => {\n        const lineStr = path(dataSet1);\n        document.querySelector(\"#pahtd2\").value = lineStr;\n        return lineStr;\n    })\n\nd3.select(\"#run2\").on(\"click\", () =>{\n    path2.transition().duration(1000).attr(\"d\", () => {\n        const lineStr = path(dataSet2);\n        document.querySelector(\"#pahtd2\").value = lineStr;\n        return lineStr;\n    })\n});\n    \nd3.select(\"#reset2\").on(\"click\", () => {\n    path2.attr(\"d\", () => {\n        const lineStr = path(dataSet1);\n        document.querySelector(\"#pahtd2\").value = lineStr;\n        return lineStr;\n    })\n});\n\n\/*****************************************************************************\n * path 3 \u9802\u70b9\uff13\u2192\uff12(\u6e1b\u308b\u5834\u5408)\n ******************************************************************************\/\n        \nconst svg3 = d3.select(\"#svg3\")\n    \nconst path3 = svg3.append(\"path\")\n    .attr(\"d\", d => {\n        const lineStr = path(dataSet2);\n        document.querySelector(\"#pahtd3\").value = lineStr;\n        return lineStr; \n    })\n\nd3.select(\"#run3\").on(\"click\", () => {\n    path3.transition().duration(1000).attr(\"d\", () => {\n        const lineStr = path(dataSet1);\n        document.querySelector(\"#pahtd3\").value = lineStr;\n        return lineStr;\n    })\n});\n\nd3.select(\"#reset3\").on(\"click\", () => {\n    path3.attr(\"d\", () => {\n        const lineStr = path(dataSet2);\n        document.querySelector(\"#pahtd3\").value = lineStr;\n        return lineStr;\n    })\n});\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>example \u5148\u65e5\u304b\u3089Path\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4247,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[],"class_list":["post-4246","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3v4","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=4246"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4246\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/4247"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=4246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=4246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=4246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}