I am plotting a graph in XPages using QJplot. It was working fine before until I copied the entire process ie, buttons that extract data, buttons that plot data etc. Now for some reason I keep getting an error that says "An error has occurred while updating some of the page. $ is not a function." When I do a preview in the browser and look on the error console it highlights this "$(document).ready(function(){"
In the working version the code below is identical, the only difference is the values are extracted from a different view.
`<xp:scriptBlock id="scriptBlock" rendered="true">
<xp:this.value>
<![CDATA[$(document).ready(function(){
var line1 = #{javascript:return compositeData.Temp};
var line2 = #{javascript:return compositeData.MaxTemp};
var line3 = #{javascript:return compositeData.MinTemp};
var ticks1 = #{javascript:return compositeData.Time};
var plot1 = $.jqplot('chart3', [line1,line2,line3], {
title: '#{javascript: return compositeData.title}',
animate:#{javascript:return compositeData.animated},
seriesDefaults: {
renderer: $.jqplot.LineRenderer,
rendererOptions:{lineMargin: 25},
pointLabels:{show:true, stackedValue: true}
},
series:[
{label:'#{javascript:return compositeData.legendTemp}'},
{label:'#{javascript:return compositeData.legendMaxTemp}'},
{label:'#{javascript:return compositeData.legendMinTemp}'},
],
legend: {
show: #{javascript:return compositeData.legendShow},
placement: '#{javascript:return compositeData.legendPlacement}'
},
axes: {
xaxis:{
label: "Time (min)",
pad: 0,
renderer:$.jqplot.CategoryAxisRenderer,
ticks: ticks1
},
yaxis:{
label: "Temperature (Deg. C)"
}
}
});
});
]]>
</xp:this.value>
</xp:scriptBlock>`
The code which extracts values from the view is working too. The button that doesn't work is the one that is supposed to plot the graph.
<xp:button
value="Replot Chart" id="refresh_code_plot">
<xp:eventHandler
event="onclick" submit="true" refreshMode="partial"
refreshId="code_plot">
</xp:eventHandler>
</xp:button>
code_plot is the custom control which contains scriptBlock. It is linked to the XPages via this code
<xc:code_plot
id="code_plot" legendMaxTemp="Upper Threshold"
legendMinTemp="Lower Threshold" legendTemp="Data"
title="Logger Data (Temperature)" cssStyle="width:900px;">
<xc:this.animated><![CDATA[#{javascript:getComponent("animated").getValue();}]]></xc:this.animated>
<xc:this.Temp><![CDATA[#{javascript:getComponent("extracted_Temp").getValue();}]]></xc:this.Temp>
<xc:this.MaxTemp><![CDATA[#{javascript:getComponent("extracted_MaxTemp").getValue();}]]></xc:this.MaxTemp>
<xc:this.MinTemp><![CDATA[#{javascript:getComponent("extracted_MinTemp").getValue();}]]></xc:this.MinTemp>
<xc:this.legendShow><![CDATA[#{javascript:"true";}]]></xc:this.legendShow>
<xc:this.stackedSeries><![CDATA[#{javascript:getComponent("stackSeries").getValue();}]]></xc:this.stackedSeries>
<xc:this.ticks><![CDATA[#{javascript:getComponent("extracted_Time").getValue();}]]></xc:this.ticks>
<xc:this.Time><![CDATA[#{javascript:getComponent("extracted_Time").getValue();}]]></xc:this.Time>
<xc:this.legendPlacement><![CDATA[#{javascript:getComponent("extracted_Time").getValue()}]]></xc:this.legendPlacement>
</xc:code_plot>
Are there any obvious bugs in this?