Skip to content

Commit ff1acc2

Browse files
committed
Update the two_dataset demo to work with mean method
1 parent f466d48 commit ff1acc2

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

demo/two_datasets/main.js

+40-37
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,48 @@ var maxX = 50,
66
var noTestData = 1000;
77
var gridMarkers = {};
88

9-
document.addEventListener('DOMContentLoaded', function(event) {
10-
console.log('dom loaded');
9+
document.addEventListener("DOMContentLoaded", function (event) {
10+
console.log("dom loaded");
1111

12-
const randomDataCells = createRandomData('cells');
13-
const randomDataMarkers = createRandomData('markers');
12+
const randomDataCells = createRandomData("cells");
13+
const randomDataMarkers = createRandomData("markers");
1414

1515
// setting map
16-
map = L.map('map-content');
17-
map.fitBounds([[minY, minX], [maxY, maxX]]);
16+
map = L.map("map-content");
17+
map.fitBounds([
18+
[minY, minX],
19+
[maxY, maxX],
20+
]);
1821

19-
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
22+
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", {
2023
attribution:
2124
'&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
22-
opacity: 0.3
25+
opacity: 0.3,
2326
}).addTo(map);
2427

2528
gridMarkers = L.regularGridCluster({
2629
rules: {
2730
markers: {
2831
radius: {
29-
method: 'count',
30-
attribute: '',
31-
scale: 'continuous',
32-
range: [3, 10]
32+
method: "mean",
33+
attribute: "a",
34+
scale: "continuous",
35+
range: [-5, 10],
3336
},
34-
color: 'black'
37+
color: "black",
3538
},
3639
cells: {},
37-
texts: {}
40+
texts: {},
3841
},
3942
zoomShowElements: 10,
4043
zoomHideGrid: 9,
4144
zoneSize: 10000,
42-
gridMode: 'hexagon',
45+
gridMode: "hexagon",
4346
showCells: false,
4447
gridOrigin: { lat: 0, lng: 0 },
4548
showMarkers: true,
4649
showTexts: false,
47-
trackingTime: false
50+
trackingTime: false,
4851
});
4952

5053
gridMarkers.addLayers(randomDataMarkers);
@@ -54,55 +57,55 @@ document.addEventListener('DOMContentLoaded', function(event) {
5457
rules: {
5558
cells: {
5659
fillColor: {
57-
method: 'count',
58-
attribute: '',
59-
scale: 'continuous',
60-
range: ['yellow', 'red']
60+
method: "count",
61+
attribute: "",
62+
scale: "continuous",
63+
range: ["yellow", "red"],
6164
},
62-
color: 'black',
63-
fillOpacity: 0.6
65+
color: "black",
66+
fillOpacity: 0.6,
6467
},
6568
markers: {},
66-
texts: {}
69+
texts: {},
6770
},
6871
zoomShowElements: 10,
6972
zoomHideGrid: 9,
7073
zoneSize: 10000,
71-
gridMode: 'hexagon',
74+
gridMode: "hexagon",
7275
showCells: true,
7376
showEmptyCells: true,
7477
emptyCellOptions: {
7578
weight: 1,
7679
fillOpacity: 0,
7780
clickable: false,
78-
color: 'grey',
79-
lineJoin: 'miter',
80-
fillRule: 'evenodd',
81-
strokeLocation: 'inside',
82-
interactive: false
81+
color: "grey",
82+
lineJoin: "miter",
83+
fillRule: "evenodd",
84+
strokeLocation: "inside",
85+
interactive: false,
8386
},
8487
gridOrigin: { lat: 0, lng: 0 },
8588
gridEnd: { lat: 30, lng: 80 },
8689
showMarkers: false,
8790
showTexts: false,
88-
trackingTime: false
91+
trackingTime: false,
8992
});
9093

9194
gridCells.addLayers(randomDataCells);
9295
gridCells.addTo(map);
9396
});
9497

95-
const createRandomData = function(mode) {
98+
const createRandomData = function (mode) {
9699
// random point data
97100
const randomData = [];
98101
const x = minX;
99102
for (let i = 0; i < noTestData; i++) {
100103
const coordinates = [
101104
x + Math.random() * (maxX - x),
102-
minY + Math.random() * (maxY - minY)
105+
minY + Math.random() * (maxY - minY),
103106
];
104107
const properties = {
105-
a: Math.floor(Math.random() * 5)
108+
a: Math.floor(Math.random() * 5),
106109
};
107110

108111
const marker = L.circleMarker(coordinates, circleStyle(properties, mode));
@@ -111,13 +114,13 @@ const createRandomData = function(mode) {
111114
return randomData;
112115
};
113116

114-
const circleStyle = function(props, mode) {
115-
const fillColor = mode === 'cells' ? 'red' : 'black';
117+
const circleStyle = function (props, mode) {
118+
const fillColor = mode === "cells" ? "red" : "black";
116119
return {
117120
fillColor: fillColor,
118-
color: 'black',
121+
color: "black",
119122
weight: 1,
120123
radius: props.a / 2,
121-
fillOpacity: 0.5
124+
fillOpacity: 0.5,
122125
};
123126
};

0 commit comments

Comments
 (0)