summaryrefslogtreecommitdiff
path: root/js/dojo/dojox/geo/charting/widget
diff options
context:
space:
mode:
Diffstat (limited to 'js/dojo/dojox/geo/charting/widget')
-rw-r--r--js/dojo/dojox/geo/charting/widget/Legend.js93
-rw-r--r--js/dojo/dojox/geo/charting/widget/Map.js182
2 files changed, 275 insertions, 0 deletions
diff --git a/js/dojo/dojox/geo/charting/widget/Legend.js b/js/dojo/dojox/geo/charting/widget/Legend.js
new file mode 100644
index 0000000..f307d77
--- /dev/null
+++ b/js/dojo/dojox/geo/charting/widget/Legend.js
@@ -0,0 +1,93 @@
+//>>built
+
+define("dojox/geo/charting/widget/Legend", ["dojo/_base/kernel", "dojo/_base/lang","dojo/_base/array", "dojo/_base/declare","dojo/_base/html","dojo/dom",
+ "dojo/dom-construct","dojo/dom-class", "dojo/_base/window", "dijit/_Widget"],
+ function(dojo, lang, arr, declare, html,dom,domConstruct,domClass, win, Widget) {
+
+return declare("dojox.geo.charting.widget.Legend",Widget, {
+ // summary:
+ // A legend widget displaying association between colors and Feature value ranges.
+ //
+ // description:
+ // This widget basically is a table comprising (icon,string) pairs, describing the color scheme
+ // used for the map and its associated text descriptions.
+ //
+
+ // example:
+ // | var legend = new dojox.geo.charting.widget.Legend({
+ // | map: map
+ // | });
+ horizontal:true,
+ legendBody:null,
+ swatchSize:18,
+ map:null,
+ postCreate: function(){
+ // summary:
+ // inherited Dijit's postCreate function
+ // tags:
+ // protected
+ if(!this.map){return;}
+ this.series = this.map.series;
+ if (!this.domNode.parentNode) {
+ // compatibility with older version : add to map domNode if not already attached to a parentNode.
+ dom.byId(this.map.container).appendChild(this.domNode);
+ }
+ this.refresh();
+ },
+ buildRendering: function(){
+ // summary:
+ // Construct the UI for this widget, creates the underlying real dojox.geo.charting.Map object.
+ // tags:
+ // protected
+ this.domNode = domConstruct.create("table",
+ {role: "group", "class": "dojoxLegendNode"});
+ this.legendBody = domConstruct.create("tbody", null, this.domNode);
+ this.inherited(arguments);
+ },
+
+ refresh:function(){
+ // summary:
+ // Refreshes this legend contents when Map series has changed.
+ // cleanup
+ while(this.legendBody.lastChild){
+ domConstruct.destroy(this.legendBody.lastChild);
+ }
+
+ if(this.horizontal){
+ domClass.add(this.domNode,"dojoxLegendHorizontal");
+ this._tr = win.doc.createElement("tr");
+ this.legendBody.appendChild(this._tr);
+ }
+
+ var s = this.series;
+ if(s.length == 0){return;}
+
+ arr.forEach(s,function(x){
+ this._addLabel(x.color, x.name);
+ },this);
+ },
+ _addLabel:function(color,label){
+ var icon = win.doc.createElement("td");
+ var text = win.doc.createElement("td");
+ var div = win.doc.createElement("div");
+ domClass.add(icon, "dojoxLegendIcon");
+ domClass.add(text, "dojoxLegendText");
+ div.style.width = this.swatchSize + "px";
+ div.style.height = this.swatchSize + "px";
+ icon.appendChild(div);
+
+ if(this.horizontal){
+ this._tr.appendChild(icon);
+ this._tr.appendChild(text);
+ }else{
+ var tr = win.doc.createElement("tr");
+ this.legendBody.appendChild(tr);
+ tr.appendChild(icon);
+ tr.appendChild(text);
+ }
+
+ div.style.background = color;
+ text.innerHTML = String(label);
+ }
+});
+});
diff --git a/js/dojo/dojox/geo/charting/widget/Map.js b/js/dojo/dojox/geo/charting/widget/Map.js
new file mode 100644
index 0000000..dc28e7d
--- /dev/null
+++ b/js/dojo/dojox/geo/charting/widget/Map.js
@@ -0,0 +1,182 @@
+//>>built
+
+define("dojox/geo/charting/widget/Map", ["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/declare","dojo/_base/html","dojo/dom-geometry",
+ "dijit/_Widget","dojox/geo/charting/Map"],
+ function(dojo, lang, declare, html,domGeom, Widget, Map) {
+
+return declare("dojox.geo.charting.widget.Map", Widget, {
+ // summary:
+ // A map viewer widget based on the dojox.geo.charting.Map component
+ //
+ // description:
+ // The `dojox.geo.charting.widget.Map` widget combines map display together with charting capabilities.
+ // It encapsulates an `dojox.geo.charting.Map` object on which most operations are delegated.
+ // Parameters can be passed as argument at construction time to specify map data file (json shape format)
+ // as well as charting data.
+ //
+ // The parameters are :
+ //
+ // * `shapeData`: The json object containing map data or the name of the file containing map data.
+ // * `dataStore`: the dataStore to fetch the charting data from
+ // * `dataBindingAttribute`: property name of the dataStore items to use as value for charting
+ // * `markerData`: tooltips to display for map features, handled as json style.
+ // * `adjustMapCenterOnResize`: if true, the center of the map remains the same when resizing the widget
+ // * `adjustMapScaleOnResize`: if true, the map scale is adjusted to leave the visible portion of the map identical as much as possible
+ //
+ // example:
+ //
+ // | var map = new dojox.geo.charting.widget.Map({
+ // | shapeData : 'map.json',
+ // | adjustMapCenterOnresize : true,
+ // | adjustMapScaleOnresize : true,
+ // | });
+
+ shapeData : "",
+ dataStore : null,
+ dataBindingAttribute : "",
+ dataBindingValueFunction: null,
+ markerData : "",
+ series : "",
+ adjustMapCenterOnResize: null,
+ adjustMapScaleOnResize: null,
+ animateOnResize: null,
+ onFeatureClick: null,
+ onFeatureOver: null,
+ enableMouseSupport: null,
+ enableTouchSupport: null,
+ enableMouseZoom: null,
+ enableMousePan: null,
+ enableKeyboardSupport: false,
+ showTooltips: false,
+ enableFeatureZoom: null,
+ colorAnimationDuration: 0,
+ mouseClickThreshold: 2,
+ _mouseInteractionSupport:null,
+ _touchInteractionSupport:null,
+ _keyboardInteractionSupport:null,
+ constructor : function(/* Object */options, /* HtmlNode */div){
+ // summary:
+ // Constructs a new Map widget
+ this.map = null;
+ },
+
+ startup : function(){
+ this.inherited(arguments);
+ if (this.map) {
+ this.map.fitToMapContents();
+ }
+
+ },
+
+ postMixInProperties : function(){
+ this.inherited(arguments);
+ },
+
+ create : function(/*Object?*/params, /*DomNode|String?*/srcNodeRef){
+ this.inherited(arguments);
+ },
+
+ getInnerMap: function() {
+ return this.map;
+ },
+
+
+ buildRendering : function(){
+ // summary:
+ // Construct the UI for this widget, creates the underlying real dojox.geo.charting.Map object.
+ // tags:
+ // protected
+ this.inherited(arguments);
+ if (this.shapeData) {
+ this.map = new Map(this.domNode, this.shapeData);
+ if (this.markerData && (this.markerData.length > 0))
+ this.map.setMarkerData(this.markerData);
+
+ if (this.dataStore) {
+ if (this.dataBindingValueFunction) {
+ this.map.setDataBindingValueFunction(this.dataBindingValueFunction);
+ }
+ this.map.setDataStore(this.dataStore,this.dataBindingAttribute);
+ }
+
+ if (this.series && (this.series.length > 0)) {
+ this.map.addSeries(this.series);
+ }
+
+ if (this.onFeatureClick) {
+ this.map.onFeatureClick = this.onFeatureClick;
+ }
+ if (this.onFeatureOver) {
+ this.map.onFeatureOver = this.onFeatureOver;
+ }
+ if (this.enableMouseSupport) {
+
+ if (!dojox.geo.charting.MouseInteractionSupport) {
+ throw Error("Can't find dojox.geo.charting.MouseInteractionSupport. Didn't you forget to dojo" + ".require() it?");
+ }
+ var options = {};
+ options.enablePan = this.enableMousePan;
+ options.enableZoom = this.enableMouseZoom;
+ options.mouseClickThreshold = this.mouseClickThreshold;
+ this._mouseInteractionSupport = new dojox.geo.charting.MouseInteractionSupport(this.map,options);
+ this._mouseInteractionSupport.connect();
+ }
+
+ if (this.enableTouchSupport) {
+ if (!dojox.geo.charting.TouchInteractionSupport) {
+ throw Error("Can't find dojox.geo.charting.TouchInteractionSupport. Didn't you forget to dojo" + ".require() it?");
+ }
+ this._touchInteractionSupport = new dojox.geo.charting.TouchInteractionSupport(this.map,{});
+ this._touchInteractionSupport.connect();
+ }
+ if (this.enableKeyboardSupport) {
+ if (!dojox.geo.charting.KeyboardInteractionSupport) {
+ throw Error("Can't find dojox.geo.charting.KeyboardInteractionSupport. Didn't you forget to dojo" + ".require() it?");
+ }
+ this._keyboardInteractionSupport = new dojox.geo.charting.KeyboardInteractionSupport(this.map,{});
+ this._keyboardInteractionSupport.connect();
+ }
+ this.map.showTooltips = this.showTooltips;
+ this.map.enableFeatureZoom = this.enableFeatureZoom;
+ this.map.colorAnimationDuration = this.colorAnimationDuration;
+
+
+ }
+ },
+
+
+ resize : function(b){
+ // summary:
+ // Resize the widget.
+ // description:
+ // Resize the domNode and the widget to the dimensions of a box of the following form:
+ // `{ l: 50, t: 200, w: 300: h: 150 }`
+ // box:
+ // If passed, denotes the new size of the widget.
+
+ var box;
+ switch (arguments.length) {
+ case 0:
+ // case 0, do not resize the div, just the surface
+ break;
+ case 1:
+ // argument, override node box
+ box = lang.mixin({}, b);
+ domGeom.getMarginBox(this.domNode, box);
+ break;
+ case 2:
+ // two argument, width, height
+ box = {
+ w : arguments[0],
+ h : arguments[1]
+ };
+ domGeom.getMarginBox(this.domNode, box);
+ break;
+ }
+
+ if (this.map) {
+ this.map.resize(this.adjustMapCenterOnResize,this.adjustMapScaleOnResize,this.animateOnResize);
+ }
+ }
+});
+});