Content deleted Content added
m Pppery moved page Module:Dot graph/sandbox to Module:Dot chart/sandbox without leaving a redirect: Module move cleanup |
BrandonXLF (talk | contribs) No edit summary Tag: Reverted |
||
Line 1:
local p = {}
local getArgs = require(
local yesno = require('Module:Yesno')
▲---------- Returns all the dots (with absolute postions) -----------------------
function p.data(frame) -- Returns the data of the graph
local args = getArgs(frame)
Line 29 ⟶ 25:
local yLCount = 0
if yesno(args[
isx = false
else
Line 35 ⟶ 31:
end
if args[
for str in string.gmatch(args[
table.insert(xLabels, str)
xLCount = xLCount+1
end
end
if args[
for str in string.gmatch(args[
table.insert(yLabels, str)
yLCount = yLCount+1
end
end
if args[
local i = 0
local j = 0
for k, v in pairs(args) do
if string.match(k,
and not string.match(k,
table.insert(yTable, v)
yCount = yCount+1
end
end
local cols = yCount / tonumber(args[
if cols ~= math.floor(cols) then
return
end
while(cols>i) do
local xValue = ((100 / cols * i) + (100 / cols / 10)) * 1.1
i = i + 1
while(tonumber(args[
j = j + 1
table.insert(xTable, xValue)
xCount = xCount + 1
end
j = 0
end
else -- Divides args into the yTable and the xTable
for k, v in pairs(args) do
if string.match(k,
and not string.match(k,
if isx == false then
table.insert(yTable, v)
yCount = yCount + 1
isx = true
elseif not args[
table.insert(xTable, v)
xCount = xCount + 1
isx = false
Line 95 ⟶ 91:
if xCount < yCount then
return
elseif xCount > yCount then
return
end
if args[
colorTime = false
for k, v in pairs(yTable) do
if colorTime == true then
colorTable[k] = args[
colorTime = false
else
Line 112 ⟶ 108:
end
if args[
colorTime = true
for k, v in pairs(yTable) do
if colorTime == true then
colorTable[k] = args[
colorTime = false
else
Line 124 ⟶ 120:
end
for k, v in pairs(args) do
if k == mw.ustring.match(k,
num = mw.ustring.gsub(k,
num = tonumber(num)
colorTable[num] = v
Line 132 ⟶ 128:
end
for k, y in pairs(yTable) do
local
local div = mw.html.create('div')
local size;
if args[
size = tonumber(mw.ustring.match(args[
else
size = 8
end
x = xTable[k]
innerDiv
:css('position', 'absolute')
:css('top',
:css('left',
:css('line-height', '0')
:wikitext('[[File:Location dot ', colorTable[k] or 'red', '.svg|', size, 'x', size, 'px]]')
div
:css('position', 'absolute')
:css('bottom',
:css('left',
:wikitext(tostring(
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',
: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',
:css('left', '0%')
:wikitext(v)
table.insert(dotTable, tostring(div))
end
Line 179 ⟶ 175:
end
-- Create the legendTable
local function legend(args)
local color;
local aValue;
local
for k, v in pairs(args) do
if k == mw.ustring.match(k,
color = mw.ustring.gsub(k,
v =
table.insert(
aValue = true
end
end
if aValue == true then
return table.concat(
else
return
end
end
-- Get all the dots in a div tag
function p.graph(frame) -- Returns a graph with the dots on it
if mw.ustring.match(p.data(frame),
return p.data(frame)
end
local args = getArgs(frame)
local picture =
local div = mw.html.create('div')
local center = mw.html.create('div')
Line 217 ⟶ 207:
local top = mw.html.create('div')
local size;
if args[
size = tonumber(mw.ustring.match(args[
else
size = 8
end
if args[
if args[
args[
end
end
if args[
picture = args[
elseif yesno(args[
picture =
end
picture = mw.ustring.gsub(picture, '|.+', '')
picture = mw.ustring.gsub(picture, '.-:', '')
if p.data(frame) ==
return
end
if args[
top -- Create top text
:css('font-weight', 'bold')
:css('text-decoration', 'underline')
:css('text-align', 'center')
:wikitext(args[
end
args[
if not args[
args[
end
container -- Creates container
:css('width', args[
:css('float', 'right')
:css('position', 'relative')
:wikitext('[[File:', picture, '|', args[
:wikitext(p.data(frame))
div -- Creates box
:css('width', args[
:css('display', 'inline-block')
:css('float', args[
:css('margin', args[
:css('padding', args[
:css('background', args[
:wikitext(tostring(top))
:wikitext(tostring(container))
:wikitext(legend(args))
:wikitext(args[
if yesno(args['border']) ~= false then -- Creates box border
div
:css('border-style', 'solid')
:css('border-color', 'black')
:css('border-width', '3px')
end
Line 284 ⟶ 274:
center
:addClass('center')
:css('width', 'auto')
:css('margin-left', 'auto')
:css('margin-right', 'auto')
:wikitext(tostring(div))
return center
|