{"id":4592,"date":"2015-10-20T16:43:27","date_gmt":"2015-10-20T07:43:27","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=4592"},"modified":"2018-03-05T11:04:25","modified_gmt":"2018-03-05T02:04:25","slug":"post-4592","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/svg\/4592","title":{"rendered":"\u3010D3.js\u3011\u4eba\u578b\u30b0\u30e9\u30d5"},"content":{"rendered":"<p><a href=\"http:\/\/bl.ocks.org\/shimizu\/062920b3d6cbabc66a6444a0ab19d571\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/10\/manchart151020.jpg\" alt=\"manchart\" width=\"500\" height=\"260\" class=\"aligncenter size-full wp-image-4593 border\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/10\/manchart151020.jpg 500w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/10\/manchart151020-288x150.jpg 288w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/bl.ocks.org\/shimizu\/062920b3d6cbabc66a6444a0ab19d571\">example<\/a><\/p>\n<p>\u30b9\u30e9\u30a4\u30c9\u30d0\u30fc\u3092\u52d5\u304b\u3059\u3068\u3001\u4eba\u578b\u30a2\u30a4\u30b3\u30f3\u306e\u9752\u8272\u306e\u30a8\u30ea\u30a2\u304c\u4e0a\u4e0b\u3057\u307e\u3059\u3002<br \/>\n\u3053\u3046\u3044\u3046\u30c1\u30e3\u30fc\u30c8\u3092\u4f55\u3068\u547c\u3076\u3093\u3067\u3057\u3087\u3046\u306d\uff1f\u3000\u3088\u304f\u898b\u304b\u3051\u308b\u308f\u308a\u306b\u540d\u79f0\u304c\u5206\u304b\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u3068\u308a\u3042\u3048\u305a\u300c\u4eba\u578b\u30b0\u30e9\u30d5\u300d\u3068\u3057\u3066\u304a\u304d\u307e\u3057\u305f\u3002\u6b63\u5f0f\u306a\u540d\u524d\u3092\u77e5\u3063\u3066\u3044\u308b\u65b9\u3044\u3089\u3063\u3057\u3083\u3044\u307e\u3057\u305f\u3089\u6559\u3048\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u3061\u306a\u307f\u306b\u3001\u53ef\u8996\u5316\u3068\u3044\u3046\u70b9\u304b\u3089\u3059\u308b\u3068\u3001\u3042\u307e\u308a\u3088\u308d\u3057\u304f\u306a\u3044\u8868\u73fe\u65b9\u6cd5\u3060\u3063\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b5\u30f3\u30d7\u30eb<\/h2>\n<p>\u4eca\u56de\u306f\u30a4\u30f3\u30e9\u30a4\u30f3svg\u306e\u90e8\u5206\u304c\u591a\u3044\u306e\u3067\u3001svg\u30d1\u30fc\u30c8\u3068JavaScript\u30d1\u30fc\u30c8\u3067\u5206\u3051\u3066\u63b2\u8f09\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:xhtml decode:true \" title=\"svg\" >&lt;svg  viewBox=\"0 0 960 500\"&gt;\n&lt;def&gt;\n    &lt;g id=\"manIcon\"&gt;\n        &lt;path d=\"M197,476c0,14,6.833,21,20.5,21s20.5-7,20.5-21V282h21v194c0,14,6.833,21,20.5,21s20.5-7,20.5-21\n            V149h10v121c0,7.334,2.5,12.667,7.5,16s10.167,3.333,15.5,0s8-8.667,8-16V145c0-14-4.667-25.5-14-34.5S305,97,289,97h-81\n            c-15.333,0-27.833,4.333-37.5,13S156,130,156,144v127c0,6.667,2.667,11.333,8,14c5.333,2.667,10.5,2.667,15.5,0s7.5-7.334,7.5-14\n            V149h10V476z\"\/&gt;\n        &lt;path d=\"M205,42.5c0,11.667,4.167,21.667,12.5,30s18.333,12.5,30,12.5S269,80.833,277,72.5s12-18.333,12-30\n            s-4-21.667-12-30S259.167,0,247.5,0s-21.667,4.167-30,12.5S205,30.833,205,42.5z\"\/&gt;\n    &lt;\/g&gt;\n&lt;\/def&gt;\n&lt;mask id=\"mask\" maskUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"960\" height=\"500\"&gt;\n    &lt;use   xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" xlink:href=\"#manIcon\" x=\"260\" y=\"2\" fill=\"white\" transform=\"translate(-25,-0) scale(1,1)\"\/&gt;\n&lt;\/mask&gt;\n&lt;rect  mask=\"url(#mask)\" x=\"0\" y=\"0\" width=\"960\" height=\"500\" fill=\"gray\" \/&gt;\n&lt;rect id=\"bar\" mask=\"url(#mask)\" x=\"0\" y=\"250\" width=\"960\" height=\"250\" fill=\"blue\" \/&gt;\n&lt;\/svg&gt;<\/pre>\n<p>def\u8981\u7d20\u306e\u4e2d\u3067\u6307\u5b9a\u3057\u3066\u3044\u308b\u306e\u304c\u4eba\u578b\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8(path)\u3067\u3059\u3002<br \/>\nuse\u8981\u7d20\u306b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8a2d\u5b9a\u3057\u3001\u30de\u30b9\u30af\u306b\u3057\u307e\u3059\u3002<br \/>\n\u6b21\u306b\u7070\u8272\u306erect\u8981\u7d20\u3068\u9752\u8272\u306erect\u8981\u7d20\u3092\u7528\u610f\u3057\u3001\u305d\u308c\u305e\u308c\u306b\u30de\u30b9\u30af\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\n\u3064\u307e\u308a\u4eba\u578b\u306b\u5207\u308a\u53d6\u3063\u3066\u3044\u308b\u308f\u3051\u3067\u3059\u306d\u3002<br \/>\n\u4e26\u3073\u9806\u3067\u4e0b\u306b\u306a\u308b\u8981\u7d20\u304c\u624b\u524d\u306e\u30ec\u30a4\u30e4\u30fc\u306b\u306a\u308b\u306e\u3067\u3001\u7070\u8272\u306e\u4eba\u578b\u306e\u4e0a\u306b\u9752\u8272\u306e\u4eba\u578b\u304c\u91cd\u306a\u3063\u305f\u72b6\u614b\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" title=\"javaScript\" >var rangeX = document.querySelector('#rangeX');   \nvar h = 500;\n\nrangeX['oninput' in rangeX ? 'oninput' : 'onchange'] = slide;\n\nfunction slide(){\n    var barH = h * rangeX.value;\n    var bar = d3.select(\"#bar\");\n    bar.transition().attr({\n        \"y\":h - barH,\n        \"height\":barH\n    })\n}<\/pre>\n<p>\u5f8c\u306f\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u624b\u524d\u306e\u9752\u8272\u306e\u4eba\u578b\u3092\u30b9\u30e9\u30a4\u30c9\u64cd\u4f5c\u306b\u9069\u7528\u3057\u3066\u3042\u3052\u308c\u3070\u5b8c\u6210\u3067\u3059\u3002<br \/>\n#bar\u304c\u9752\u8272\u306e\u4eba\u578b\u3067\u3059\u3002\u30b9\u30e9\u30a4\u30c9\u306evalue(0\u301c1)\u306b\u5408\u308f\u305b\u3066y\u5ea7\u6a19\u3068\u9ad8\u3055\u3092\u5909\u5316\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30ec\u30b9\u30d0\u30fc\u306a\u3069\u306b\u3082\u4f7f\u3048\u305d\u3046\u306a\u306e\u3067\u3001\u4f55\u6c17\u306b\u6c4e\u7528\u6027\u9ad8\u3044\u304b\u3082\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>example \u30b9\u30e9\u30a4\u30c9\u30d0\u30fc\u3092\u52d5\u304b\u3059\u3068\u3001\u4eba\u578b\u30a2\u30a4\u30b3&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4593,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69,50],"tags":[],"class_list":["post-4592","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3v4","category-svg","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4592","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=4592"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4592\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/4593"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=4592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=4592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=4592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}