Extension talk:Graph/Demo

Improvements
Have suggested some improvements here

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. And than I can start creating bunches to add to Wikipedia. Doc James (talk) 23:53, 23 July 2015 (UTC)
 * This has been resolved with Vega 2.0. --Yurik (talk) 02:54, 24 January 2016 (UTC)

Firefox
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)
 * , There was an issue with caching, should be working now. Please double check. Thx! --Yurik (talk) 02:54, 24 January 2016 (UTC)

Graphs are not the same in previewing mode and reading mode
The following graph : { "version": 2, "width": 700, "height": 200, "padding": {"top": 10, "left": 65, "bottom": 20, "right": 10},

"data": [ {     "name": "table", "values": [ {"category":"français", "amount":1489616}, {"category":"russe", "amount":175173}, {"category":"bulgare", "amount":155782}, {"category":"anglais", "amount":131326}, {"category":"espagnol", "amount":99599}, {"category":"latin", "amount":82650}, ]   }  ],

"signals": [ {     "name": "tooltip", "init": {}, "streams": [ {"type": "rect:mouseover", "expr": "datum"}, {"type": "rect:mouseout", "expr": "{}"} ]   }  ],

"scales": [ { "name": "xscale", "type": "ordinal", "range": "width", "domain": {"data": "table", "field": "category"} }, { "name": "yscale", "range": "height", "nice": true, "domain": {"data": "table", "field": "amount"} } ],

"axes": [ { "type": "x", "scale": "xscale" }, { "type": "y", "scale": "yscale" } ],

"marks": [ {     "type": "rect", "from": {"data":"table"}, "properties": { "enter": { "x": {"scale": "xscale", "field": "category"}, "width": {"scale": "xscale", "band": true, "offset": -1}, "y": {"scale": "yscale", "field": "amount"}, "y2": {"scale": "yscale", "value":0} },       "update": { "fill": {"value": "steelblue"} }, "hover": { "fill": {"value": "red"} } }   },    {      "type": "text", "properties": { "enter": { "align": {"value": "center"}, "fill": {"value": "#333"} },       "update": { "x": {"scale": "xscale", "signal": "tooltip.category"}, "dx": {"scale": "xscale", "band": true, "mult": 0.5}, "y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -5}, "text": {"signal": "tooltip.amount"}, "fillOpacity": [ {             "test": "tooltip._id === null", "value": 0 },           {"value": 1} ]       }      }    }  ] } is supposed to have a "mouseover" functionality; actually, this functionality works only when previewing the graph. Automatik (talk) 22:08, 1 February 2016 (UTC)


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


 * Thank you Yurik! I suscribed to the phab task. Automatik (talk) 22:16, 2 February 2016 (UTC)

Use of parser functions in "graph" tags
Hello,

It seems that we can not use the parser functions —like — in   (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)


 * , fixed above - use the  . In general, I would advise to put graphs into their own templates like here. --Yurik (talk) 15:55, 6 March 2016 (UTC)
 * 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)
 * , I do not understand, it worked a few weeks ago on fr.wiktionary (wikt:fr:Discussion Wiktionnaire:Statistiques), now it doesn't work, neither with or without (like before). Seems strange. Automatik (talk) 16:30, 6 March 2016 (UTC)
 * , 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 &lt;graph> tags because it made other code much slower and more complicated. The template expansion only works if you use the , just like all other tags like &lt;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)
 * : 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)
 * , thx, updated. --19:40, 6 March 2016 (UTC)

Graphs broken
Graphs in Using_RESTBase_API section seems broken.--Eloy (talk) 17:48, 20 April 2016 (UTC)
 * , 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)

Commons
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)
 * , 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)

Lua modules?
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)
 * sure, Template:Graph:Chart does exactly that. You can also use a   approach.--Yurik (talk) 22:40, 20 April 2016 (UTC)

SPARQL-datasource
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)
 * , 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)


 * 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 --Zache (talk) 14:02, 11 October 2017 (UTC)

Json-stat
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? --Zache (talk) 13:30, 21 November 2017 (UTC)
 * 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
 * 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)

Any examples of use on English Wikipedia?
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.

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


 * - about 3500 pages use it. Some are much more interesting than others: , . --Yurik (talk) 20:34, 25 December 2017 (UTC)

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:

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


 * Timeshifter: heh, the actual graph is much worse ;) w:template:Graph:US Map state highlight --Yurik (talk) 06:22, 29 December 2017 (UTC)


 * 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)
 * See Extension:Graph - good links there. --Yurik (talk) 01:24, 30 December 2017 (UTC)