-
Notifications
You must be signed in to change notification settings - Fork 0
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
Introduce plots in tweets #1
Comments
When you say small image are you referring to the green and black icons that are being returned in the json from the api? Or will it be from another known source? |
I was actually thinking something more like the plot of the forecast that's currently on the web page: The plot is currently rendered client-side, but it should be possible to render it when generating the tweets as well. |
I saw that the plot of the referred forecast above is rendered by the front end using the import altair
import json
import requests
url = "https://xn--grnstrm-r1ae.nu/api/v1/current-emission-intensity"
response = requests.get(url)
jd = json.dumps(response.json().get("plot-data"))
altair.Chart.from_json(jd)
Shortened Traceback:
AttributeError: 'list' object has no attribute 'get' I may have made mistakes in my approach and I'd appreciate if you'd help me navigate them. Thanks for your comments thus far. |
In your traceback, which of the two |
I forgot to paste the requests in the snippet. Did it really work because I tried it again after your comment and I'm still getting the same error for the |
Yep, here's with I get:
|
4.1.0
2.26.0
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last) This is my output unfortunately for the same snippet above. What version for python are you using? |
What is the value of |
That looks about right as well; as in, altair.Chart.from_json(json.dumps(requests.get("https://github.com/groenstroem/twitter/files/7273244/plot_data_response.txt").json().get('plot-data'))) does what it should. You'll have to either get the full traceback, or debug each step. |
It's relatively straightforward to include images in Twitter updates. In our case, it would make sense to include a small image showing the current forecast.
The text was updated successfully, but these errors were encountered: