major rework
- modified chartjs for better zoom on touchpad - flexible number of charts - handle bool as checkbox - handle enum as select (pull down menu) - disable swiper where not needed and many more
This commit is contained in:
38
histgraph.py
38
histgraph.py
@@ -117,31 +117,28 @@ def get_vars(main, time):
|
||||
|
||||
time, = get_abs_time(time)
|
||||
# get last value only
|
||||
curves = main.get_curves(['$vars'], (time, time))
|
||||
for _, value in curves['$vars'].get():
|
||||
for var in value.split():
|
||||
vars = var.split("|")
|
||||
if len(vars) == 1:
|
||||
vars.append("")
|
||||
if len(vars) == 2:
|
||||
vars.append(vars[0])
|
||||
if len(vars) == 3:
|
||||
vars.append("")
|
||||
if len(vars) == 4:
|
||||
vars.append("") # exact flag
|
||||
name, unit, label, color, continuous = vars
|
||||
continuous = int(continuous) if continuous else 0
|
||||
if not unit in result:
|
||||
result[unit] = dict(tag=unit, unit=unit.split("_")[0], curves=Dict())
|
||||
result[unit]["curves"][name] = dict(name=name, label=label, color=color, continuous=continuous)
|
||||
curves = main.get_curve_options((time, time))
|
||||
for key, opts in curves.items():
|
||||
if not opts.get('show', False):
|
||||
continue
|
||||
print(key, opts)
|
||||
opts = dict(name=key, **opts)
|
||||
unit = opts.pop('unit', '*')
|
||||
tag = opts.pop('tag', unit)
|
||||
if not tag in result:
|
||||
result[tag] = dict(tag=tag, unit=unit, curves=Dict())
|
||||
if 'label' not in opts:
|
||||
opts['label'] = opts['name']
|
||||
result[tag]["curves"][key] = opts
|
||||
|
||||
for unit, curvegroup in result.items():
|
||||
# determine colors
|
||||
for _, curvegroup in result.items():
|
||||
color_set = set()
|
||||
auto_curves = []
|
||||
curve_list = list(curvegroup["curves"].values())
|
||||
curvegroup['curves'] = curve_list
|
||||
for curve in curve_list:
|
||||
col = curve["color"].strip()
|
||||
col = curve.get("color", '').strip()
|
||||
c = ColorMap.to_code(col)
|
||||
if c < 0:
|
||||
valid = ColorMap.check_hex(col)
|
||||
@@ -166,8 +163,9 @@ def get_vars(main, time):
|
||||
|
||||
def get_curves(main, keys, timerange, cut_begin=True):
|
||||
curves = main.get_curves(keys, get_abs_time(*timerange), maxpoints=500, cut_begin=cut_begin)
|
||||
opts = main.get_curve_options(timerange, keys)
|
||||
#if 'tt:target' in curves:
|
||||
# print('---')
|
||||
# print(curves['tt:target'].fmtm())
|
||||
# print('TT', curves['tt:target'].for_json()[-5:])
|
||||
return {k: c.for_json() for k, c in curves.items()}
|
||||
return {k: c.for_json(opts.get(k, {}).get('period', 0)) for k, c in curves.items()}
|
||||
|
||||
Reference in New Issue
Block a user