Bug: Crash if invalid region code is specified. #88

Closed
Digicrat opened this Issue Sep 13, 2012 · 0 comments

Comments

Projects
None yet
2 participants

I am dynamically setting the region color values based on values in a database - and unfortunately the country names in that database are not a 100% match to those the world map and this has resulted in a few exceptions.

A fix is below for jvm.DataSeries.prototype.setValues.

     for (cc in values) {
-      val = parseFloat(values[cc]);
-      if (val) {
-        attrs[cc] = this.scale.getValue(val);
+      if (this.elements[cc]) {
+          val = parseFloat(values[cc]);
+          if (val) {
+              attrs[cc] = this.scale.getValue(val);
+          } else {
+              attrs[cc] = this.elements[cc].element.style.initial[this.params.attribute];
+          }
       } else {
-        attrs[cc] = this.elements[cc].element.style.initial[this.params.attribute];
+          console.log("WARNING: Attempt to set region value for " + cc + ", which does not exist!");
       }
     }
     this.setAttributes(attrs);

bjornd closed this in a0a7330 Oct 1, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment