Content deleted Content added
BrandonXLF (talk | contribs) No edit summary |
BrandonXLF (talk | contribs) Don't add border:none to improve compatibility with skin dark mode CSS |
||
(63 intermediate revisions by 2 users not shown) | |||
Line 3:
local yesno = require('Module:Yesno')
--------------------------------------------------------------------------------
---------- P . D O T S ---------------------------------------------------------
---------- Returns all the dots (with absolute postions) -----------------------
--------------------------------------------------------------------------------
local args = getArgs(frame)
-- Dot related
local yTable = {}
local xTable = {}
Line 12 ⟶ 16:
local yCount = 0
local isx;
local dotTable = {}
local x;
-- Color related
local colorTable = {}
local num;
local colorTime;
-- X label related
local xLabels = {}
local xLCount = 0
-- Y label related
local yLabels = {}
local yLCount = 0
if yesno(args["yx"]) == true then
isx = false
else
isx = true
end
if args["x labels"] then -- Create xLabels
for str in string.gmatch(args["x labels"], "([^,]+)") do
table.insert(xLabels,str)
xLCount = xLCount+1
end
end
if args["y labels"] then -- Create yLabels
for str in string.gmatch(args["y labels"], "([^,]+)") do
table.insert(yLabels,str)
yLCount = yLCount+1
end
end
Line 38 ⟶ 68:
while(cols>i) do
local xValue = ((100/cols*i)+(100/cols/
i=i+1
while(tonumber(args["dots"])>j) do
Line 69 ⟶ 99:
return table.concat({'<span style="font-size:100%" class="error">The amount of x values (',xCount,') is more then the number y values (',yCount,')</span>'})
end
if args["color-even"] then -- Creates the colorTable if color-even is set
Line 165 ⟶ 150:
div
:css('position','absolute')
:css('bottom',table.concat({y*0.85+15,'%'}))
:css('
:wikitext(tostring(InnerDiv))
table.insert(dotTable,tostring(div))
end
for k,v in pairs(xLabels) do
local div = mw.html.create('div')
div
:css('position','absolute')
:css('bottom','0%')
:css('left',table.concat({((100/xLCount*k-100/xLCount)*0.85+15)-4,'%'}))
:wikitext(v)
table.insert(dotTable,tostring(div))
end
for k,v in pairs(yLabels) do
local div = mw.html.create('div')
div
:css('position','absolute')
:css('bottom',table.concat({(((((100/yLCount*k-100/yLCount)-(100/yLCount/3))+5))+100/yLCount/2)*1.02,'%'}))
:css('left','0%')
:wikitext(v)
table.insert(dotTable,tostring(div))
end
return table.concat(dotTable)
end
---------- L E G E N D ---------------------------------------------------------
---------- Makes the legendTable -----------------------------------
local function legend(args)
local color;
local aValue;
local Table = {}
for k,v in pairs(args) do -- Adds values to the table
if k == mw.ustring.match(k,"legend%-%a+") then
color = mw.ustring.gsub(k,"legend%-","")
v = table.concat({'<div>[[File:Location dot ',color or 'red','.svg|8x8px]] (',color,') = ',v,'</div>'})
table.insert(Table,v)
aValue = true
end
end
if aValue == true then
return table.concat(Table)
else
return ""
end
end
--------------------------------------------------------------------------------
---------- P . G R A P H -------------------------------------------------------
---------- Returns all the dots in div tags-------------------------------------
--------------------------------------------------------------------------------
function p.graph(frame) -- Returns a graph with the dots on it
if mw.ustring.match(p.
return p.
end
local args = getArgs(frame)
Line 186 ⟶ 214:
local div = mw.html.create('div')
local center = mw.html.create('div')
local container = mw.html.create('div')
local top = mw.html.create('div')
Line 211 ⟶ 238:
picture = mw.ustring.gsub(picture,'.-:','')
if p.
return ""
end
Line 256 ⟶ 255:
:css('position','relative')
:wikitext('[[File:',picture,'|',args["width"] or '240px',']]')
:wikitext(p.
div -- Creates box
:css('width', args["width"] or '240px')
:css('display', 'inline-block')
:css('float', args["align"] or 'right')
:css('margin', args["margin"] or '2px')
:css('padding', args["padding"] or table.concat({size/2,'px'}))
:wikitext(tostring(top))
:wikitext(tostring(container))
:wikitext(legend(args))
:wikitext(args["bottom"])
if args["color"] then
div:css('background', args["color"])
end
if yesno(args['border']) ~= false then -- Creates box border
|