Skip to content

Commit 1f012f0

Browse files
Merging and regenerating dist
2 parents 336e20f + 7dadb30 commit 1f012f0

File tree

7 files changed

+124
-51
lines changed

7 files changed

+124
-51
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777

7878
- Fixes some coordinates in the country location data.
7979
- Last Geohash as center for the map - it centers the map on the last geohash position received. Useful for real time tracking (with auto refresh on in Grafana).
80+
81+
## v0.0.19
82+
83+
Fix for Elasticsearch geohash maps after breaking change in Grafana 4.5.

dist/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@
7777

7878
- Fixes some coordinates in the country location data.
7979
- Last Geohash as center for the map - it centers the map on the last geohash position received. Useful for real time tracking (with auto refresh on in Grafana).
80+
81+
## v0.0.19
82+
83+
Fix for Elasticsearch geohash maps after breaking change in Grafana 4.5.

dist/data_formatter.js

Lines changed: 56 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/data_formatter.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
{"name": "USA", "path": "images/worldmap-usa.png"},
2424
{"name": "Light Theme", "path": "images/worldmap-light-theme.png"}
2525
],
26-
"version": "0.0.18",
27-
"updated": "2017-10-10"
26+
"version": "0.0.19",
27+
"updated": "2017-10-11"
2828
},
2929

3030
"dependencies": {

src/data_formatter.js

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,69 @@ export default class DataFormatter {
4646
}
4747
}
4848

49+
createDataValue(encodedGeohash, decodedGeohash, locationName, value, highestValue, lowestValue) {
50+
const dataValue = {
51+
key: encodedGeohash,
52+
locationName: locationName,
53+
locationLatitude: decodedGeohash.latitude,
54+
locationLongitude: decodedGeohash.longitude,
55+
value: value,
56+
valueFormatted: value,
57+
valueRounded: 0
58+
};
59+
60+
dataValue.valueRounded = this.kbn.roundValue(dataValue.value, this.ctrl.panel.decimals || 0);
61+
return dataValue;
62+
}
63+
4964
setGeohashValues(dataList, data) {
5065
if (!this.ctrl.panel.esGeoPoint || !this.ctrl.panel.esMetric) return;
5166

5267
if (dataList && dataList.length > 0) {
5368
let highestValue = 0;
5469
let lowestValue = Number.MAX_VALUE;
5570

56-
dataList[0].datapoints.forEach((datapoint) => {
57-
const encodedGeohash = datapoint[this.ctrl.panel.esGeoPoint];
58-
const decodedGeohash = decodeGeoHash(encodedGeohash);
59-
60-
const dataValue = {
61-
key: encodedGeohash,
62-
locationName: this.ctrl.panel.esLocationName ? datapoint[this.ctrl.panel.esLocationName] : encodedGeohash,
63-
locationLatitude: decodedGeohash.latitude,
64-
locationLongitude: decodedGeohash.longitude,
65-
value: datapoint[this.ctrl.panel.esMetric],
66-
valueFormatted: datapoint[this.ctrl.panel.esMetric],
67-
valueRounded: 0
68-
};
69-
70-
if (dataValue.value > highestValue) highestValue = dataValue.value;
71-
if (dataValue.value < lowestValue) lowestValue = dataValue.value;
72-
73-
dataValue.valueRounded = this.kbn.roundValue(dataValue.value, this.ctrl.panel.decimals || 0);
74-
data.push(dataValue);
71+
dataList.forEach((result) => {
72+
if (result.type === 'table') {
73+
const columnNames = {};
74+
75+
result.columns.forEach((column, columnIndex) => {
76+
columnNames[column.text] = columnIndex;
77+
});
78+
79+
result.rows.forEach((row) => {
80+
const encodedGeohash = row[columnNames[this.ctrl.panel.esGeoPoint]];
81+
const decodedGeohash = decodeGeoHash(encodedGeohash);
82+
const locationName = this.ctrl.panel.esLocationName ? row[columnNames[this.ctrl.panel.esLocationName]] : encodedGeohash;
83+
const value = row[columnNames[this.ctrl.panel.esMetric]];
84+
85+
const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value, highestValue, lowestValue);
86+
if (dataValue.value > highestValue) highestValue = dataValue.value;
87+
if (dataValue.value < lowestValue) lowestValue = dataValue.value;
88+
data.push(dataValue);
89+
});
90+
91+
data.highestValue = highestValue;
92+
data.lowestValue = lowestValue;
93+
data.valueRange = highestValue - lowestValue;
94+
} else {
95+
result.forEach((datapoint) => {
96+
const encodedGeohash = datapoint[this.ctrl.panel.esGeoPoint];
97+
const decodedGeohash = decodeGeoHash(encodedGeohash);
98+
const locationName = this.ctrl.panel.esLocationName ? datapoint[this.ctrl.panel.esLocationName] : encodedGeohash;
99+
const value = datapoint[this.ctrl.panel.esMetric];
100+
101+
const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value, highestValue, lowestValue);
102+
if (dataValue.value > highestValue) highestValue = dataValue.value;
103+
if (dataValue.value < lowestValue) lowestValue = dataValue.value;
104+
data.push(dataValue);
105+
});
106+
107+
data.highestValue = highestValue;
108+
data.lowestValue = lowestValue;
109+
data.valueRange = highestValue - lowestValue;
110+
}
75111
});
76-
77-
data.highestValue = highestValue;
78-
data.lowestValue = lowestValue;
79-
data.valueRange = highestValue - lowestValue;
80112
}
81113
}
82114

src/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
{"name": "USA", "path": "images/worldmap-usa.png"},
2424
{"name": "Light Theme", "path": "images/worldmap-light-theme.png"}
2525
],
26-
"version": "0.0.18",
27-
"updated": "2017-10-10"
26+
"version": "0.0.19",
27+
"updated": "2017-10-11"
2828
},
2929

3030
"dependencies": {

0 commit comments

Comments
 (0)