모듈:글상자: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
1번째 줄: 1번째 줄:
local p = {}
local p = {}
local table_ = {
local table_ = {
    width = 400, height = 300, data = {}, signals = {}, scales ={}, axes ={} , marks= {},
width = 400, height = 300, scales = {}, axes = {}, marks = {}, signals = {}, data = {}
    data = "1"
}
}
data[1] = {}
 
data[1].name = "table"
table_.data[1] = {}
data[1].values = {
table_.data[1].name = "table"
table_.data[1].values = {
     {category = "USB 3.2 Gen 2x2", amount = 20},
     {category = "USB 3.2 Gen 2x2", amount = 20},
     {category = "USB 3.2 Gen 2(구 명칭 USB 3.1 Gen2, USB 3.1)", amount = 10},
     {category = "USB 3.2 Gen 2(구 명칭 USB 3.1 Gen2, USB 3.1)", amount = 10},
14번째 줄: 14번째 줄:
}
}


signals[1] = {}
table_.signals[1] = {
signals[1].name = "tooltip"
    name = "tooltip",
signals[1].value = {}
    value = {},
signals[1].on = {
    on = {
         {events = "rect:mouseover", update = "datum"},
         {events = "rect:mouseover", update = "datum"},
         {events = "rect:mouseout", update = "{}"}
         {events = "rect:mouseout", update = "{}"}
    }
}
}


scales[1] = {}
table_.scales[1] = {
scales[1].name = "x"
    name = "x",
scales[1].range = "width"
    range = "width",
scales[1].domain = {data = "table", field = "amount"}
    domain = {data = "table", field = "amount"},
scales[1].round = true
    round = true
}
table_.scales[2] = {
    name = "y",
    range = "height",
    type = "ordinal",
    domain = {data = "table", field = "category"},
    padding = 0.3,
    round = true
}


scales[2] = {}
table_.axes[1] = {type = "x", scale = "x", title = "Gbps"}
scales[2].name = "y"
table_.axes[2] = {type = "y", scale = "y"}
scales[2].range = "height"
scales[2].type = "ordinal"
scales[2].domain = {data = "table", field = "category"}
scales[2].padding = 0.3
scales[2].round = true


axes[1] = {type = "x", scale = "x", title = "Gbps"}
table_.marks[1] = {
axes[2] = {type = "y", scale = "y"}
 
marks[1] = {
     type = "rect",
     type = "rect",
     from = {data = "table"},
     from = {data = "table"},
59번째 줄: 61번째 줄:
     }
     }
}
}


function p.jsonDecode()
function p.jsonDecode()

2021년 6월 6일 (일) 15:33 판

설명문서 [편집] [역사] [새로고침]

스크립트 오류: 함수 "main"가 존재하지 않습니다.

연습장이나 사용자 문서에서 틀의 사용이나 수정을 연습할 수 있습니다.
분류는 /설명문서에 넣어주세요.

local p = {}
local table_ = {
	width = 400, height = 300, scales = {}, axes = {}, marks = {}, signals = {}, data = {}
}

table_.data[1] = {}
table_.data[1].name = "table"
table_.data[1].values = {
    {category = "USB 3.2 Gen 2x2", amount = 20},
    {category = "USB 3.2 Gen 2(구 명칭 USB 3.1 Gen2, USB 3.1)", amount = 10},
    {category = "USB 3.2 Gen 1(구 명칭 USB 3.1 Gen 1, USB 3.0) ", amount = 5},
    {category = "USB 2.0", amount = 0.480},
    {category = "USB 1.0", amount = 0.12}
}

table_.signals[1] = {
    name = "tooltip",
    value = {},
    on = {
        {events = "rect:mouseover", update = "datum"},
        {events = "rect:mouseout", update = "{}"}
    }
}

table_.scales[1] = {
    name = "x",
    range = "width",
    domain = {data = "table", field = "amount"},
    round = true
}
table_.scales[2] = {
    name = "y",
    range = "height",
    type = "ordinal",
    domain = {data = "table", field = "category"},
    padding = 0.3,
    round = true
}

table_.axes[1] = {type = "x", scale = "x", title = "Gbps"}
table_.axes[2] = {type = "y", scale = "y"}

table_.marks[1] = {
    type = "rect",
    from = {data = "table"},
    properties = {
        enter = {
            y = {scale = "y", field = "category"},
            height = {scale = "y", band = true},
            x = {scale = "x", value = 0},
            x2 = {scale = "x", field = "amount"}
        },
        update = {
            fill = {value = "#4188F1"}
        },
        hover = {
            strokeWidth = {value = 1},
            stroke = {value = "#4188F1"},
            fill = {value = "#F5F8FA"}
        }
    }
}

function p.jsonDecode()
    return 0
    --mw.text.jsonDecode()
end
function p.jsonEncode()
    return mw.text.jsonEncode(table_)

end

function p.textDecode(frame)
    return mw.text.decode(frame.args[1])
end
function p.textSplit(frame)
    return mw.text.split(frame.args[1], frame.args[2], frame.args[3] or "")
end

local vertical_p = {}

function vertical_p.main(frame)
    local str = ""
    local i, j = 1, 1

    while frame.args[i] do
        str = str..[[<div class="vertical_p" style="float:left;">]]..frame.args[i]..[[ <  / div > ]]
        i = i + 1
    end
    return str
end

--return vertical_p
return p