Book Image

Mastering ArcGIS Server Development with JavaScript

By : Raymond Kenneth Doman
Book Image

Mastering ArcGIS Server Development with JavaScript

By: Raymond Kenneth Doman

Overview of this book

Table of Contents (18 chapters)
Mastering ArcGIS Server Development with JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using D3.js in our application


In our application, we will explore using D3 to add graphs to our application. We'll use it to replace parts of the dojox/charting code where we add the graphs to our map popup. Many of the steps will be similar, but some will be different.

Adding D3.js to the configuration

Since our application relies heavily on the Dojo framework, we will add our D3.js library with AMD. We'll add the reference to D3 in our dojoConfig.packages list. The new dojoConfig script should look like the following:

dojoConfig = {
  async: true,
  packages: [
    {
      name: 'y2k',
      location: location.pathname.replace(/\/[^\/]*$/, '') +'/js'
    },
    {
      name: "d3",
      location: "http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.12/"
    }
  ]
};

Now that our AMD code knows where to look for the D3 library, we can add a reference to it in our census application. The D3 library will then be available to our census widget, but it will not interfere with other applications that...