Created
February 20, 2018 12:36
-
-
Save somejavadev/0ff3ed73e30b77fe4bd275872747a4e7 to your computer and use it in GitHub Desktop.
Simple weather html to be used in a Grafana text panel. Weather gets refreshed on the global refresh of the dashboard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
A simple grafana weather panel combined by posts from this page: https://github.com/grafana/grafana/issues/1816 | |
Just change the WOE_ID. Get one for your region here: http://www.woeidlookup.com/ | |
--> | |
<script> | |
var WOE_ID = XXXX; | |
var callbackFunction = function (data) { | |
var wind = data.query.results.channel.wind; | |
$("#windspeed").text(wind.speed); | |
var astronomy = data.query.results.channel.astronomy; | |
$("#sunrise").text(astronomy.sunrise); | |
$("#sunset").text(astronomy.sunset); | |
var condition = data.query.results.channel.item.condition; | |
$("#temp").text(condition.temp); | |
$("#conditions").text(condition.text); | |
}; | |
var getWeather = function () { | |
jQuery.get("https://query.yahooapis.com/v1/public/yql?q=select item, condition, wind, astronomy from weather.forecast where woeid =" + WOE_ID + " and u='c'&format=json", callbackFunction); | |
}; | |
angular.element('#weatherPanel').injector().get('$rootScope').$on('refresh', function () { | |
getWeather(); | |
}); | |
getWeather(); | |
</script> | |
<div id="weatherPanel"> | |
Temperature: <span id="temp"/> °C</br> | |
Sunrise: <span id="sunrise"/> </br> | |
Sunset: <span id="sunset"/> </br> | |
Wind Speed: <span id="windspeed"/> km/h </br> | |
Conditions: <span id="conditions"/> </br> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work for me.the jQuery link not responding. How about angular?