dc.js 1.7中的饼图图例未显示

Jef*_*les 1 javascript legend d3.js pie-chart dc.js

我正在尝试在dc.js中创建一个饼图图例.但是,没有传说.它只是...没有显示出来.一切都和我使用legend命令之前一样.

这是JSBin

这是传说代码:

.legend(dc.legend().x(80).y(70).itemHeight(13).gap(5));
Run Code Online (Sandbox Code Playgroud)

以下是相关代码的其余部分:

  var companyDimension = data.dimension(function(d) {return d.company;});
  var totalSalesByCompany = companyDimension.group().reduceSum(function(d) {return d.total;});
  var pieChartCompanySales = dc.pieChart("#pie-chart-sales-by-company");
  pieChartCompanySales
    .width(150).height(150)
    .dimension(companyDimension)
    .group(totalSalesByCompany)
    .legend(dc.legend().x(80).y(70).itemHeight(13).gap(5));

  dc.renderAll();
Run Code Online (Sandbox Code Playgroud)

我从本教程中获取了我的传奇代码,似乎可以查看官方文档.我究竟做错了什么?

Sid*_*pta 5

我认为你没有做错任何事.它是你正在使用的dc.js版本的问题.请查看http://jsbin.com/xasenusu/1/.我已经更改了dc.js的版本,并为div提供了更多的空间.

 <!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.7/crossfilter.min.js"></script>
  <script type="text/javascript" src="http://dc-js.github.io/dc.js/js/dc.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
    <style>
    #pie-chart-sales-by-company svg{width:350px;}</style>
</head>
<body>

<div id="pie-chart-sales-by-company"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)