diff --git a/.gitignore b/.gitignore index d5a2735..3bf23f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -node_modules +node_modules* npm-debug.log .DS_Store .vscode @@ -10,4 +10,4 @@ artifacts/ .venv* bin/ -build/ +build/ \ No newline at end of file diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..abc26f9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +10.24.1 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 438d233..7fb4fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## Entries +## v1.0.2 +- Added filtering by minimum value and color as second metric + ## v1.0.1 - Release for Grafana 7.0 with plugin signing diff --git a/README.md b/README.md index 8a0a44a..c42af0b 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,10 @@ This is minimum size for a circle in pixels. This is the maximum size for a circle in pixels. Depending on the zoom level you might want a larger or smaller max circle size to avoid overlapping. +**Min Value** + +This is the minimum value to show a circle. If provided, data points with values lower than this minimum value won't be shown at the map. + **Unit** The Unit is shown in the popover when you hover over a circle. There are two fields the singular form and the plural form. E.g. visit/visits or error/errors @@ -269,7 +273,15 @@ The Unit is shown in the popover when you hover over a circle. There are two fie Shows/hide the legend on the bottom left that shows the threshold ranges and their associated colors. -### Threshold Options +### Coloring Options + +The coloring options allows the use of the circle colors with a second metric. In case of a single metric, leave the Color metric field empty and the same value will be used for circle size and color. + +Using the field color metric will enable the color to read from this second metric and generate thresholds based on this number. + +The Color label is used on the tooltip, showing a "Label: Value Unit" as a second line on the map's tooltip, together with the Color unit field. + +The Color value decimals limits the decimal cases from the color metric on the map's tooltip. Thresholds control the color of the circles. @@ -277,6 +289,7 @@ If one value is specified then two colors are used. For example, if the threshol The threshold field also accepts 2 or more comma-separated values. For example, if you have 2 values that represents 3 ranges that correspond to the three colors. For example: if the thresholds are 70, 90 then the first color represents < 70, the second color represents between 70 and 90 and the third color represents > 90. + ### CHANGELOG The latest changes can be found here: [CHANGELOG.md](https://github.com/grafana/worldmap-panel/blob/master/CHANGELOG.md) diff --git a/package.json b/package.json index d5cc8fe..5997fc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "worldmap-panel", - "version": "1.0.1", + "version": "1.0.2", "description": "Worldmap Panel Plugin for Grafana", "main": "src/module.js", "scripts": { diff --git a/src/data_formatter.ts b/src/data_formatter.ts index 13121f0..9880b49 100644 --- a/src/data_formatter.ts +++ b/src/data_formatter.ts @@ -53,8 +53,9 @@ export default class DataFormatter { } } - createDataValue(encodedGeohash, decodedGeohash, locationName, value) { + createDataValue(encodedGeohash, decodedGeohash, locationName, value, colorValue) { const dataValue = { + colorValue: colorValue, key: encodedGeohash, locationName: locationName, locationLatitude: decodedGeohash.latitude, @@ -65,6 +66,7 @@ export default class DataFormatter { }; dataValue.valueRounded = kbn.roundValue(dataValue.value, this.ctrl.panel.decimals || 0); + dataValue.colorValue = kbn.roundValue(dataValue.colorValue, this.ctrl.panel.colorDecimals || 0); return dataValue; } @@ -92,8 +94,8 @@ export default class DataFormatter { ? row[columnNames[this.ctrl.panel.esLocationName]] : encodedGeohash; const value = row[columnNames[this.ctrl.panel.esMetric]]; - - const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value); + const colorValue = row[columnNames[this.ctrl.panel.colorMetric]]; + const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value, colorValue); if (dataValue.value > highestValue) { highestValue = dataValue.value; } @@ -116,8 +118,8 @@ export default class DataFormatter { ? datapoint[this.ctrl.panel.esLocationName] : encodedGeohash; const value = datapoint[this.ctrl.panel.esMetric]; - - const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value); + const colorValue = datapoint[this.ctrl.panel.colorMetric]; + const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value, colorValue); if (dataValue.value > highestValue) { highestValue = dataValue.value; } diff --git a/src/partials/editor.html b/src/partials/editor.html index 63c474e..dc385e9 100644 --- a/src/partials/editor.html +++ b/src/partials/editor.html @@ -29,6 +29,11 @@