javascript - ReferenceError: $ is not defined for original flot library -


everyone, got error inside original flot.js library. wonder wrong part of script? *the error shwon fire bug firefox error msg is:

referenceerror: $ not defined  $(document).ready(function () {  

the line starts claim error code is:

$(document).ready(function () { $.plot($("#flot-placeholder1"), dataset, options); $("#flot-placeholder1").usetooltip(); });  

and below before error line:

 <script> //******* 2012 gold price chart var data1 = [ [gd(2012, 0, 1), 1652.21], [gd(2012, 1, 1), 1742.14], [gd(2012, 2, 1), 1673.77], [gd(2012, 3, 1), 1649.69], [gd(2012, 4, 1), 1591.19], [gd(2012, 5, 1), 1598.76], [gd(2012, 6, 1), 1589.90], [gd(2012, 7, 1), 1630.31], [gd(2012, 8, 1), 1744.81], [gd(2012, 9, 1), 1746.58], [gd(2012, 10, 1), 1721.64], [gd(2012, 11, 2), 1684.76] ]; var data2 = [ [gd(2012, 0, 1), 0.63], [gd(2012, 1, 1), 5.44], [gd(2012, 2, 1), -3.92], [gd(2012, 3, 1), -1.44], [gd(2012, 4, 1), -3.55], [gd(2012, 5, 1), 0.48], [gd(2012, 6, 1), -0.55], [gd(2012, 7, 1), 2.54], [gd(2012, 8, 1), 7.02], [gd(2012, 9, 1), 0.10], [gd(2012, 10, 1), -1.43], [gd(2012, 11, 2), -2.14] ]; var dataset = [ { label: "gold price", data: data1, points: { symbol: "triangle"} }, { label: "change", data: data2, yaxis: 2 } ]; var options = { series: { lines: { show: true }, points: { radius: 3, fill: true, show: true } }, xaxis: { mode: "time", ticksize: [1, "month"], ticklength: 0, axislabel: "2012", axislabelusecanvas: true, axislabelfontsizepixels: 12, axislabelfontfamily: 'verdana, arial', axislabelpadding: 10 }, yaxes: [{ axislabel: "gold price(usd)", axislabelusecanvas: true, axislabelfontsizepixels: 12, axislabelfontfamily: 'verdana, arial', axislabelpadding: 3, tickformatter: function (v, axis) { return $.formatnumber(v, { format: "#,###", locale: "us" }); } }, { position: "right", axislabel: "change(%)", axislabelusecanvas: true, axislabelfontsizepixels: 12, axislabelfontfamily: 'verdana, arial', axislabelpadding: 3 } ], legend: { nocolumns: 0, labelboxbordercolor: "#000000", position: "nw" }, grid: { hoverable: true, borderwidth: 2, bordercolor: "#633200", backgroundcolor: { colors: ["#ffffff", "#edf5ff"] } }, colors: ["#ff0000", "#0022ff"] }; 

=================update===================================================== hi, everyone. answer! here order load script (load correctly because test in dw cs4 1. jquery-1.8.3.min.js 2. jquery.flot.min.js" 3. jquery.flot.time.js" 4. jquery.flot.symbol.js 5. jquery.flot.axislabels.js 6. jshashtable-2.1.js 7. jquery.numberformatter-1.2.3.min.js

so consider order should not problem, following tutorial told me here: http://www.pureexample.com/jquery-flot-tutorial-how-to-make-a-jquery-flot-line-chart.html

also found these code put stop on firefox/firebug, maybe helps. stop put in front of 2nd line of code--> '$(this).bind("plot...'.

$.fn.usetooltip = function () { $(this).bind("plothover", function (event, pos, item) { if (item) { if ((previouslabel != item.series.label) || (previouspoint != item.dataindex)) { previouspoint = item.dataindex; previouslabel = item.series.label; $("#tooltip").remove(); var x = item.datapoint[0]; var y = item.datapoint[1]; var color = item.series.color; var month = new date(x).getmonth(); //console.log(item); if (item.seriesindex == 0) { showtooltip(item.pagex, item.pagey, color, "<strong>" + item.series.label + "</strong><br>" + monthnames[month] + " : <strong>" + y + "</strong>(usd)"); } else { showtooltip(item.pagex, item.pagey, color, "<strong>" + item.series.label + "</strong><br>" + monthnames[month] + " : <strong>" + y + "</strong>(%)"); } } } else { $("#tooltip").remove(); previouspoint = null; } }); };  

thanks.

further question kevin asked under comment answer....

the error here:

$(document) 

$ not defined. means either aren't including jquery, including late, or using $.noconflict() incorrectly.

more specifically, $ === undefined, , undefined not function , therefore can't executed.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -