d3pie在JS Bin中工作,而不是在浏览器中工作

时间:2015-08-02 00:07:20

标签: javascript jquery html d3.js d3pie.js

我正在尝试在浏览器上运行d3pie中的示例代码,然后才开始输入我自己的数据/编辑它。当我将它粘贴到JS Bin时,无论是在Firefox还是Chrome上,它都可以正常工作。这就是代码的外观:

<html>
<head></head>
<body>

<div id="pieChart"></div>

<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.4.4/d3.min.js"></script>
<script src="https://rawgit.com/benkeen/d3pie/master/d3pie/d3pie.min.js">   </script>



<script>

   var randomval = 50;
   var pie = new d3pie("pieChart", {
"header": {
"title": {
"text": "Lots of Programming Languages",
"fontSize": 24,
"font": "open sans"
},
"subtitle": {
"text": "A full pie chart to show off label collision detection and resolution.",
"color": "#999999",
"fontSize": 12,
"font": "open sans"
},
"titleSubtitlePadding": 9
},
"footer": {
"color": "#999999",
"fontSize": 10,
"font": "open sans",
"location": "bottom-left"
},
"size": {
"canvasWidth": 590,
"pieOuterRadius": "90%"
},
"data": {
"sortOrder": "value-desc",
"content": [
{
"label": "JavaScript",
"value": randomval,
"color": "#2484c1"
},
{
"label": "Ruby",
"value": 218812,
"color": "#0c6197"
},
{
"label": "Java",
"value": 157618,
"color": "#4daa4b"
}
]
},
"labels": {
"outer": {
"pieDistance": 32
},
"inner": {
"hideWhenLessThanPercentage": 3
},
"mainLabel": {
"fontSize": 11
},
"percentage": {
"color": "#ffffff",
"decimalPlaces": 0
},
"value": {
"color": "#adadad",
"fontSize": 11
},
"lines": {
"enabled": true
},
"truncation": {
"enabled": true
}
},
"effects": {
"pullOutSegmentOnClick": {
"effect": "linear",
"speed": 400,
"size": 8
}
},
"misc": {
"gradient": {
"enabled": true,
"percentage": 100
}
}
});

</script>

</body>
</html>

但是,当我将此代码复制粘贴到HTML文件并在Chrome或Firefox上运行该HTML文件时,我们看不到任何图表!我将d3pie.min.js的脚本更改为:

<script src="d3pie.min.js></script>

我很肯定我在本地正确保存了d3pie.min.js文件。我似乎无法弄清楚问题是什么以及为什么它没有在浏览器上正确显示。过去有没有人遇到过这类问题?谢谢!

1 个答案:

答案 0 :(得分:1)

更改

cpdef enum:
    CONST_A = 0
    CONST_B = 1

<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.4.4/d3.min.js"></script>