Permalink
Browse files

#90 #92 Added ability to set values directly with dataSeries

  • Loading branch information...
1 parent 5e3591f commit 4510d48889ffe06bfb02287b49eeabe7b1b71886 @bjornd committed Sep 28, 2012
Showing with 23 additions and 6 deletions.
  1. +1 −0 build.sh
  2. +6 −5 lib/data-series.js
  3. +7 −0 lib/simple-scale.js
  4. +1 −1 lib/world-map.js
  5. +2 −0 tests/index.html
  6. +6 −0 tests/markers.html
View
@@ -20,6 +20,7 @@ files=( \
lib/vml-path-element.js \
lib/vml-circle-element.js \
lib/vector-canvas.js \
+ lib/simple-scale.js \
lib/ordinal-scale.js \
lib/numeric-scale.js \
lib/color-scale.js \
View
@@ -14,7 +14,6 @@ jvm.DataSeries = function(params, elements) {
params = params || {};
params.attribute = params.attribute || 'fill';
- params.scale = params.scale || ['#C8EEFF', '#0071A4'];
this.elements = elements;
this.params = params;
@@ -23,11 +22,13 @@ jvm.DataSeries = function(params, elements) {
this.setAttributes(params.attributes);
}
- if (!jvm.$.isArray(params.scale)) {
- this.scale = new jvm.OrdinalScale(params.scale);
- } else {
+ if (jvm.$.isArray(params.scale)) {
scaleConstructor = (params.attribute === 'fill' || params.attribute === 'stroke') ? jvm.ColorScale : jvm.NumericScale;
this.scale = new scaleConstructor(params.scale, params.normalizeFunction, params.min, params.max);
+ } else if (params.scale) {
+ this.scale = new jvm.OrdinalScale(params.scale);
+ } else {
+ this.scale = new jvm.SimpleScale(params.scale);
}
if (params.values) {
@@ -63,7 +64,7 @@ jvm.DataSeries.prototype = {
cc,
attrs = {};
- if (!(this.scale instanceof jvm.OrdinalScale)) {
+ if (!(this.scale instanceof jvm.OrdinalScale) && !(this.scale instanceof jvm.SimpleScale)) {
if (!this.params.min || !this.params.max) {
for (cc in values) {
val = parseFloat(values[cc]);
View
@@ -0,0 +1,7 @@
+jvm.SimpleScale = function(scale){
+ this.scale = scale;
+};
+
+jvm.SimpleScale.prototype.getValue = function(value){
+ return value;
+};
View
@@ -351,6 +351,7 @@ jvm.WorldMap.prototype = {
mouseMoved = true;
});
+ //http://bugs.jquery.com/ticket/10791
this.container.delegate('.jvectormap-element', 'mouseover mouseout', function(e){
var path = this,
type = jvm.$(this).attr('class').indexOf('jvectormap-region') === -1 ? 'marker' : 'region',
@@ -468,7 +469,6 @@ jvm.WorldMap.prototype = {
this.scale = scale;
this.applyTransform();
- console.log(this.baseScale);
this.container.trigger(viewportChangeEvent, [scale/this.baseScale]);
},
View
@@ -28,6 +28,7 @@
<script src="../lib/vml-circle-element.js"></script>
<script src="../lib/vector-canvas.js"></script>
+ <script src="../lib/simple-scale.js"></script>
<script src="../lib/numeric-scale.js"></script>
<script src="../lib/ordinal-scale.js"></script>
<script src="../lib/color-scale.js"></script>
@@ -53,6 +54,7 @@
},
series: {
regions: [{
+ scale: ['#C8EEFF', '#0071A4'],
normalizeFunction: 'polynomial',
values: {
"AF": 16.63,
View
@@ -36,6 +36,7 @@
<script src="../lib/vml-circle-element.js"></script>
<script src="../lib/vector-canvas.js"></script>
+ <script src="../lib/simple-scale.js"></script>
<script src="../lib/ordinal-scale.js"></script>
<script src="../lib/numeric-scale.js"></script>
<script src="../lib/color-scale.js"></script>
@@ -84,6 +85,11 @@
"US-IA": 'blue',
"US-NE": 'blue'
}
+ },{
+ values: {
+ "US-NY": '#000000'
+ },
+ attribute: 'fill'
}]
},
regionsSelectable: true,

0 comments on commit 4510d48

Please sign in to comment.