block by timelyportfolio 6919316

rCharts micropolar dartboard

Full Screen

index.html

<!doctype HTML>
<meta charset = 'utf-8'>
<html>
  <head>
    <link rel='stylesheet' href="//netdna.bootstrapcdn.com/bootswatch/2.3.1/cosmo/bootstrap.min.css">
     <link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" >
    <link rel='stylesheet' href="//getbootstrap.com/2.3.2/assets/js/google-code-prettify/prettify.css">
    <link rel='stylesheet' href="//aozora.github.io/bootplus/assets/css/docs.css">
    <link rel='stylesheet' href='//micropolar.org/style.css'>
    
    <script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
    <script src='//micropolar.org/micropolar.js' type='text/javascript'></script>
    
    <style>
    .rChart {
      display: block
      margin: auto auto;
    }
    /*
    body {
      margin-top: 60px;
    }
    */
    </style>
    
  </head>
  <body>
    <div class='container'>
      <div class='row'>
        <div class='span8'>
          <div class="bs-docs-example">
            <div id='chart13b466f2179e' class='rChart nvd3Plot micropolar'></div>
          <br/>
<pre><code class='r'>require(rCharts)

make_dataset = function(data = data){
  lapply(toJSONArray2(data, json = F, names = F), unlist)
}


dart &lt;- data.frame(
  score = c(20,1,18,4,13,6,10,15,2,17,3,19,7,16,8,11,14,9,12,5),
  measure = rep(451/2, 20)  #451 mm diameter
)

dartboard &lt;- rCharts$new()
dartboard$setLib(
  &quot;//rcharts.io/howitworks/libraries/widgets/micropolar&quot;
)
dartboard$set(
  data = make_dataset( dart ),
  radialDomain = c(0, 225),
  radialTicksSuffix = '',
  angularDomain = as.character(dart$score),
  minorTicks = 0,
  type = &quot;areaChart&quot;,
  height = 300,
  width = 300
)
dartboard
</code></pre>
</div>
        </div>
      </div>
    </div>
      
    <script>
  var chartParamschart13b466f2179e = {
 "dom": "chart13b466f2179e",
"width":    300,
"height":    300,
"data": [
 [     20,  225.5 ],
[      1,  225.5 ],
[     18,  225.5 ],
[      4,  225.5 ],
[     13,  225.5 ],
[      6,  225.5 ],
[     10,  225.5 ],
[     15,  225.5 ],
[      2,  225.5 ],
[     17,  225.5 ],
[      3,  225.5 ],
[     19,  225.5 ],
[      7,  225.5 ],
[     16,  225.5 ],
[      8,  225.5 ],
[     11,  225.5 ],
[     14,  225.5 ],
[      9,  225.5 ],
[     12,  225.5 ],
[      5,  225.5 ] 
],
"radialDomain": [      0,    225 ],
"radialTicksSuffix": "",
"angularDomain": [ "20", "1", "18", "4", "13", "6", "10", "15", "2", "17", "3", "19", "7", "16", "8", "11", "14", "9", "12", "5" ],
"minorTicks":      0,
"type": "areaChart",
"id": "chart13b466f2179e" 
}
  chartParamschart13b466f2179e.containerSelector = '#chart13b466f2179e'
  micropolar.factory[chartParamschart13b466f2179e.type](
    chartParamschart13b466f2179e
  )
</script>
    
  </body>
  <!-- Google Prettify -->
  <script src="//cdnjs.cloudflare.com/ajax/libs/prettify/188.0.0/prettify.js"></script>
  <script 
    src='https://google-code-prettify.googlecode.com/svn-history/r232/trunk/src/lang-r.js'>
  </script>
  <script>
    var pres = document.getElementsByTagName("pre");
    for (var i=0; i < pres.length; ++i) {
      pres[i].className = "prettyprint linenums";
    }
    prettyPrint();
  </script>
</html>

code.R

require(rCharts)

make_dataset = function(data = data){
  lapply(toJSONArray2(data, json = F, names = F), unlist)
}


dart <- data.frame(
  score = c(20,1,18,4,13,6,10,15,2,17,3,19,7,16,8,11,14,9,12,5),
  measure = rep(451/2, 20)  #451 mm diameter
)

dartboard <- rCharts$new()
dartboard$setLib(
  "http://rcharts.io/howitworks/libraries/widgets/micropolar"
)
dartboard$set(
  data = make_dataset( dart ),
  radialDomain = c(0, 225),
  radialTicksSuffix = '',
  angularDomain = as.character(dart$score),
  minorTicks = 0,
  type = "areaChart",
  height = 300,
  width = 300
)
dartboard