gpt4 book ai didi

javascript - jqPlot 饼图渲染但抛出错误并且表现得很奇怪?

转载 作者:行者123 更新时间:2023-11-30 18:26:17 24 4
gpt4 key购买 nike

我使用 jqPlot 制作了一个饼图并且饼图确实呈现了,我的代码在下面提到

var plot4 = $.jqplot('pie', [[["none",10],["error",20],["click",30],["impression",40]]], {
seriesDefaults:{
renderer:$.jqplot.PieRenderer,
rendererOptions:{ sliceMargin: 0 }
},
legend:{ show: true }
});

我面临的问题是,当我将鼠标悬停在饼图上时,出现错误提示

B.axes[D[0]]._ticks[0] is undefined

在 Firebug 控制台上。当我点击饼图的任何一个切片时,我看到了一个更奇怪的现象,即我点击的整个切片消失了。

点击前饼图如下所示:-

Original Pie Chart

在我点击棕色区域后,馅饼变成了如下所示的东西,甚至棕色切片也消失了。

Pie Chart without the brown slice

请提供上述解决方案。我尝试了不同的配置,但效果不佳。另外让我告诉你我正在使用其他插件,例如此页面上的条形图和光标。

我在下面提到了我正在执行此操作的页面的完整源代码:-

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>jqPlot Demo</title>
<!--[if IE]><script src="./js/excanvas.min.js"></script><![endif]-->
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.jqplot.js"></script>
<script type="text/javascript" src="./js/jqplot.cursor.min.js"></script>
<script type="text/javascript" src="./js/jqplot.dragable.min.js"></script>
<script type="text/javascript" src="./js/jqplot.trendline.min.js"></script>
<script type="text/javascript" src="./js/jqplot.barRenderer.min.js"></script>
<script type="text/javascript" src="./js/jqplot.pieRenderer.min.js"></script>
<script type="text/javascript" src="./js/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script type="text/javascript" src="./js/jquery-ui.min.js"></script>
<link rel="stylesheet" href="./css/jquery.jqplot.min.css"/>
<link rel="stylesheet" href="./css/jqPlot.css"/>
<script>
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
var lineGraph=$.jqplot('chart', [[[10, 2],[30,5.12],[50,13.1],[70,33.6],[90,85.9],[11,20.9]]],
{
title:'Exponential Line',
axes:{yaxis:{min:0,max:100},xaxis:{min:0,max:100}},
legend:{
show:true,
location:'se',
xoffset:12,
yoffset:0
},
grid:{
gridLineColor:'#F2F2F2',
background:'#FFFFFF',
borderWidth:1,
borderColor:'#BBBBBB',
shadow:true,
shadowAmgle:45,
shadowWidth:2,
shadowOffset:2,
shadowDepth:2
},
cursor:{
style: 'pointer',
show:false,
showTooltip: true,
followMouse:true,
tooltipOffset:10,
tooltipLocation:'se'
},
highlighter: {
lineWidthAdjust: 2.5,
sizeAdjust: 5,
showTooltip: true,
tooltipLocation: 'nw',
fadeTooltip: true,
tooltipFadeSpeed: "fast",
tooltipOffset: 2,
tooltipAxes: 'both',
tooltipSeparator: ', ',
useAxesFormatters: true,
tooltipFormatString: '%.5P'
},
seriesDefaults:{
trendline:{
show:true,
color:'#A2D379',
lable:'trendX',
lineWidth:2,
shadow:true
},
color:'#058DC7',
lineWidth:5,
fill:true,
fillAndStroke:true,
fillColor:'#E6F4F9'
}

});
var plot4 = $.jqplot('pie', [[["none",10],["error",20],["click",30],["impression",40]]], {
seriesDefaults:{
renderer:$.jqplot.PieRenderer,
rendererOptions:{ sliceMargin: 0 }
},
legend:{ show: true },
cursor: {
show: false
}
});
});
$('document').ready(function(){
$('.column').sortable({
connectWith:'.column',
handle:'h2',
cursor:'move',
placeholder:'placeholder',
forcePlaceholderSize:true,
opacity:0.4,
revert:true

}).disableSelection();
}


);
</script>
</head>
<body>
<div class="column" id="column1">
<div class="dragbox" id="item1" >
<h2>Handle 1</h2>
<div class="dragbox-content" >
<div id="chart" style="width:100%;height:100%;float:left"></div>
</div>
</div>
</div>
<div class="column" id="column1">
<div class="dragbox" id="item1" >
<h2>Handle 1</h2>
<div class="dragbox-content" >
<div id="pie" style="width:100%;height:100%;float:left"></div>
</div>
</div>
</div>
<div class="column" id="column1">
<div class="dragbox" id="item1" >
<h2>Handle 1</h2>
<div class="dragbox-content" >
<div id="chart1" style="width:400px;height:300px;float:left"></div>
</div>
</div>
</div>


<div id="barRender" style="width:400px;height:300px;float:left"></div>
</body>
</html>

最佳答案

好的,我得到了问题的答案。我们只需要删除一行代码,之后一切正常

 $.jqplot.config.enablePlugins = true;

当我删除上面的内容时,我会在需要的时候和需要的地方调用单独的插件。当这条语句存在时,所有插件都被启用,这就是奇怪输出的原因。

关于javascript - jqPlot 饼图渲染但抛出错误并且表现得很奇怪?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10717370/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com