I am having trouble accessing some of the features of Dojo via the ESRI js. I have used several links to no avail
http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/
When I try to use dijit.form.Form I hit an undefined error. I notice that this is not referenced in any of the above links. I resolved this problem by using dijit.layout.ContentPane. Notably I could use dijit.form.Button and dijit.form.TextBox so it is not an issue with dijit.form.
Now I am hitting a similar error with dojox.charting however I do not appear to be able to hit dojox.charting at all. Once again I notice that it is not referenced in the linked Javascript.
I have minimal HTML scripting as I am building nearly everything programatically:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://js.arcgis.com/3.11/"></script>
My Javascript looks like this:
/*global esri*/
/*global dojo*/
/*global dijit*/
/*global dojox*/
function createLineChart(startMeasure, elevations) {
var lineChart = new dojox.charting.Chart("simplechart");
lineChart.addPlot("default", {type: "Lines"});
lineChart.addAxis("x");
lineChart.addAxis("y", {vertical: "true"});
lineChart.addSeries("SERIES X", elevations);
lineChart.render();
}
The error is on the first line of the function where Chart is undefined, charting is also undefined as is Chart2D.
I am perplexed as to why everything else works but I do not seem to be hit a number of functions from the Dojo toolkit when I can use other functions in the same namespace.
Solved! Go to Solution.
Hi Henry,
anything in between /* */ is a comment and is not used during runtime. JavaScript Comments .
The reason you got away with not using requires is because http://js.arcgis.com/3.10/ already requires few modules like button, contentPane etc.
Since you are new to javascript i would recommend you start using AMD straight way instead of legacy dojo.
dojo.require("dojox.charting.Chart"); var chart = new dojox.charting.Chart(); is legacy
require(["dojox/charting/Chart"], function(Chart) { var chart = new Chart(); }); is AMD
Check out these samples at Create a map | ArcGIS API for JavaScript you can get fair bit of understanding on using AMD.
Hi Henry,
Chart and Form are included in the Javascript API. http://js.arcgis.com/3.10/js/dojo/dojox/charting/Chart.js , http://js.arcgis.com/3.10/js/dojo/dijit/form/Form.js
Did you require them before using?
dojo.require("dojox.charting.Chart");
dojo.require("dijit.form.Form");
Hi Riyas,
So far I have managed to get away with not using "dojo.require" at all in my project. My understanding was that including lines like
/*global dojox*/
should be the same as require. Relatively new to Javscript at the moment so am quite likely making basic errors.
I tried including
dojo.require("dojox.charting.Chart");
in the first line of the createLineChart function with no success but not sure if that is the right place to do it.
Hi Henry,
anything in between /* */ is a comment and is not used during runtime. JavaScript Comments .
The reason you got away with not using requires is because http://js.arcgis.com/3.10/ already requires few modules like button, contentPane etc.
Since you are new to javascript i would recommend you start using AMD straight way instead of legacy dojo.
dojo.require("dojox.charting.Chart"); var chart = new dojox.charting.Chart(); is legacy
require(["dojox/charting/Chart"], function(Chart) { var chart = new Chart(); }); is AMD
Check out these samples at Create a map | ArcGIS API for JavaScript you can get fair bit of understanding on using AMD.
Awesome Riyas,
Thanks for your help