0

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?

3 Answers3

2

Seems you are indeed missing your jquery link. Also simplify:

old:

{label:'#{javascript:return compositeData.legendTemp}'}

new:

{label:'#{compositeData.legendTemp}'}
stwissel
  • 20,110
  • 6
  • 54
  • 101
1

Are you including jQuery on the main page? it doesn't recognize its namespace.

Andrei Nemes
  • 3,062
  • 1
  • 16
  • 22
  • The and the button are on the main page, just like in the working example. Unless there is another way to include it? The plugins are also on the main page. –  May 09 '13 at 14:08
0

I fixed this bug. Because I am using different custom controls I didn't define one or two variables in the custom properties and this is why the button which is responsible for plotting the graph wasn't working. One of the other problems I had was in the extracted_Data ids. It is case sensitive and when I was transferring the buttons etc.. the case of some of the ids changed.