Javascript 该插件不能处理动态更新的数据

Javascript 该插件不能处理动态更新的数据,javascript,jquery,ajax,Javascript,Jquery,Ajax,插件描述的快捷方式: 按钮 graphResolutionByYear=新阵列([ [5, 11, 6, 11], "1" ]); $(“#多重图”).jqBarGraph({ 数据:按年份绘制的解决方案图, 宽度:850, 身高:250 }); $(“#按钮”)。单击(函数(){ $.ajax({ 类型:“POST”, 网址:“d.php”, 数据:{ 日期:“15” }, 成功:函数(msg){ 警报(msg) var qqq=msg; graphResolutionByYear=新阵列

插件描述的快捷方式:


按钮
graphResolutionByYear=新阵列([
[5, 11, 6, 11], "1"
]);
$(“#多重图”).jqBarGraph({
数据:按年份绘制的解决方案图,
宽度:850,
身高:250
});
$(“#按钮”)。单击(函数(){
$.ajax({
类型:“POST”,
网址:“d.php”,
数据:{
日期:“15”
},
成功:函数(msg){
警报(msg)
var qqq=msg;
graphResolutionByYear=新阵列([
[qqq,qqq,qqq,qqq],“1”
]);
$(“#多重图”).jqBarGraph({
数据:按年份绘制的解决方案图,
宽度:850,
身高:250
});
}
});
});

您没有关闭最终按钮单击事件

graphResolutionByYear=新数组([
[5, 11, 6, 11], "1"
]);
$(“#图”).jqBarGraph({
数据:按年份绘制的解决方案图
});
$(“#按钮”)。单击(函数(){
$.ajax({
类型:“POST”,
url:“date.php”,
数据:{
日期:“2015年1月1日”
},
成功:功能(msg){
var qqq=msg;
graphResolutionByYear=新阵列([
[qqq,qqq,qqq,qqq],“1”
]);
$(“#图”).jqBarGraph({
数据:按年份绘制的解决方案图
});
}
});
});

/**
*jqBarGraph-jQuery插件
*@version:1.1(2011/04/03)
*@需要jQuery v1.2.2或更高版本
*@作者伊万·拉扎雷维奇
*示例和文档位于:http://www.workshop.rs/jqbargraph/
* 
*MIT和GPL许可下的双重许可:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
* 
*/
(function($){var opts=new Array;var level=new Array;$.fn.jqBarGraph=$.fn.jqBarGraph=function(options){init=function(el){opts[el.id]=$.extend({},$.fn.jqBarGraph.defaults,options);$(el.css({'width':opts[el.id]。width,'height':opts[el.id]。高度,'position':'relative','text-align':'center'});doGraph(el);}总和=函数(ar=0;用于{{total+=ar[val];}
返回total.toFixed(2);};max=function(ar){maxvalue=0;for(ar中的var-val){value=ar[val][0];if(数组的值实例)value=sum(value);if(parseFloat(value)>parseFloat(maxvalue))maxvalue=value;}
返回maxvalue;};maxMulti=function(ar){maxvalue=0;maxvalue2=0;for(ar中的var-val){ar2=ar[val][0];for(ar2中的var-val2){if(ar2[val2]>maxvalue2)maxvalue2=ar2[val2];}
如果(maxvalue2>maxvalue)maxvalue=maxvalue2;}
return maxvalue;};doGraph=function(el){arr=opts[el.id];data=arr.data;if(data==undefined){$(el.html('图形没有足够的数据');return;}
if(arr.sort=='asc')data.sort(sortNumberAsc);if(arr.sort=='desc')data.sort(sortNumberDesc);legend='';prefix=arr.prefix;postfix=arr.postfix;space=arr.barSpace;legendWidth=arr.legendWidth?arr.legendWidth:0;fieldWidth=($(el.width()-legendWidth)/data.length;totalHeight=$(el.height();var leg=new数组();max=max(data);colPosition=0;for(var-val-in-in-data){valueData=data[val][0];if(数组的valueData实例)
值=总和(valueData);否则
value=valueData;lbl=data[val][1];color=data[val][2];unique=val+el.id;if(color==undefined&&arr.colors==false)
color=arr.color;if(arr.colors&&!color){colorscenter=arr.colors.length;if(colorscenter==colPosition)colPosition=0;color=arr.colors[colPosition];colPosition++;}
if(arr.type=='multi')color='none';if(lbl==未定义)lbl=arr.lbl;out=“”;out+=”+前缀+值+后缀+”;out+=”;if(!arr.legend | | arr.legends)
out+=“”+lbl+“”;out+=“”;$(el).追加(out);totalHeightBar=totalHeight-$('.graphLabel'+el.id).高度()-$('.graphValue'+el.id).高度();字段高度=(totalHeightBar*value)/max;$('#graphField'+unique).css({'left':(fieldWidth)*val,'width':fieldWidth space,'margin-left':space});if(valueData instanceof Array){if(arr.type=“multi”){MaxData=maxe);totalHeightBar=fieldHeight=totalHeight-$('.graphLabel'+el.id).height();$('.graphValue'+el.id).remove();}其他{maxe=max;}
对于(i in valueData){heig=totalHeightBar*valueData[i]/maxe;wid=parseInt((字段宽度空间)/valueData.length);sv='';fs=0;if(arr.showValues){sv=arr.prefix+valueData[i]+arr.postfix;fs=12;}
o=“”+sv+”;$(“#graphFieldBar”+唯一)。前缀(o);}
如果(arr.type=='multi')
$('.subBars'+el.id).css({'width':wid,'position':'absolute','bottom':0});if(arr.position=='bottom')$('.graphField'+el.id).css('bottom',0);if(!arr.legends)
leg.push([color,lbl,el.id,unique]);if(arr.animate){$('graphFieldBar'+unique).css({'height':0});$('graphFieldBar'+unique).animate({'height':fieldHeight},arr.speed*1000)}else{$('graphFieldBar'+unique).css({'height':fieldHeight})}
对于(arr.legends中的var l){leg.push([arr.colors[l],arr.legends[l],el.id,l]);}
createLegend(leg);if(arr.legend){$(el).append(“”;$)('legendBar'+el.id).css({'width':legendWidth,'float':'right','text-align':'left'});$('legendBar'+el.id);$('float':'left','margin':3,'height':12,'width':20,'font-size':0})
if(arr.title){$(el).wrap(“”;$)(“#graphHolder”+unique).prepend(arr.title).css({'width':arr.width+'px','text-align':'center'});}};createLegendard=函数(legendArr=”;for(legendar中的var val){legend+=”;legend+=”;legend+=”;legend+=“+legendArr[val][1];legend+=”};this.each(函数()
{init(this);};$.fn.jqBarGraph.defaults={barSpace:10,宽度:400,高度:300,颜色:'#000000',颜色:false,lbl:'',排序:false,位置:'bottom',前缀:'',后缀:'',动画:true,速度:1.5,legendWidth:100,图例:false,类型:false,showValues:true,showValuesColor:'#fff',title:false};函数sortNumberAsc(a,b){if(a[0]b[0]返回1])

函数sortNumberDesc(a,b){if(a[0]>b[0])返回-1;if(a[0]也许这个答案可以帮助您: