Extension talk:Graph/Demo

Improvements edit

Have suggested some improvements here [1]

This is exceedingly useful. I just need to be able to pull the what colors correspond to what ranges of numbers out of the map. An example is here [2]. And than I can start creating bunches to add to Wikipedia. Doc James (talk) 23:53, 23 July 2015 (UTC)Reply

This has been resolved with Vega 2.0. --Yurik (talk) 02:54, 24 January 2016 (UTC)Reply

Firefox edit

The "Using API" graphs don't load at all for me in Firefox 42, even after disabling NoScript. Nemo 22:54, 16 December 2015 (UTC)Reply

Nemo_bis, There was an issue with caching, should be working now. Please double check. Thx! --Yurik (talk) 02:54, 24 January 2016 (UTC)Reply

Graphs are not the same in previewing mode and reading mode edit

The following graph :

is supposed to have a "mouseover" functionality; actually, this functionality works only when previewing the graph. Automatik (talk) 22:08, 1 February 2016 (UTC)Reply

Automatik, you need to enable it with "mode=interactive" (I fixed it above). You might also be interested in commenting on phab:T124254 - to make all graphs load dynamically on desktop. --Yurik (talk) 11:37, 2 February 2016 (UTC)Reply
Thank you Yurik! I suscribed to the phab task. Automatik (talk) 22:16, 2 February 2016 (UTC)Reply

Use of parser functions in "graph" tags edit

Hello,

It seems that we can not use the parser functions —like {{NUMBEROFARTICLES|R}}— in <graph></graph> (a few weeks ago, it was possible):


Is there a way to use them? If not, could it be the case? Automatik (talk) 15:43, 6 March 2016 (UTC)Reply

