| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 5 | <title>Chart: Map&Chart</title> |
| 6 | <style type="text/css"> |
| 7 | @import "../../../../dojo/resources/dojo.css"; |
| 8 | @import "../../../../dijit/tests/css/dijitTests.css"; |
| 9 | @import "../../../../dijit/themes/tundra/tundra.css"; |
| 10 | @import "../resources/Map.css"; |
| 11 | .mapContainer { |
| 12 | display: none; |
| 13 | width: 810px; |
| 14 | height: 400px; |
| 15 | border: solid 1px; |
| 16 | } |
| 17 | |
| 18 | .mapVerticalContainer { |
| 19 | display: none; |
| 20 | width: 405px; |
| 21 | height: 500px; |
| 22 | border: solid 1px; |
| 23 | } |
| 24 | </style> |
| 25 | <script type="text/javascript" data-dojo-config="parseOnLoad:true,isDebug:true,gfxRenderer:'svg,canvas,vml,silverlight'" src="../../../../dojo/dojo.js"></script> |
| 26 | <script type="text/javascript"> |
| 27 | var isTouchDevice = dojo.isIos || (navigator.userAgent.toLowerCase().indexOf("android") > -1) |
| 28 | || (navigator.userAgent.toLowerCase().indexOf("blackberry") > -1); |
| 29 | </script> |
| 30 | <script type="text/javascript"> |
| 31 | dojo.require("dojox.geo.charting.Map"); |
| 32 | dojo.require("dojox.charting.Chart"); |
| 33 | dojo.require("dojox.charting.axis2d.Default"); |
| 34 | dojo.require("dojox.charting.plot2d.ClusteredBars"); |
| 35 | dojo.require("dojox.charting.plot2d.Grid"); |
| 36 | dojo.require("dojo.data.ItemFileReadStore"); |
| 37 | dojo.requireIf(isTouchDevice,"dojox.geo.charting.TouchInteractionSupport"); |
| 38 | dojo.requireIf(!isTouchDevice,"dojox.geo.charting.MouseInteractionSupport"); |
| 39 | dojo.require("dojox.geo.charting.KeyboardInteractionSupport"); |
| 40 | dojo.require("dojox.charting.themes.PlotKit.blue"); |
| 41 | var chartStore = new dojo.data.ItemFileReadStore({ |
| 42 | url: "datastore/dataStore.json" |
| 43 | }); |
| 44 | var chart,series,productList; |
| 45 | dojo.addOnLoad(function(){ |
| 46 | productSeries = [0,0,0,0,0,0]; |
| 47 | productList = ["product A", "product B","product C","product D","product E","product F"]; |
| 48 | |
| 49 | chart = (new dojox.charting.Chart("chartDiv")). |
| 50 | addAxis("x", { |
| 51 | fixLower: "major", |
| 52 | fixUpper: "major", |
| 53 | minorTicks: false, |
| 54 | includeZero: true, |
| 55 | min:0, |
| 56 | max: 8, |
| 57 | labelFunc: function(value) { |
| 58 | return "$" + value + "M"; |
| 59 | } |
| 60 | }). |
| 61 | addAxis("y", {vertical: true, fixLower: "minor", fixUpper: "minor", natural: true,labels: [ |
| 62 | { value: 1, text: productList[0] }, |
| 63 | { value: 2, text: productList[1] }, |
| 64 | { value: 3, text: productList[2] }, |
| 65 | { value: 4, text: productList[3] }, |
| 66 | { value: 5, text: productList[4] }, |
| 67 | { value: 6, text: productList[5] } |
| 68 | ]}). |
| 69 | addPlot("default", { type: "ClusteredBars", gap: 5, animate:{duration: 1000}}). |
| 70 | addSeries("productSeries", productSeries, { stroke: { color: "gray" }, fill: "gray" }). |
| 71 | render(); |
| 72 | var map = new dojox.geo.charting.Map("map", "../resources/data/USStates.json"); |
| 73 | map.setMarkerData("../resources/markers/USStates.json"); |
| 74 | // install mouse/touch navigation |
| 75 | if (!isTouchDevice) { |
| 76 | var mouseInteraction = new dojox.geo.charting.MouseInteractionSupport(map,{enablePan:true,enableZoom:true}); |
| 77 | mouseInteraction.connect(); |
| 78 | } else { |
| 79 | var touchInteraction = new dojox.geo.charting.TouchInteractionSupport(map,{}); |
| 80 | touchInteraction.connect(); |
| 81 | } |
| 82 | var keyboardInteraction = new dojox.geo.charting.KeyboardInteractionSupport(map, {enableZoom: true}); |
| 83 | keyboardInteraction.connect(); |
| 84 | |
| 85 | map.onFeatureClick = function(feature){ |
| 86 | |
| 87 | if (!feature) { |
| 88 | productSeries = [0,0,0,0,0,0]; |
| 89 | chart.updateSeries("productSeries",productSeries); |
| 90 | chart.render(); |
| 91 | } else if (!feature.isSelected) { |
| 92 | chartStore.fetchItemByIdentity({ |
| 93 | identity: feature.id, |
| 94 | onItem: function(item){ |
| 95 | for (var i = productList.length - 1; i >= 0; i--){ |
| 96 | productSeries[i] = chartStore.getValue(item, productList[i]); |
| 97 | }; |
| 98 | chart.updateSeries("productSeries",productSeries); |
| 99 | chart.render(); |
| 100 | } |
| 101 | }); |
| 102 | } |
| 103 | }; |
| 104 | }); |
| 105 | </script> |
| 106 | </head> |
| 107 | <body class="tundra"> |
| 108 | <h1>Map connect with DataChart(Click on map)</h1> |
| 109 | <p>Keyboard Tips: Use <b>TAB</b> to focus the map, then use <b>up/down/left/right</b> to go around the map, zoom in by <b>SPACE</b> and zoom out by <b>ESC</b>.</p> |
| 110 | <div style="width:610px;height:400px;border:solid 1px;background:#f5f5f5;" id="map"> |
| 111 | </div> |
| 112 | <div id="chartDiv" style="width: 400px; height: 150px;"> |
| 113 | </div> |
| 114 | </body> |
| 115 | </html> |