• Properties
    Pie Chart

    <style>
    g.arc path{
    stroke: #666;
    }
    </style>
    <div id="chart">
    </div>
    <h3>Example of a chart</h3>
    <p>Data has been dynamically obtained from the list of wines below</p>
    <p>Please see <a href="/doc/26:0">settings</a> for details</p>

    var width = 400,
    height = 300,
    radius = Math.min(width, height) / 2;

    var color = d3.scale.ordinal()
    .range(["#FF5555", "#EEEEEE", "#FFAAAA"]);

    var arc = d3.svg.arc()
    .outerRadius(radius - 10)
    .innerRadius(0);

    var pie = d3.layout.pie()
    .sort(null)
    .value(function(d) { return d.count; });

    var svg = d3.select("#chart").append("svg")
    .attr("width", width)
    .attr("height", height)
    .append("g")
    .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

    d3.json("/orientdb/query/db/sql/select+count(name),+colour.name+from+WWine+group+by+colour", function(error, data) {

    /*data.forEach(function(d) {
    d.population = +d.population;
    });*/
    data = data.result;

    var g = svg.selectAll(".arc")
    .data(pie(data))
    .enter().append("g")
    .attr("class", "arc");

    g.append("path")
    .attr("d", arc)
    .style("fill", function(d) { return color(d.data.colour); });

    g.append("text")
    .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; })
    .attr("dy", ".35em")
    .style("text-anchor", "middle")
    .text(function(d) { return d.data.colour; });

    });

    browse-html-js-pane
    https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js
Wicket Wicket Console Panel 8.3.0 Inspector Session: 3.1KB Page: 61.4KB Remove