Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Hierarchical and Array of Keys #106

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a7027a4
adds missing dev dependencies
daniellee Feb 21, 2019
5aa8c3b
tweak for incorrect height on render
daniellee Feb 21, 2019
5f71ecd
release 0.2.0
daniellee Feb 21, 2019
35428bf
remove dist
ryantxu Aug 29, 2019
8a5d4bc
Chore: Remove dist from master (#215)
ryantxu Aug 29, 2019
f652100
Add error handling to onDataRecevied, fixes #213
torkelo Aug 29, 2019
aef156b
Updated changlog
torkelo Aug 29, 2019
734ea74
Merge remote-tracking branch 'origin/master' into delay-first-render
torkelo Aug 29, 2019
95f8956
Merge pull request #216 from grafana/delay-first-render
torkelo Aug 29, 2019
e401b69
remove dist again
ryantxu Aug 29, 2019
c776ba4
Merge pull request #217 from grafana/remove-dist-again
ryantxu Aug 29, 2019
8df45a5
Release with signing for Grafana 7.x (prep)
srclosson May 15, 2020
4878487
update build sans toolkit
srclosson May 15, 2020
dc281fa
updated to add toolkit for packaging and signing
srclosson May 15, 2020
b16ffc7
update build process
srclosson May 15, 2020
4e864e1
update ci 2
srclosson May 15, 2020
4c14233
ci update 3
srclosson May 15, 2020
547fd44
ci update 4
srclosson May 15, 2020
39b7cea
ci config 5
srclosson May 15, 2020
d0df25e
ci config 6
srclosson May 15, 2020
ddfc35f
ci update 7
srclosson May 15, 2020
80cf86e
ci update 8
srclosson May 15, 2020
fce638b
ci update 9
srclosson May 15, 2020
8c46939
ci update 10
srclosson May 15, 2020
5beb89b
ci update 11
srclosson May 15, 2020
2489338
ci update 12
srclosson May 15, 2020
af91128
ci update 13
srclosson May 15, 2020
9b9d7a5
Updated plugin.json
srclosson May 15, 2020
a61dee9
ci update infinity
srclosson May 15, 2020
bd11307
why do you ask
srclosson May 15, 2020
ed62bf9
tweaking
srclosson May 15, 2020
3751fa7
tweaking
srclosson May 15, 2020
06b3674
updated plugin.json
srclosson May 15, 2020
45ec6c3
Merge pull request #265 from grafana/v1.0.x
srclosson May 15, 2020
75b491d
force forground color for light theme
srclosson Feb 18, 2021
2b3b163
Merge pull request #300 from grafana/src/fix-light-theme-background
srclosson Feb 18, 2021
0b855d6
Update data_formatter.ts
nibinqtl May 7, 2021
a2f314d
Update data_formatter.ts
nibinqtl May 7, 2021
5a2cd47
Revert "Update data_formatter.ts"
nibinqtl May 7, 2021
493b1a0
Update data_formatter.ts
nibinqtl May 7, 2021
e0f028b
support known location and multiple keys in loc data
May 7, 2021
7b49df6
added new location data file
nibinqtl May 7, 2021
b43388a
support new location data file
nibinqtl May 7, 2021
d5a3fca
move the location of china
nibinqtl May 7, 2021
cc85ee3
added US states
nibinqtl May 7, 2021
e49ff8c
Circle area, instead of radius to be linear in data value
nibinqtl May 8, 2021
439b345
fixed unit test
nibinqtl May 8, 2021
0059315
Update worldmap.ts
nibinqtl May 8, 2021
b9dcf83
updated plugin info
nibinqtl May 10, 2021
391b1d8
updated readme
nibinqtl May 10, 2021
30e87af
more updates to readme
nibinqtl May 10, 2021
a9cd1ff
Update CHANGELOG.md
nibinqtl May 10, 2021
89f744f
more updates to readme
nibinqtl May 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 154 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,155 @@
version: 2 # use CircleCI 2.0
version: 2.1

jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
working_directory: ~/worldmap-panel # directory where steps will run
docker: # run the steps with Docker
- image: circleci/node:latest
steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Dependencies
command: yarn install --frozen-lockfile
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run: # run tests
name: test
command: yarn test
parameters:
ssh-fingerprint:
type: string
default: ${GITHUB_SSH_FINGERPRINT}

aliases:
# Workflow filters
- &filter-only-master
branches:
only: master
- &filter-only-release
branches:
only: /^v[1-9]*[0-9]+\.[1-9]*[0-9]+\.x$/

workflows:
plugin_workflow:
jobs:
- build
- report:
requires:
- build
- approve_release:
type: approval
requires:
- report
filters: *filter-only-release
- publish_github_release:
requires:
- approve_release
filters: *filter-only-release

executors:
default_exec: # declares a reusable executor
docker:
- image: srclosson/grafana-plugin-ci-alpine:latest
e2e_exec:
docker:
- image: srclosson/grafana-plugin-ci-e2e:latest

jobs:
build:
executor: default_exec
steps:
- checkout
- restore_cache:
name: restore node_modules
keys:
- build-cache-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
- run:
name: Install dependencies
command: |
mkdir ci
[ -f ~/project/node_modules/.bin/grafana-toolkit ] || yarn install --frozen-lockfile
- save_cache:
name: save node_modules
paths:
- ~/project/node_modules
key: build-cache-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
- save_cache:
name: save cypress cache
paths:
- ~/.cache/Cypress
key: cypress-cache-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
- run:
name: Build and test panel
command: |
sed -e "s/%VERSION%/$(cat package.json | jq .version | tr -d '\"')/" -e "s/%TODAY%/$(date)/" ./src/plugin.json.tmpl > ./src/plugin.json
yarn build
- run:
name: Move results to ci folder
command: |
# Update the plugin.json with up to date info
mkdir -pv ci/job/build_plugin
mkdir -pv ci/packages
mkdir -pv ci/jobs/package
mkdir -pv ci/grafana-test-env
cp -rv dist ci/job/build_plugin
- run:
name: Package distribution
command: |
./node_modules/.bin/grafana-toolkit plugin:ci-package
- persist_to_workspace:
root: .
paths:
- ci/jobs/package
- ci/packages
- ci/dist
- ci/grafana-test-env
- store_artifacts:
path: ci

report:
executor: default_exec
steps:
- checkout
- attach_workspace:
at: .
- restore_cache:
name: restore node_modules
keys:
- build-cache-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
- run:
name: Toolkit report
command: |
./node_modules/.bin/grafana-toolkit plugin:ci-report
- store_artifacts:
path: ci

publish_github_release:
executor: default_exec
steps:
- checkout
- add_ssh_keys:
fingerprints:
- "${GITHUB_SSH_FINGERPRINT}"
- attach_workspace:
at: .
- restore_cache:
name: restore node_modules
keys:
- build-cache-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
- run:
name: "Publish Release on GitHub"
command: |
wget "https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz"
tar zxvf "./ghr_v0.13.0_linux_amd64.tar.gz" -C /usr/local
/bin/rm -rf "./ghr_v0.13.0_linux_amd64.tar.gz"
mkdir -pv dist
mkdir -pv artifacts
cp -r ci/dist/grafana-worldmap-panel/* dist/
cp -r ci/packages/* artifacts/
DATASOURCE_NAME=grafana-worldmap-panel
RELEASE_NOTES=`awk 'BEGIN {FS="##"; RS=""} FNR==4 {print; exit}' CHANGELOG.md`
VERSION=`cat ci/dist/plugin.json|jq '.info.version'| sed s/\"//g`
git config user.email "eng@grafana.com"
git config user.name "CircleCI Automation"
git checkout -b release-${VERSION}
git add --force dist/
git add --force artifacts/
git commit -m "automated release $VERSION [skip ci]"
git push -f origin release-${VERSION}
git tag -f v${VERSION}
git push -f origin v${VERSION}
/usr/local/ghr_v0.13.0_linux_amd64/ghr \
-t ${GITHUB_TOKEN} \
-u ${CIRCLE_PROJECT_USERNAME} \
-r ${CIRCLE_PROJECT_REPONAME} \
-c ${CIRCLE_SHA1} \
-n "${DATASOURCE_NAME} v${VERSION}" \
-b "${RELEASE_NOTES}" \
-delete \
v${VERSION} \
./artifacts
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ node_modules
npm-debug.log
.DS_Store
.vscode
.idea

dist/
coverage/
artifacts/

.venv*
bin/
build/
61 changes: 60 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,63 @@
# Changelog
## Entries

## v1.1.1

- Allow the key to be an array in the location data. For example:
```json
[
{
"key": "US",
"latitude": 37.09024,
"longitude": -95.712891,
"name": "United States"
},
{
"key": [
"US.CA","US-CA","US_California"
],
"latitude": 36.17,
"longitude": -119.7462,
"name": "California"
},
{
"key": [
"US.IA","US-IA","US_Iowa"
],
"latitude": 42.0046,
"longitude": -93.214,
"name": "Iowa"
},
{
"key": "Unknown",
"latitude": 66,
"longitude": 66,
"name": "Unknown"
}
]
```
- Support hierarchical keys with segments delimited by '.-_'. The longest match at a segment boundary wins. For example, with the location data above, a key of "US.CA.PaloAlto" will be matching "US.CA". "US-Unknown" will match "US".
- If the location data has an entry with key="unknown", this entry will be returned for any un-matched input data.
- Added a built-in location data file "world_regions", with 2 letter country code and provinces in China and states in the US.
- Made circle area (instead of radius) to be linear in data value.
- Added 'kMGTP' unit to the data value

## v1.0.1

- Release for Grafana 7.0 with plugin signing

## v0.2.1

- Fixes error handling that made everything disappear in edit mode, [#213](https://github.com/grafana/worldmap-panel/issues/213)
- Fixes partial (not full height) map on first render [#212](https://github.com/grafana/worldmap-panel/issues/212)

## v0.2.0

- Convert to TypeScript, webpack and Jest
- Use Yarn on CircleCI
- Add missing dev dependencies
- Tweak for incorrect height on render
which occurs more frequently in Grafana 6.0

## v0.1.2

Expand All @@ -13,7 +72,7 @@
## v0.1.0

- Configuration option for turning mouse wheel zoom on or off. [#140](https://github.com/grafana/worldmap-panel/issues/140) Thanks [@Perlovka](https://github.com/Perlovka)
- Upgrade to Leaflet JS [#132](https://github.com/grafana/worldmap-panel/pull/132) Thanks [@cbarbier](https://github.com/cbarbier)
- Upgrade to Leaflet JS [#132](https://github.com/grafana/worldmap-panel/pull/132) Thanks [@cbarbier](https://github.com/cbarbier)

## v0.0.21

Expand Down
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Time Series data contains a timestamp, a metric name and a numeric value. In oth
```json
[
{"target": "SE", "datapoints": [[183255.0, 1529755200]]},
{"target": "US", "datapoints": [[192224.0, 1529755200]]}
{"target": "US", "datapoints": [[192224.0, 1529755200]]},
{"target": "US.CA.PaloAlto", "datapoints": [[3922.0, 1529755200]]}
]
```

Expand All @@ -46,11 +47,37 @@ Location data should be in the JSON format and should be an array of JSON object
"latitude": 37.09024,
"longitude": -95.712891,
"name": "United States"
},
{
"key": [
"US.CA",
"US-CA",
"US_California"
],
"latitude": 36.17,
"longitude": -119.7462,
"name": "California"
},
{
"key": [
"US.IA",
"US-IA",
"US_Iowa"
],
"latitude": 42.0046,
"longitude": -93.214,
"name": "Iowa"
},
{
"key": "Unknown",
"latitude": 66,
"longitude": 66,
"name": "Unknown"
}
]
```

The Worldmap will then match the metric name (target in the example data) with a key field from the location data. With this example data there will be two circles drawn on the map, one for Sweden and one for the United States with values 183255 and 192224.
The Worldmap will then match the metric name (target in the example data) with a key field from the location data. With this example data there will be three circles drawn on the map, one for Sweden, one for the United States and one for California with values 183255, 192224 and 3922.

### Table Format

Expand Down Expand Up @@ -218,8 +245,9 @@ There are four ways to provide data for the worldmap panel:

- *countries*: This is a list of all the countries in the world. It works by matching a country code (US, FR, AU) to a node alias in a time series query.
- *states*: Similar to countries but for the states in USA e.g. CA for California
- *world_regions*: On top of countries, added states in USA and provinces in China with hierarchical keys e.g. US.CA for California, CN.GD for Guangdong.
- *geohash*: An ElasticSearch query that returns geohashes.
- *json*: A json endpoint that returns custom json. Examples of the format are the [countries data used in first option](https://github.com/grafana/worldmap-panel/blob/master/src/data/countries.json) or [this list of cities](https://github.com/grafana/worldmap-panel/blob/master/src/data/probes.json).
- *json*: A json endpoint that returns custom json. Examples of the format are the [countries data used in first option](https://github.com/mileweb/worldmap-panel/blob/master/src/data/countries.json) or [this list of world_regions](https://github.com/mileweb/worldmap-panel/blob/master/src/data/world_regions.json).
- *jsonp*: A jsonp endpoint that returns custom json wrapped as jsonp. Use this if you are having problems with CORS.
- *table*: This expects the metric query to return data points with a field named geohash or two fields/columns named `latitude` and `longitude`. This field should contain a string in the [geohash form](https://www.elastic.co/guide/en/elasticsearch/guide/current/geohashes.html). For example: London -> "gcpvh3zgu992".

Expand Down Expand Up @@ -279,4 +307,4 @@ The threshold field also accepts 2 or more comma-separated values. For example,

### CHANGELOG

The latest changes can be found here: [CHANGELOG.md](https://github.com/grafana/worldmap-panel/blob/master/CHANGELOG.md)
The latest changes can be found here: [CHANGELOG.md](https://github.com/mileweb/worldmap-panel/blob/master/CHANGELOG.md)
Loading