Extend semiplot_tags for pen settings and add group tables

Open
#9 1 comment 0 reactions 1 assignee View on GitHub

@mrcsin is already working on this.

Since Sep 10, 2026.

Assessment

This issue has not been assessed yet.

Description

enhancement

Today

semiplot_tags is the one object SemiBase adds beside the archive (sql/semiplot_tags.sql:6-13):

CREATE TABLE IF NOT EXISTS semiplot_tags (
	id         integer PRIMARY KEY,   -- matches trends.id
	name       text    NOT NULL,
	group_name text,
	unit       text,
	color      text,
	line_style smallint NOT NULL DEFAULT 0
);

group_name holds one string per pen. There is no place for a pen's own scale, no stored visibility, and a pen cannot belong to two groups.

Wanted

One pen row holds everything the viewer needs to draw and label the pen. Groups become their own table so a pen can sit in several.

Columns added to semiplot_tags:

Column Type Meaning
enabled boolean NOT NULL DEFAULT true drawn when the viewer starts
scale_min double precision lower bound of the pen's Y axis; NULL means autoscale
scale_max double precision upper bound; NULL means autoscale

Existing columns keep their meaning. unit is free text (Pa, C, mbar, sccm, W, %). color is #RRGGBB. line_style is 0 interpolated, 1 stepped. group_name is replaced by the tables below.

CREATE TABLE semiplot_groups (
	id   integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
	name text NOT NULL UNIQUE
);

CREATE TABLE semiplot_pen_groups (
	pen_id   integer NOT NULL REFERENCES semiplot_tags (id) ON DELETE CASCADE,
	group_id integer NOT NULL REFERENCES semiplot_groups (id) ON DELETE CASCADE,
	PRIMARY KEY (pen_id, group_id)
);

Constraints: scale_min < scale_max when both are set, color matches ^#[0-9A-Fa-f]{6}$ or is NULL.

Migration runs inside provision and stays idempotent like the rest of it: ADD COLUMN IF NOT EXISTS, CREATE TABLE IF NOT EXISTS, one statement turning every distinct non-empty group_name into a semiplot_groups row with its links, then DROP COLUMN group_name. SemiPlot is the only reader and moves in the same release (Semiteq/SemiPlot#65), so no compatibility column stays behind.

Grants: SELECT to semiplot_reader on all three tables, full DML to semiplot_writer (#8).

Add the semiplot_meta table SemiPlot's docs already reserve for exactly this (SemiPlot docs/architecture/postgres-instance.md:79-81), holding one schema_version integer. The viewer then refuses an older database with a clear message instead of failing on a missing column.

Notes

  • Y axes on the SemiPlot side become one per pen. unit is a label suffix, never an axis key. Group membership drives legend headers and bulk on/off only.
  • A pen with no group row is legal and shows under an "Ungrouped" header.
  • The SemiPlot bench seeder fills these tables; that half is Semiteq/SemiPlot#65. This issue covers DDL, migration, grants and docs.
Dominant language
Go
Stars
0
Forks
0
Avg merge
21h 58m
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Semiteq/SemiBase

All issues in Semiteq/SemiBase

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.