{"id":3738,"date":"2014-09-09T11:25:00","date_gmt":"2014-09-09T02:25:00","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=3738"},"modified":"2018-03-07T16:49:08","modified_gmt":"2018-03-07T07:49:08","slug":"post-3738","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/d3v4\/3738","title":{"rendered":"[SVG]\u30c9\u30fc\u30ca\u30c4\u72b6\u306ecircle\u3092\u63cf\u753b\u3059\u308b\u3002"},"content":{"rendered":"<p><a href=\"https:\/\/gunmagisgeek.com\/blog\/d3-js\/3737\">\u5148\u65e5\u306e\u52c9\u5f37\u4f1a<\/a>\u306b\u3066\u300c\u91cd\u306d\u305fcircle\u306e\u9014\u4e2d\u306e\u8272\u3060\u3051\u5909\u3048\u305f\u3044\u300d\u3068\u3044\u3046\u8cea\u554f\u304c\u3042\u308a\u3001\u305d\u306e\u5834\u3067\u306f\u8a73\u3057\u3044\u65b9\u6cd5\u3092\u7b54\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u8a18\u4e8b\u306b\u3066\u56de\u7b54\u3057\u307e\u3059\u3002<\/p>\n<p>\u8907\u6570\u306ecircle\u3092\u91cd\u306d\u3066\u8272\u3092\u5909\u3048\u305f\u5834\u5408\u3001\u900f\u904e\u51e6\u7406\u3092\u884c\u3046\u3068\u4e0b\u306ecircle\u306e\u8272\u3068\u91cd\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/circlemask140909.jpg\" alt=\"svg mask\" width=\"425\" height=\"208\" class=\"aligncenter size-full wp-image-3739\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/circlemask140909.jpg 425w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/circlemask140909-300x147.jpg 300w\" sizes=\"auto, (max-width: 425px) 100vw, 425px\" \/><\/p>\n<p>\u3053\u308c\u3092\u56de\u907f\u3059\u308b\u65b9\u6cd5\u306f\u3044\u308d\u3044\u308d\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u4e00\u756a\u7c21\u5358\u306a\u65b9\u6cd5\u306fmask\u3092\u4f7f\u3046\u65b9\u6cd5\u3067\u3059\u3002<br \/>\n\uff08\u8cea\u554f\u306b\u306f\u300c\u30af\u30ea\u30c3\u30d7\u30d1\u30b9\u3067\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u300d\u3068\u7b54\u3048\u305f\u6c17\u304c\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u3059\u307f\u307e\u305b\u3093\u79c1\u306e\u52d8\u9055\u3044\u3067\u3057\u305f\u3002\u30af\u30ea\u30c3\u30d7\u30d1\u30b9\u306f\u300c\u8868\u793a\u3057\u305f\u3044\u90e8\u5206\u3092\u5207\u308a\u53d6\u308b\u300d\u3060\u3051\u306a\u306e\u3067\u3001Mask\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\uff09<\/p>\n<p>\u30b5\u30fc\u30af\u30eb\u3092Mask\u3092\u4f7f\u3063\u3066\u30c9\u30fc\u30ca\u30c4\u72b6\u306b\u5909\u5f62\u3059\u308b\u3053\u3068\u3067\u3001\u91cd\u306d\u305f\u3068\u304d\u306b\u8272\u304c\u91cd\u306a\u3089\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>Mask\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u30c9\u30fc\u30ca\u30c4\u72b6\u306ecircle\u3092\u8868\u793a\u3059\u308b<\/h2>\n<p>D3.js\u3092\u4f7f\u3066\u30c9\u30fc\u30ca\u30c4\u72b6\u306ecircle\u3092\u91cd\u306d\u308b\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<br \/>\n\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u6570\u306b\u5408\u308f\u305b\u3066mask\u8981\u7d20\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/bl.ocks.org\/shimizu\/d98d1080f9dc03d3d25cfde73bd23971\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/SVG-Mask-Example-Bl.ock-Builder-2018-03-07-16-35-21-1.png\" alt=\"\" width=\"945\" height=\"220\" class=\"aligncenter size-full wp-image-5649 border\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/SVG-Mask-Example-Bl.ock-Builder-2018-03-07-16-35-21-1.png 945w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/SVG-Mask-Example-Bl.ock-Builder-2018-03-07-16-35-21-1-300x70.png 300w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/SVG-Mask-Example-Bl.ock-Builder-2018-03-07-16-35-21-1-768x179.png 768w\" sizes=\"auto, (max-width: 945px) 100vw, 945px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/bl.ocks.org\/shimizu\/d98d1080f9dc03d3d25cfde73bd23971\">example<\/a><\/p>\n<pre class=\"lang:js decode:true \" >const dataSet =[\n    {r:20, color:\"blue\"},\n    {r:40, color:\"red\"},\n    {r:60, color:\"blue\"},\n]\n\n\/*normal*\/\nconst svg1 = d3.select(\"#svg1\")\nsvg1.selectAll(\"circle\")\n    .data(dataSet.reverse())\n    .enter()\n    .append(\"circle\")\n    .attr(\"cx\", 100)\n    .attr(\"cy\", 60)\n    .attr(\"r\", d => d.r)\n    .attr(\"fill\", d => d.color)\n\n\/*fill-opacity:0.5*\/\nconst svg2 = d3.select(\"#svg2\")\nsvg2.selectAll(\"circle\")\n    .data(dataSet.reverse())\n    .enter()\n    .append(\"circle\")\n    .attr(\"cx\", 100)\n    .attr(\"cy\", 60)\n    .attr(\"r\", d => d.r)\n    .attr(\"fill\", d => d.color)\n    .attr(\"fill-opacity\", 0.5)\n\n\/*mask*\/\nconst svg3 = d3.select(\"#svg3\")\nsvg3.selectAll(\"circle\")\n    .data(dataSet)\n    .enter()\n    .append(\"circle\")\n    .attr(\"cx\", 100)\n    .attr(\"cy\", 60)\n    .attr(\"r\", d => d.r)\n    .attr(\"fill\", d => d.color)\n    .attr(\"fill-opacity\", 0.5)\n    .attr(\"mask\", (d, i) => {\n        if(i <= 0) return null;\n        return `url(#mask${i}`;\n    })\n\n\/\/\u90e8\u54c1\u306e\u5b9a\u7fa9 \nconst defs = svg3.append(\"defs\");       \ndataSet.forEach(function(d, i){\n    if (i <= 0) return;\n    \n    \/\/defs\u5185\u306bmask\u8981\u7d20\u3092\u8ffd\u52a0\n    const mask = defs.append(\"mask\")\n        .attr(\"id\", `mask${i}`);\n    \n    \/\/mask\u8868\u793a\u9818\u57df\u306e\u6307\u5b9a   \n    mask.append(\"circle\")\n        .attr(\"cx\", 100)\n        .attr(\"cy\", 60)\n        .attr(\"r\", dataSet[i].r)\n        .attr(\"fill\", \"white\")\n\n    \/\/mask\u975e\u8868\u793a\u9818\u57df\u306e\u6307\u5b9a  \n    mask.append(\"circle\")\n        .attr(\"cx\", 100)\n        .attr(\"cy\", 60)\n        .attr(\"fill\", \"black\")\n        .attr(\"r\", dataSet[i-1].r)\n\n});<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u65e5\u306e\u52c9\u5f37\u4f1a\u306b\u3066\u300c\u91cd\u306d\u305fcircle\u306e\u9014\u4e2d\u306e\u8272\u3060\u3051&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3739,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[],"class_list":["post-3738","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\/3738","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=3738"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3738\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/3739"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=3738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=3738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=3738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}