â» ãªãããã¹ã©ã¤ãå ã®ç»åã天å°é転ãã¦è¡¨ç¤ºããã¦ãã¾ãã D3.js ver.4ã®æ°æ©è½ãªã©ã«ã¤ãã¦ã Read less
ããã¯Data Visualization Advent Calendar 2014ã®20æ¥ç®ã®æ稿ã§ãã dataãplotããã«ããã£ã¦å¤§å¤ä¾¿å©ãªd3.jsã§ãããæç³»åãªã©ã«ãã"å¤å"ã表ç¾ã§ããããã«ä¾¿å©ãªé¢æ°ãããã¤ãåãã£ã¦ãã¾ãã åºæ¬çã«ã¯transitionãtweenã¡ã½ããã§é·ç§»ãããã®ã§ããããã®éã®åããæå®ããeaseã¡ã½ãããã¡ãã£ã¨ãã ãã£ã¦ä½¿ãã ãã§é åçãªè¡¨ç¾ã«ãªãã¾ãã èªèº«ãå æ¥ãé¨ã«é¢ããã¤ã¶ããã表示ããä½åãçºè¡¨ããã®ã§ããããã®ä¸ã§ãç°¡åã«ä½¿ç¨ãã¦ãã¾ãã(http://world-rainy-clock.herokuapp.com/) åºæ¬ svg.select("circle").transition() .duration(10) .ease("linear") .attr("cy", 10) transitionã«ç¶ãã¦ãé·ç§»ã«ãã
ããã¼ã¿ãã¼ã¹ã®ãã¼ã¿ãD3.jsã§ä½¿ãã«ã¯ï¼ãã¨ãã質åãããã ããã®ã§è¨äºã«ãã¦ã¿ã¾ãããD3.jsã®è©±ã¨ãããããããã¯ã¨ã³ãã¨ããã³ãã¨ã³ããã©ããã£ã¦ç¹ããï¼ã¨ãã話ãªãã¾ããã åºæ¬çã«ã¯ããã¯ã¨ã³ãå´ã§ããã¼ã¿ãã¼ã¹ã®ãã¼ã¿ãJSONå½¢å¼ã§åºåããAPIãä½ããAPIã«å¯¾ãã¦JavaScriptããXMLHttpRequestã使ã£ã¦ãã¼ã¿ãåãåãã¨ããå½¢ãä¸è¬çã ã¨æãã¾ãã ãD3.js Tips and Tricksãã«ãã®ãã®ãºããªãªè¨äºãæ²è¼ããã¦ãã¾ããããã®è¨äºã§ã¯phpé¨åãpdoã使ã£ãã³ã¼ãã«ãã¦ãã¾ãã Using a MySQL database as a source of data ããã¯ã¨ã³ãæ§æ ãã¼ã¿ãã¼ã¹ï¼MySQL WEBãµã¼ãã¼ï¼Apache API:PHP ã ããããããªæãã 質åããã ããå 容ããPHP+MySQLãã¨ãããã¨ã
ä½æãã¦ããD3.jsã«é¢ããã¾ã¨ãã§ãããD3ã®è©±é¡ãå¢ãã¦è¡ãã«ã¤ããã¾ãã«ãæ°ãå¢ããããã®ã§ãå°ãæ´çãã¦ãï¼ã¤ã®ã¾ã¨ãã«åé¡ãã¾ããã ã»ãã¼ã¿ãã¸ã¥ã¢ã©ã¤ã¼ã¼ã·ã§ã³ï¼D3.jsï¼ãå¦ã¶ããã®ææã¾ã¨ã ä»ã¾ã§ã®ã¾ã¨ãã§ãã 主ã«å ¬å¼ãµã¤ããããã¥ã¼ããªã¢ã«ãD3ã«é¢ããã¹ã©ã¤ããªã©ã®ã¾ã¨ãã§ãã ç´è¿ã§ã¯ãD3.jsä¾æè¾å ¸ãã追å ããã¦ããã ãã¾ããã D3ã®ãµã³ãã«ã³ã¼ããå¤æ°æ²è¼ããã¦ãã¾ãã ã»D3.js Wrapper Library D3ã¯ãããå¦ç¿ã³ã¹ããé«ããã¨è¨ãããã®ã§ããããã®çºããD3ãã³ã¢ã¨ããããã£ã¨ç°¡åã«ã°ã©ããæç»ã§ããã©ããã¼ã©ã¤ãã©ãªãå¤æ°åå¨ãã¾ãããã¡ãã®ã¾ã¨ãã§ã¯ãããã®ã©ã¤ãã©ãªãç»é²ãã¦ãã¾ãã æ軽ã«ãµã¯ãã¨ã°ã©ãã表示ãããæã«è¦ãã¦ã¿ã¦ãã ããã AngularJSãEmber.jsãªã©æåãªãã¬ã¼ã ã¯ã¼ã¯ã®ä¸ã§D3ã使ãçºã®
ã¹ãããã¿ãã¬ããã§åçã表示ãã¦ããã¨ããã³ãã§ãºã¼ã ãããããã©ãã°ã§ç§»åããããã§ãã¦ä¾¿å©ãªã®ã§ãããã Web ä¸ã§å®ç¾ãã¦ã¿ãããªã£ãã æè¿ã®ãã©ã¦ã¶ã¼ã§ã¯ touchstart ã touchmove ã¤ãã³ãã§ã¿ããæ å ±ãåããããã¤ãã³ãã® touches ã§ãã«ãã¿ãããæ±ãããããã®ã§ãå®ç¾ããããã®åºç¤ã¯ããã£ã¦ããã é©å½ãªã©ã¤ãã©ãªã¼ããããã¨æã£ã¦æ¢ãã¦ã¿ãããæå¤ã¨è¦å´ãã¦ãã¾ã£ãã Hammer.js ã使ããªã ã¿ãããæ±ãããã®ã©ã¤ãã©ãªã¼ã¨ãã¦ã¯ Hammer.js ãã¡ã¸ã£ã¼ããããã¹ã¯ã¤ãã»ãã³ãã»ãã©ãã°ãªã©ãå種ã¤ãã³ãã«ã対å¿ãã¦ãã¦ãããã使ãã°ä¸çºè§£æ±ºãã¦ããããã ã ã¨ããããç»åãã¥ã¼ã¯ã¼ãä½ãã«ã¯ä¸åãã ã£ããå°ã£ãã®ã¯æ¬¡ã® 2 ç¹ã ãã³ãããã©ãã°ã¯åå¥ã«ã¯åãããçµã¿åãããã¨ãã«ã表示ä½ç½®ãã¨ãåçãã®é¢ä¿ãèªåã§è¨ç®ãã
ãã¼ã·ãã¯ãªæãã®D3.jså ¥éæ¸ããGetting Started with D3ãããInteractive Data Visualization for the Webãã¨è¢«ãå 容ãããã¾ãããæ¬æ¸ã¯âD3.jsã使ã£ã¦SVGãæä½ãããã¨âã«ã¤ãã¦çµæ§æ·±ãæãä¸ãã¦æ¸ããã¦ãã¾ããã¡ãã£ã¢ã¢ã¼ãã£ã½ããµã³ãã«ãå¤ãã®ã§ãD3ã§ä½ãã°ã©ãããã£ã¨ãã£ãããè£ é£¾ãããï¼ãã£ã¦äººã«ãå§ãã§ãã ãæé ä¾¡æ ¼ã
ã¯ã©ã¹ã¿ãªã³ã°ã®å®çªã¢ã«ã´ãªãºã K-means æ³ï¼Kå¹³åæ³ï¼ã®åä½åçãç解ããããã«ãD3.js ã使ã£ã¦å¯è¦åãã¦ã¿ã¾ããã å³ãã¯ãªãã¯ããã [ã¹ããã] ãã¿ã³ãæ¼ãã¨ã1ã¹ããããã¤å¦çãè¡ãã¾ã [æåãã] ãã¿ã³ãæ¼ãã¨ãæåã®ç¶æ ã«æ»ãã¾ã [æ°è¦ä½æ] ãã¿ã³ãæ¼ãã¨ãN (ãã¼ãæ°) 㨠K (ã¯ã©ã¹ã¿æ°) ã®å¤ã§æ°ããåæåãã¾ã å¤ããã©ã¦ã¶ã¼ã§ã¯ãã¾ã表示ã§ããªãå¯è½æ§ãããã¾ã (IE 10ãFirefox 25ãChrome 30 ã§åä½ç¢ºèªãã¦ãã¾ã) K-Means æ³ã¨ã¯ è±èªç Wikipedia ã® k-means clustering - Wikipedia, the free encyclopedia ã®æé ã«æ²¿ã£ã¦å®è£ ãã¦ãã¾ãã è±èªçã®æé ãã¶ãã¯ãªã¨æ¸ãã¨ãããªã¤ã¡ã¼ã¸ã«ãªãã¾ãã åæå: N åã®ãã¼ã (丸å°) 㨠K åã®
shimizu/d3example ããã£ãããåå¼·ä¼ã«ãè¡ã£ããã¨ã ãç©æ¥µçã«gitã使ã£ã¦ãããï¼ã第äºå¼¾ãã¨ããããããã¾ã¾ã§ä½æããD3ã®ãµã³ãã«ã³ã¼ããgithubã«ä¸ãã¦ã¿ã¾ããã ã¢ãããã¼ãããã«ããã£ã¦ãå¤å°ã³ã¼ããæ´çããããã¦ã¿ãã®ã§ãããåãã®é ã«æ¸ããã³ã¼ãã¨ãå²ã¨ä¹±éãªãã®ãæ··ãã£ã¦ã¾ãã ãªããd3.csvãd3.jsonã§å¤é¨ãã¡ã¤ã«ãèªã¿è¾¼ãã§ãã³ã¼ãã¯ãã¼ã«ã«ã§ã¯ãã©ã¦ã¶ã®ã»ãã¥ãªãã£æ©è½ã«ãã£ã¦å®è¡ã§ãã¾ããã webãµã¼ãã¼ä¸ã§å®è¡ãã¦ãã ããã ç¡ãã¨ãã¯âãã©ããã SimpleWebServer ãä½è«ã ãããã¯ã©ã¦ãããã ã¨SSH使ããã¨ã¢ãããã¼ãã§ããªãã¿ããã ã£ãã®ã§ãä¸è¨è¨äºãåèã«ããã¦ããã ãã¾ããã åå¿è Gitæ¥è¨ãã®äºï½GitHubã«SSHå ¬ééµç»é²ï½
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}