我正在尝试重新绘制我的 jqplot 图表。
$(document).ready(function(){
var dataseries = [[[10,20]]];
var plot = $.jqplot('placeholder', dataseries ,
{ title:'<%= @question.text%>',
axes:{
yaxis:{min:-100, max:100, tickInterval:10, showTicks:true, label:"<%=@question.ylabel1%>"},
xaxis:{min:-100, max:100, tickInterval:10, showTicks:true, label: "<%=@question.xlabel1%>"},
y2axis:{min:-100, max:100, tickInterval:10, showTicks:true, label:"<%=@question.ylabel2%>", show:true},
x2axis:{min:-100, max:100, tickInterval:10, showTicks:true, label:"<%=@question.xlabel2%>", show:true}},
seriesDefaults:{showLine:false},
series:<%=itemNames.html_safe%>,
highlighter:{
show:true,
tooltipContentEditor:tooltipContentEditor}
});
});
function tooltipContentEditor(str, seriesIndex, pointIndex, plot) {
return plot.series[seriesIndex]["label"];
}
$("#placeholder").bind("jqplotClick", function(ev, gridpos, datapos, neighbor) {
var x = Math.round(datapos.xaxis);
var y = Math.round(datapos.yaxis);
var item = $('li.item_button_selected').attr('id');
if (item > 0){
var requestObj = {
question_id: "<%=@question.id%>",
user_id: "1",
}
requestObj["item_id"]=item
requestObj["x"]=x
requestObj["y"]=y
plot.series[0].data = [[50,50]];
plot.replot();
BLAH BLAH BLAH...
<%=itemNames.html_safe%> 通常如下所示:[{label:"Winona Ryder"},{label:"Paris Hilton"},{label:"Margaret Thatcher"},{label:"Snooki"},{标签:“娜塔莉波特曼”},]
页面加载时图表绘制良好;当我点击图表时,什么也没有发生。我知道点击被捕获;如果我在那里发出警报,我会看到它。帮助!