ADD framework for setting plot height/width

This commit is contained in:
Nathan Dwarshuis 2022-08-09 17:39:49 -04:00
parent d4a5b74a52
commit 4877eece30
3 changed files with 27 additions and 3 deletions

View File

@ -33,6 +33,8 @@ theme:
plot: plot:
seconds: 90 seconds: 90
ticks: [9, 4] ticks: [9, 4]
height: 56
spacing: 20
table: table:
name_chars: 8 name_chars: 8
padding: [6, 15] padding: [6, 15]

View File

@ -224,9 +224,17 @@ properties:
additionalProperties: false additionalProperties: false
properties: properties:
plot: plot:
required: [seconds, ticks] required: [seconds, ticks, height, spacing]
additionalProperties: false additionalProperties: false
properties: 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: seconds:
description: the number of seconds on each timeseries plot description: the number of seconds on each timeseries plot
type: integer type: integer

View File

@ -51,6 +51,18 @@ return function(config)
local DIAL_THETA0 = 90 local DIAL_THETA0 = 90
local DIAL_THETA1 = 360 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 -- line helper functions
@ -128,6 +140,8 @@ return function(config)
) )
end end
local gplot = geometry.plot
local _make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, update_freq, _format) local _make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, update_freq, _format)
return { return {
label = _left_text(geom.make_point(x, y), label), label = _left_text(geom.make_point(x, y), label),
@ -140,9 +154,9 @@ return function(config)
), ),
plot = M.make_percent_timeseries( plot = M.make_percent_timeseries(
x, x,
y + spacing, y + _maybe_config(gplot.spacing, spacing),
w, w,
h, _maybe_config(gplot.height, h),
update_freq update_freq
), ),
} }