summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv60
1 files changed, 7 insertions, 53 deletions
diff --git a/Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv b/Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv
index e218e6110b4..d8b6e2ff6cd 100644
--- a/Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv
+++ b/Master/texmf-dist/tex/context/modules/mkiv/s-youless.mkiv
@@ -33,26 +33,7 @@
moduledata.youless = { }
- local defaults = {
- electricity = {
- unit = "watt",
- maxunit = "maxwatt",
- },
- watt = {
- unit = "watt",
- maxunit = "maxwatt",
- },
- pulse = {
- unit = "watt",
- maxunit = "maxwatt",
- },
- gas = {
- unit = "liters",
- maxunit = "maxliters",
- },
- }
-
- local function process(specification,thevariant)
+ local function process(specification)
local data, message = utilities.youless.analyze(specification.filename or "youless-electricity.lua")
@@ -61,32 +42,12 @@
return
end
+ local year = tonumber(specification.year) or os.today().year
+ local years = data.years
local variant = data.variant
local unit = specification.unit
local maxunit = specification.maxunit
- if thevariant then
- if variant ~= thevariant then
- context("invalid variant")
- return
- end
- elseif variant then
- local d = defaults[variant]
- if d then
- unit = d.unit
- maxunit = d.maxunit
- else
- context("unknown variant")
- return
- end
- else
- context("invalid variant")
- return
- end
-
- local year = tonumber(specification.year) or os.today().year
- local month = tonumber(specification.month)
- local years = data.years
local max = specification[maxunit]
if not max then
@@ -99,19 +60,16 @@
end
end
- local firstmonth = month or 1
- local lastmonth = month or 12
-
local max = max
local delta = round(max/10)
local scale = round(delta/20)
local mark = 3
for y=year,year do
- local year = years[y]
+ local year = years[y]
if year then
local grand = 0
- for m=firstmonth,lastmonth do
+ for m=1,12 do
local month = year.months[m]
if month then
context.startMPpage { offset = "10pt" }
@@ -209,7 +167,7 @@
function moduledata.youless.electricity(specification)
specification.unit = "watt"
specification.maxunit = "maxwatt"
- process(specification,"electricity")
+ process(specification)
end
moduledata.youless.watt = moduledata.youless.electricity
@@ -217,16 +175,12 @@
function moduledata.youless.gas(specification)
specification.unit = "liters"
specification.maxunit = "maxliters"
- process(specification,"gas")
+ process(specification)
end
function moduledata.youless.pulse(specification)
specification.unit = "watt"
specification.maxunit = "maxwatt"
- process(specification,"pulse")
- end
-
- function moduledata.youless.graphics(specification)
process(specification)
end