Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用flotr的饼图html文件无法完全工作_Javascript_Html_Flotr - Fatal编程技术网

Javascript 使用flotr的饼图html文件无法完全工作

Javascript 使用flotr的饼图html文件无法完全工作,javascript,html,flotr,Javascript,Html,Flotr,我只是尝试使用flotr(一种用于开发各种图表的开源javascript)绘制一个简单的饼图。但我给出的代码只起了一小部分作用。绘制了图表,爆炸特性、水平线和垂直线都很好。但是鼠标跟踪器和传说都不起作用。我想我在代码上犯了一些错误。但我无法清除它。有人帮我吗。提前谢谢 <html> <head> <script type="text/javascript" src="prototype-1.6.0.2.js"></script> <scrip

我只是尝试使用flotr(一种用于开发各种图表的开源javascript)绘制一个简单的饼图。但我给出的代码只起了一小部分作用。绘制了图表,爆炸特性、水平线和垂直线都很好。但是鼠标跟踪器和传说都不起作用。我想我在代码上犯了一些错误。但我无法清除它。有人帮我吗。提前谢谢

<html>
<head>
<script type="text/javascript" src="prototype-1.6.0.2.js"></script>
<script type="text/javascript" src="flotr.js"></script>
</head>
    <body>
        <div id="container" style="width:600px;height:300px;" ></div>

        <script type="text/javascript">
        (function basic_pie(container) {
  var
    d1 = [[0, 4]],
    d2 = [[0, 3]],
    d3 = [[0, 1.03]],
    d4 = [[0, 3.5]],
    graph;
   graph = Flotr.draw('container', [
    { data : d1, label : 'Comedy' },
    { data : d2, label : 'Action' },
    { data : d3, label : 'Romance',
      pie : {
        explode : 50
      }
    },
    { data : d4, label : 'Drama' }
  ], {
    HtmlText : false,
    grid : {
      verticalLines : false,
      horizontalLines : false
    },
    xaxis : { showLabels : false },
    yaxis : { showLabels : false },
    pie : {
      show : true, 
      explode : 6
    },
    mouse : { track : true },
    legend : {
      position : 'se',
      backgroundColor : '#D2E8FF'
    }
  });
})(document.getElementById("editor-render-0"));
</script>
</body>
</html>

(功能基本图(容器){
变量
d1=[[0,4]],
d2=[[0,3]],
d3=[[0,1.03]],
d4=[[0,3.5]],
图表
graph=Flotr.draw('容器'[
{数据:d1,标签:'喜剧'},
{data:d2,标签:'Action'},
{数据:d3,标签:'浪漫',
馅饼:{
爆炸:50
}
},
{数据:d4,标签:'戏剧'}
], {
HtmlText:false,
网格:{
轮回:错,
水平线:错误
},
xaxis:{showLabels:false},
yaxis:{showLabels:false},
馅饼:{
秀:没错,
爆炸:6
},
鼠标:{track:true},
图例:{
位置:'se',
背景颜色:“#D2E8FF”
}
});
})(document.getElementById(“editor-render-0”);

您的图例配置可能有错误,我已将其删除,图例显示正确。看看:

你可以检查你的浏览器类型,你使用哪种浏览器?如果是IE,你应该加上

meta http-equiv="X-UA-Compatible" content="IE=edge"
段的第一行,添加

[if IE]> script type="text/javascript" src="../lib/excanvas.js">script <![endif]
函数basic\u pie(container)
的第一行中,指向container元素


(注意:我的一些答案字符串被stackoverflow网站弄乱了。很抱歉)

谢谢matthew。现在对我来说很好。但是鼠标轨迹问题仍然存在。我在这里更新了代码。
var container = document.getElementById(' container ');