Skip to content

Commit

Permalink
Merge 2aba68b into 0779944
Browse files Browse the repository at this point in the history
  • Loading branch information
1chandu committed Sep 27, 2019
2 parents 0779944 + 2aba68b commit e063e12
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
3 changes: 2 additions & 1 deletion website/package.json
Expand Up @@ -40,7 +40,8 @@
"styletron-engine-atomic": "^1.4.0",
"styletron-react": "^5.2.0",
"supercluster": "^6.0.1",
"tagmap.js": "^1.1.1"
"tagmap.js": "^1.1.1",
"bowser": "^2.6.1"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand Down
56 changes: 37 additions & 19 deletions website/src/components/demos/heatmap-demo.js
@@ -1,4 +1,6 @@
/* global window */
import React, {Component} from 'react';
import Bowser from 'bowser';
import {readableInteger} from '../../utils/format-utils';
import {MAPBOX_STYLES, DATA_URI} from '../../constants/defaults';
import {App} from 'website-examples/heatmap/app';
Expand All @@ -12,27 +14,32 @@ export default class HeatmapDemo extends Component {
}

static get parameters() {
return {
const parameters = {
radius: {displayName: 'Radius', type: 'range', value: 5, step: 1, min: 1, max: 50},
intensity: {displayName: 'Intensity', type: 'range', value: 1, step: 0.1, min: 0, max: 5},
threshold: {displayName: 'Threshold', type: 'range', value: 0.03, step: 0.01, min: 0, max: 1},
minWeight: {
displayName: 'Minimum Weight',
type: 'range',
value: 0,
step: 10,
min: 0,
max: 50000
},
maxWeight: {
displayName: 'Maximum Weight',
type: 'range',
value: 0,
step: 10,
min: 0,
max: 50000
}
threshold: {displayName: 'Threshold', type: 'range', value: 0.03, step: 0.01, min: 0, max: 1}
};
if (shouldEnableColorDomain()) {
Object.assign(parameters, {
minWeight: {
displayName: 'Minimum Weight',
type: 'range',
value: 0,
step: 10,
min: 0,
max: 50000
},
maxWeight: {
displayName: 'Maximum Weight',
type: 'range',
value: 0,
step: 10,
min: 0,
max: 50000
}
});
}
return parameters;
}

static get mapStyle() {
Expand Down Expand Up @@ -70,7 +77,10 @@ export default class HeatmapDemo extends Component {
const radiusPixels = params.radius.value;
const intensity = params.intensity.value;
const threshold = params.threshold.value;
const colorDomain = [params.minWeight.value, params.maxWeight.value];
const colorDomain = [
params.minWeight ? params.minWeight.value : 0,
params.maxWeight ? params.maxWeight.value : 0
];

return (
<App
Expand All @@ -84,3 +94,11 @@ export default class HeatmapDemo extends Component {
);
}
}

// HELPER
function shouldEnableColorDomain() {
const OS_NAMES_TO_DETECT = ['windows', 'ios'];
const browser = Bowser.getParser(window.navigator.userAgent);
const currentOS = browser.getOSName(true);
return OS_NAMES_TO_DETECT.indexOf(currentOS) !== -1;
}

0 comments on commit e063e12

Please sign in to comment.