AnsweredAssumed Answered

Dojox Charting

Question asked by gsanders32 on Jul 21, 2014

I was wondering if anyone has used dojox charting in their web map. I made a test map using the popup and mediainfos type:"linechart", however I need more control over the chart. I need to label the x-axis and invert y-axis in the chart.

 

So after a lot of searching on google I believe that I need to use dojox charts.

Something like this - http://dojotoolkit.org/reference-guide/1.10/dojox/charting.html

require(["dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/Lines", "dojo/ready"],

  function(Chart, Default, Lines, ready){

  ready(function(){

    var chart1 = new Chart("simplechart");

    chart1.addPlot("default", {type: Lines});

    chart1.addAxis("x");

    chart1.addAxis("y", {vertical: true});

    chart1.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7]);

    chart1.render();

  });

});

I would like to place a chart like this example in a popup - http://dojotoolkit.org/documentation/tutorials/1.8/charting/demo/monthly-sales.php

I would be very grateful if someone could show an example or give some guidance.

 

Thank you

Gray

 

link to test map - HPWD Observation Map

 

This is my current code

<!DOCTYPE html>

<html>

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>

    <title>Simple Map</title>

    <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">

    <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">

    <style>

      html, body, #map {

        height: 100%;

        width: 100%;

        margin: 0;

        padding: 0;

      }

      body {

        background-color: #FFF;

        overflow: hidden;

        font-family: "Trebuchet MS";

      }

    </style>

    <script src="http://js.arcgis.com/3.10/"></script>

    <script>

      var map;

      require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer", "esri/layers/FeatureLayer", "esri/dijit/Popup", "esri/dijit/PopupTemplate", "dojo/domReady!"],

      function(Map, Tiled, FeatureLayer, Popup, PopupTemplate) {

 

        map = new Map("map", {

          basemap: "topo",

          center: [-102.040536, 34.188206], // longitude, latitude

          zoom: 13

        });

     

        var tiled = new Tiled("http://gis.hpwd.com/arcgisweb/rest/services/obswells2014v2/MapServer");

        map.addLayer(tiled);

       

          var template = new PopupTemplate({

          title: "HPWD Water Levels",

          description: "Observation Well Number: {StateWellN}",

          fieldInfos: [{ //define field infos so we can specify an alias

            fieldName: "DTW_2004",

            label: "2004"

          },{

            fieldName: "DTW_2005",

            label: "2005"

          },{

            fieldName: "DTW_2006",

            label: "2006"

          },{

            fieldName: "DTW_2007",

            label: "2007"

          },{

            fieldName: "DTW_2008",

            label: "2009"

          },{

            fieldName: "DTW_2009",

            label: "2009"

          },{

            fieldName: "DTW_2010",

            label: "2010"

          },{

            fieldName: "DTW_2011",

            label: "2011"

          },{

            fieldName: "DTW_2012",

            label: "2012"

          },{

            fieldName: "DTW_2013",

            label: "2013"

          },{

            fieldName: "DTW_2014",

            label: "2014"

          }],

          mediaInfos:[{ //define the bar chart

            caption: "",

            type:"linechart",

            value:{

              fields:["DTW_2004","DTW_2005","DTW_2006","DTW_2007","DTW_2008","DTW_2009","DTW_2010","DTW_2011","DTW_2012","DTW_2013","DTW_2014"]

            }

          }]

        });

 

        var featureLayer = new FeatureLayer("http://gis.hpwd.com/arcgisweb/rest/services/obswells2014v2/MapServer/1",{

          mode: FeatureLayer.MODE_ONDEMAND,

          outFields: ["*"],

          infoTemplate: template

        });

 

        map.addLayer(featureLayer);

      });

    </script>

  </head>

  <body>

    <div id="map"></div>

  </body>

</html>

Outcomes