Module talk:Sandbox/Wnt/Plotter

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
System crashAbandon hope, all ye who enter here
  One (42%)
  Two (74%)
  Three (86%)
  Four (89%)
  Five (91%)
  Six (92%)
  Other (8%)

{{#invoke:Sandbox/Wnt/Plotter|bar}}


1996 1997 1998deaths-10030 injuries-10030 nasty laughter-10030



{{#invoke:Sandbox/Wnt/Plotter|main
|title=Football casualties 2000-2010 <small>excluding accidental death and dismemberment</small>
|icon=[[File:Soccerball.svg|20 px]]
|iconradius=10
|plotsizex=300
|plotsizey=200
|2000|6
|2001|11
|2002|18
|2003|14
|2004|12
|2005|16
|2006|9
|2007|18
|2008|20
|2009|21
|2010|15}}



Comments[edit]

Very nice.

some constructive criticism and suggestions:

  • style: the code does not adhere to style guide (esp. spaces in parens - ( a ) and not (a) ). not a huge deal - just mentioned it in passing.
  • i do not like the "Plot" (aka "main", linechart) syntax. i'd rather see the data for the line as a single parameter, and the different points as numbered pairs in parenthesis. this way, you could do something like this (note that:
{{#invoke:Plotter|main
| (some global params, similar to what you have
| plot 1 =  (2000, 6) (2001, 11) (2002, 18) (2003, 14) (2004, 12) 
(2005, 16, icon=[[File:Some spacial icon for this point only]]) 
(2006, 9, color=some background color for this point only) ...
| plot 2 = (2000, 8) (2001,5) (2002,12)... 
}}
  • Pie chart: same difference. i'd like to see the params either as three series (one for values, one for names and one for colors), or a single parameter of ordered trinities. e.g. (130, #ff6622, Napa Valley]])
  • Pie: please lose the assertion that values are supplied as percents. if my data is 4000, 4000, 5000 and 8000 we should be able to draw a chart (and writ the correct values in the legends).
  • Bar chart: (you get the point)
  • All: may be nice to allow making the different objects links. for plot you get it for free if you allow icon per point, like outlined above - the editor needs to set "link=" for the image. for Bars, you do it by inserting a transparent, large enough image to the DIV, set the div style with "overflow=hidden", and use the link= attribute of the image. pie might be a bit tricky, but it can be accomplished by embedding the transparent image inside an "imagemap" tag. it's not entirely trivial, but it's not that hard also.

if you decide to use the (a,b) (a,b) syntax for data pairs, note the %b of gmatch: you can do something like

function processOnePoint( p )
    local a, b, c = mw.gstring.match( p, "%(%s*(%S+)%s*(%S+)%s*%(%S*)%s*%)" )
    if a then   -- if a then also b: c might be empty.
        --[[ calc a new point. personally, i prefer mw.getContentLang():parseFormattedNumber(),
             which allows numbers like 102,333.14 over tonumber().
       ]]
    end
end

for point in mw.ustring.gmatch( paramvalue, "%b()" ) do processOnePoint( point ) end

peace - קיפודנחש (aka kipod) (talk) 21:53, 5 April 2013 (UTC)[reply]