Skip to content

Instantly share code, notes, and snippets.

@yllus
Created May 19, 2014 23:14
Show Gist options
  • Select an option

  • Save yllus/156307ae241178bd5fd4 to your computer and use it in GitHub Desktop.

Select an option

Save yllus/156307ae241178bd5fd4 to your computer and use it in GitHub Desktop.

JavaScript:

nv.addGraph(function() {
  var chart = nv.models.pieChart()
      .x(function(d) { return d.label })
      .y(function(d) { return d.value })
      .color(['#d0212a', '#2f587f'])
      .showLabels(false)
      .donut(true)
      .donutRatio(0.50)
      .showLegend(false)
      .tooltips(false);

    d3.select("#chart svg")
      .datum(data)
      .transition().duration(500)
      .call(chart);

  return chart;
});	

HTML:

<style>
#chart svg {
  height: 200px;
}
</style>

<div id="chart">
  <svg></svg>
</div>

Data:

 [
  {
    "label": "One",
    "value" : 29.765957771107
  } ,
  {
    "label": "Two",
    "value" : 14
  }

]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment