From 4877eece3072711ff6ec06f951084415cc27513d Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Tue, 9 Aug 2022 17:39:49 -0400 Subject: [PATCH] ADD framework for setting plot height/width --- config/fallback.yml | 2 ++ config/schema.yml | 10 +++++++++- src/modules/common.lua | 18 ++++++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/config/fallback.yml b/config/fallback.yml index 5521547..3033939 100644 --- a/config/fallback.yml +++ b/config/fallback.yml @@ -33,6 +33,8 @@ theme: plot: seconds: 90 ticks: [9, 4] + height: 56 + spacing: 20 table: name_chars: 8 padding: [6, 15] diff --git a/config/schema.yml b/config/schema.yml index 5a07b27..1419fdd 100644 --- a/config/schema.yml +++ b/config/schema.yml @@ -224,9 +224,17 @@ properties: additionalProperties: false properties: plot: - required: [seconds, ticks] + required: [seconds, ticks, height, spacing] additionalProperties: false properties: + spacing: + description: the spacing between the label and the plot + type: integer + minimum: 10 + height: + description: the height of the plot + type: integer + minimum: 10 seconds: description: the number of seconds on each timeseries plot type: integer diff --git a/src/modules/common.lua b/src/modules/common.lua index e2b97d4..7275d94 100644 --- a/src/modules/common.lua +++ b/src/modules/common.lua @@ -51,6 +51,18 @@ return function(config) local DIAL_THETA0 = 90 local DIAL_THETA1 = 360 + ----------------------------------------------------------------------------- + -- config helper functions + + -- ASSUME anything set in the yaml file as 'null' will come out as a '{}' + local _maybe_config = function(default, x) + if x == {} then + return default + else + return x + end + end + ----------------------------------------------------------------------------- -- line helper functions @@ -128,6 +140,8 @@ return function(config) ) end + local gplot = geometry.plot + local _make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, update_freq, _format) return { label = _left_text(geom.make_point(x, y), label), @@ -140,9 +154,9 @@ return function(config) ), plot = M.make_percent_timeseries( x, - y + spacing, + y + _maybe_config(gplot.spacing, spacing), w, - h, + _maybe_config(gplot.height, h), update_freq ), }