Modul:ChartColors
Used by {{ChartColors}} and {{ChartColorLegends}}
To translate or review the translation of the module to your language, edit carefully Data:I18n/ChartColors.tab.
Function ShowColors
| Code | Result |
|---|---|
{{#invoke:ChartColors|ShowColors|Categ20|5}} |
|
{{ChartColors|Categ20|9}} |
|
{{#invoke:ChartColors|ShowColors|Categ20|3|-}} |
#1f77b4 #ff7f0e #2ca02c |
{{#invoke:ChartColors|ShowColors|Categ20|3|a}} |
#1f77b4ff #ff7f0eff #2ca02cff |
{{#invoke:ChartColors|ShowColors|Plotter|5}} |
|
{{ChartColors|Plotter|20}} |
Function Legends
{{#invoke:ChartColors|Legends|Categ20|5|2}}
produces:
Napaka Lua v vrstici 39: assign to undeclared variable 'MaxN'.
{{#invoke:ChartColors|Legends|Categ20|3|1|One|Two|Three}}
produces:
Napaka Lua v vrstici 39: assign to undeclared variable 'MaxN'.
| Zgornja dokumentacija je vključena iz Modul:ChartColors/dok. (uredi | zgodovina) Urejevalci lahko preizkušate ta modul v peskovniku (ustvari | mirror) in testnihprimerih (ustvari). Prosimo, da dodate kategorije v /dok podstran. Podstrani te predloge. |
local p = {}
local ARG = require "Modul:Arguments"
local CFCM = require "Modul:ComplForColorModules"
local TNTT = require "Modul:TNTTools"
local SD = require "Modul:SimpleDebug"
local I18n = 'ChartColors'
local function I18nStr (S, ...)
return TNTT.GetMsgP (I18n, S, {...})
end
--local RS_ColorNameInvalid = 'El nom del color (%s) no és vàlid (ha de ser Categ20 o Plotter)'
--local RS_ColorNumInvalid = 'El nombre de colors hauria d’estar entre 1 i %d (ara és %d)'
--local RS_StartNumInvalid = 'El número del primer color hauria d’estar entre 1 i %d (ara és %d)'
local category20 = {
'#1f77b4', '#aec7e8', '#ff7f0e', '#ffbb78', '#2ca02c', '#98df8a', '#d62728', '#ff9896', '#9467bd', '#c5b0d5',
'#8c564b', '#c49c94', '#e377c2', '#f7b6d2', '#7f7f7f', '#c7c7c7', '#bcbd22', '#dbdb8d', '#17becf', '#9edae5',
}
local plotter = {--from Module:Plotter/DefaultColors
'red', 'blue', 'green', 'yellow', 'fuchsia', 'aqua', 'brown', 'orange', 'purple', 'sienna',
'#F0A3FF', '#191919', '#005C31', 'honeydew', '#808080', 'khaki', 'lime', 'navy', 'pink', '#426600',
'#5EF1F2', 'turquoise', '#E0FF66', 'violet', '#FFFF80', '#FF5005',
}
function p.GetColors (ColorName, IsInv, StartN, N, CallError)
local SelColors = {}
local ColorNameL = string.lower(ColorName)
local Palet0 = {}
if ColorNameL == 'categ20' then
Palet0 = category20
elseif ColorNameL == 'plotter' then
Palet0 = plotter
elseif CallError then
error (I18nStr ('ColorNameInvalid',ColorName))
end
MaxN = table.getn(Palet0)
if (N < 0) or (N > MaxN) then
error (I18nStr ('ColorNumInvalid',tostring(MaxN),tostring(N)))
else
Palet = {}
if IsInv then
for i=MaxN, 1, -1 do
table.insert(Palet, Palet0[i])
end
else
Palet = Palet0
end
if StartN > MaxN then
error (I18nStr ('StartNumInvalid',tostring(MaxN),tostring(StartN)))
end
local Step = 1
local NEnd = N
if (ColorNameL == 'categ20') and (N<=10) then
Step = 2
if StartN == 1 then
NEnd = N*2
end
end
if StartN == 1 then
for i=1, NEnd, Step do
table.insert(SelColors, Palet[i])
end
else
Count = 0
for i=StartN, MaxN, Step do
table.insert(SelColors, Palet[i])
Count = Count + 1
if Count == NEnd then
break
end
end
if Count < NEnd then
for i=1, MaxN, Step do
table.insert(SelColors, Palet[i])
Count = Count + 1
if Count == NEnd then
break
end
end
end
end
return SelColors
end
end --GetColors
function p.ColorNameInvStartFromS (S)
local StartN = 1
local ParamsA = {}
local ColorName, IsInv
ColorName, IsInv, ParamsA = CFCM.ColorNameInvFromS0 (S)
local PN = table.getn(ParamsA)
if PN > 1 then
if ParamsA[2]=='i' then
IsInv = true
else
StartN = tonumber (ParamsA[2])
end
if PN == 3 then
StartN = tonumber (ParamsA[3])
end
end
return ColorName, IsInv, StartN
end --ColorNameInvStartFromS
function ColorNameInv (args)
local S = args[1] or ''
local ColorName, IsInv, ParamsA = CFCM.ColorNameInvFromS0 (S)
local StartN = 1
ColorName, IsInv, StartN = p.ColorNameInvStartFromS (S)
return ColorName, IsInv, StartN
end --ColorNameInv
function p.ShowColors(frame)
local args = ARG.getArgs(frame,{
removeBlanks = false
});
local ColorName, IsInv, StartN = ColorNameInv (args)
local N = tonumber(args[2])
local WriteColor = args[3] or ""
local ColorFound = {}
ColorFound = p.GetColors (ColorName, IsInv, StartN, N, true)
local boxes = {}
for i=1, table.getn(ColorFound) do
table.insert(boxes, CFCM.Box(ColorFound[i],WriteColor))
end
return table.concat(boxes, " ")
end --ShowColors
function p.Legends(frame)
local args = ARG.getArgs(frame,{
removeBlanks = false
})
local Nargs = require("Modul:TableTools").length(args)
local ColorName, IsInv, StartN = ColorNameInv (args)
local N = tonumber(args[2])
local ColWidth = args[3]
local ColorFound = {}
local Labels = {}
local NLabels = 0
local IsTemplate = true
ColorFound = p.GetColors (ColorName, IsInv, StartN, N, true)
Labels, NLabels, OutlineColor = CFCM.GetLabels (args, N, 4)
return CFCM.LegendText (ColorFound, Labels, NLabels, ColWidth, IsTemplate, OutlineColor)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.
Index:
pl ar de en es fr it arz nl ja pt ceb sv uk vi war zh ru af ast az bg zh-min-nan bn be ca cs cy da et el eo eu fa gl ko hi hr id he ka la lv lt hu mk ms min no nn ce uz kk ro simple sk sl sr sh fi ta tt th tg azb tr ur zh-yue hy my ace als am an hyw ban bjn map-bms ba be-tarask bcl bpy bar bs br cv nv eml hif fo fy ga gd gu hak ha hsb io ig ilo ia ie os is jv kn ht ku ckb ky mrj lb lij li lmo mai mg ml zh-classical mr xmf mzn cdo mn nap new ne frr oc mhr or as pa pnb ps pms nds crh qu sa sah sco sq scn si sd szl su sw tl shn te bug vec vo wa wuu yi yo diq bat-smg zu lad kbd ang smn ab roa-rup frp arc gn av ay bh bi bo bxr cbk-zam co za dag ary se pdc dv dsb myv ext fur gv gag inh ki glk gan guw xal haw rw kbp pam csb kw km kv koi kg gom ks gcr lo lbe ltg lez nia ln jbo lg mt mi tw mwl mdf mnw nqo fj nah na nds-nl nrm nov om pi pag pap pfl pcd krc kaa ksh rm rue sm sat sc trv stq nso sn cu so srn kab roa-tara tet tpi to chr tum tk tyv udm ug vep fiu-vro vls wo xh zea ty ak bm ch ny ee ff got iu ik kl mad cr pih ami pwn pnt dz rmy rn sg st tn ss ti din chy ts kcg ve