Automatik, fixed above - use the {{tag:graph| {...} |mode=interactive}}. In general, I would advise to put graphs into their own templates like here. --Yurik (talk) 15:55, 6 March 2016 (UTC)Reply
Automatik P.S. Note that it seems some of these graphs do not exist on mediawiki, that's why it fails. Check it by changing :graph to :code. --Yurik (talk) 16:13, 6 March 2016 (UTC)Reply
Yurik, I do not understand, it worked a few weeks ago on fr.wiktionary (wikt:fr:Discussion Wiktionnaire:Statistiques#graph), now it doesn't work, neither with {{#tag:graph| {...} |mode=interactive}} or without (like before). Seems strange. Automatik (talk) 16:30, 6 March 2016 (UTC)Reply
Automatik, yes, my apologies, I thought I fixed all the cases before turning off template expansion. I had to disable the expansion of the templates inside the <graph> tags because it made other code much slower and more complicated. The template expansion only works if you use the {{#tag:graph|...}}, just like all other tags like <syntaxhighlight> and other. When you use the #tag:graph, make sure to always add a space between two } }. Also, if you ever need to use a pipe | symbol for the graph itself, use the {{!}} instead. Thanks!--Yurik (talk) 17:10, 6 March 2016 (UTC)Reply
Yurik: thank you. For information, this and this seem inconsistent: where is the main version of the template PageViews_graph? — Automatik (talk) 19:16, 6 March 2016 (UTC)Reply
Automatik, thx, updated. --19:40, 6 March 2016 (UTC)Reply

Graphs broken edit

Graphs in Using_RESTBase_API section seems broken.--Eloy (talk) 17:48, 20 April 2016 (UTC)Reply

Eloy, there is a graphs' bug that causes invalid images after some time if the graph uses time-based function. The pageviews api call uses last N days, thus the range changes every day. I will need to fix it once i figure out what is the root cause. --Yurik (talk) 00:30, 21 April 2016 (UTC)Reply

Commons edit

I think it would be better if graph's JSON were uploaded to Commons. Or am I wrong?--Eloy (talk) 17:49, 20 April 2016 (UTC)Reply

Eloy, sure, it would be much better to share graphs and modules rather than copying them to each wiki by hand. There is a number of proposals for that, such as shadow namespaces, etc. It will be a long way to get there though :(. --Yurik (talk) 22:42, 20 April 2016 (UTC)Reply

Lua modules? edit

Is there a way to construct grpahs with a module? I think this could be linked to Wikidata, also.--Eloy (talk) 17:51, 20 April 2016 (UTC)Reply

Eloy sure, Template:Graph:Chart does exactly that. You can also use a {{#tag:graph| { ...graph definition... } }} approach.--Yurik (talk) 22:40, 20 April 2016 (UTC)Reply

SPARQL-datasource edit

@Yurik: is it possible to draw bar/pie/line charts using data from SPARQL? It works with the maps so i guess it is possible, but i could not figure how it should be done. --Zache (talk) 10:26, 10 October 2017 (UTC)Reply

@Zache: , sure, sparql can be used as another data source. some examples. Also, Template:Graph:Population_history can pull data from Wikidata. --Yurik (talk) 17:42, 10 October 2017 (UTC)Reply
@Yurik: Thanks! Graph:Population history was something what i was searching! I modified the idea and copied it to the d:Wikidata:Wikidata_in_Wikimedia_projects#Maps_and_graphs --Zache (talk) 14:02, 11 October 2017 (UTC)Reply

Json-stat edit

@Yurik: Do you think that it would be possible to translate json-stat formatted data to graphs directly in Vega or do i need to parse it using Lua or convert it to some simpler format before i store it to wiki?

Specifications
https://json-stat.org/
Example data
http://json-stat.org/samples/oecd.json
Example code for parsing
https://json-stat.org/tools/php.txt

--Zache (talk) 13:30, 21 November 2017 (UTC)Reply

@Zache: in theory it should be possible to process many common types of data, like the one you have, but it might get very tricky. It will be a whole bunch of transformations, mostly lookup transformations (and possibly various groupbys, like facet), to convert an array of elements to something else. I got a bit lost in the code - it seems you have a bunch of lookup tables, and somehow convert some set of data into some other set, but I couldn't grasp the exact conversion. And yes, in the worst case, you can dynamically generate the graph tag using Lua. But obviously it won't be as easy to manage. --Yurik (talk) 21:53, 22 November 2017 (UTC)Reply

Any examples of use on English Wikipedia? edit

Is this extension enabled on English Wikipedia? Can you point me to some examples of this being used on Wikipedia? Even if just on some user pages.

I rarely check my mediawiki.org watchlist. So, please ping me in your reply. {{ping|Timeshifter}}

Thanks in advance. --Timeshifter (talk) 20:12, 25 December 2017 (UTC)Reply

@Timeshifter: - about 3500 pages use it. Some are much more interesting than others: [3], [4]. --Yurik (talk) 20:34, 25 December 2017 (UTC)Reply

Unindent. Thanks! I have not been looking at my email for a few days. So many questions. Just a quick note for now until I have more time to look at this. This stuff is so advanced. I know next to nothing about wikidata. And this is all Greek to me:

{{Image frame
|width=440
|content={{Graph:US Map state highlight | table=Bea.gov/GDP by state.tab}}
|caption=Map of U.S. states by GDP in million [[U.S. dollars]].
|align=right}}

It is from List of U.S. states by GDP. --Timeshifter (talk) 05:28, 29 December 2017 (UTC)Reply

Timeshifter: heh, the actual graph is much worse ;) w:template:Graph:US Map state highlight --Yurik (talk) 06:22, 29 December 2017 (UTC)Reply
I see what you mean! What about the easier static stuff? Can you link to some examples on Wikipedia? Are there help pages on Wikipedia?
No need to ping me. I cleared out my watchlist, and set preferences to email me when anything on my watchlist (like this talk page) is changed.
It is a shame that there is not a single combined watchlist for all Wikipedia.org, Wikimedia.org, and mediawiki.org projects. So much more work would get done on Mediawiki, Meta, etc.. I only regularly look at my Wikipedia and Commons watchlists. --Timeshifter (talk) 23:04, 29 December 2017 (UTC)Reply
See Extension:Graph - good links there. --Yurik (talk) 01:24, 30 December 2017 (UTC)Reply

Wikidata integration edit

@Yurik: I'm trying to think of ways some of these graphs could be turned into useful properties for Wikidata. Any ideas come to mind? NMaia (talk) 01:41, 6 May 2019 (UTC)Reply

NMaia hehe, depends on what you are trying to achieve. It might make sense to have some sort of a popup on some properties like weather and population history (if available), and those have already been mostly done, but I can't think much beyond that... I would have to dig deep into wikidata :) --Yurik (talk) 01:46, 6 May 2019 (UTC)Reply
I was thinking of using a map like this on items such as Brazil–Suriname relations (Q15432031), as a more elegant way to show this relationship than locator map image (P242) with an image. The problem is that for small countries, a small and zoomed out map like that wouldn't be super useful. NMaia (talk) 01:50, 6 May 2019 (UTC)Reply
Ah yes, that's totally doable -- that's actually why i created that example to begin with. Would be a fun project :) I would think the map shouldn't be its own page, but rather a template of sorts with a param specifying which regions to highlight. --Yurik (talk) 01:53, 6 May 2019 (UTC)Reply
@Yurik: Sorry, I couldn't parse your last sentence. What did you mean? NMaia (talk) 03:30, 6 May 2019 (UTC)Reply
sorry i meant map, not relation (not sure where that came from. E.g. there shouldn't be one page per different map, but rather a generic template that you can give a wikidata id or a few country codes and it will draw it properly. --Yurik (talk) 03:32, 6 May 2019 (UTC)Reply

Timestamps edit

In the Timeline / lifeline example, what format are the timestamps for dates in? 

For example, George Washington's birth (February 22, 1732) is represented as "-7506057600000", and death (December 14, 1799) as "-5366196000000" --Owencunn (talk) 23:40, 12 July 2021 (UTC)Reply

Those timestamps are in Unix time, measured using milliseconds instead of seconds (à la JavaScript):
new Date(-7506057600000).toUTCString() === "Fri, 22 Feb 1732 08:00:00 GMT"
new Date(-5366196000000).toUTCString() === "Sat, 14 Dec 1799 06:00:00 GMT"
Alhadis (talk) 22:11, 11 February 2023 (UTC)Reply

Graphs not displayed on tablette (...nor laptop) edit

Graphs images are not displayed (blank) on my tablette Galaxy Android; any view type mobile/desktop; any browser Chrome/Internet Galaxy ; any user status connected / anonymous. -- Christian 🇫🇷 FR (talk) 09:24, 18 April 2023 (UTC)Reply

Graph DISABLED => https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)#Graph_extension_disabled_per_immediate_effect -- Christian 🇫🇷 FR (talk) 12:42, 18 April 2023 (UTC)Reply
Return to "Graph/Demo" page.