From c6fc669a706d55705c97f5892fac55ef4707b435 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Fri, 4 Dec 2026 12:07:22 +1300 Subject: [PATCH 1/2] New version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2062f7b..8bdeb07 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ ], "type": "module", "types": "dist/index.d.ts", - "version": "0.20261204.0", + "version": "0.20261204.1", "exports": { ".": { "types": "./dist/index.d.ts", From 1efaf947bf09f9f52a439f0ff867c63d7672fc00 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Fri, 4 Dec 2026 12:07:15 +1300 Subject: [PATCH 2/2] Added support for a plot title, at the top, left, right, or bottom of the plot. --- README.md | 9 +- demo/App.vue | 30 ++- index.ts | 1 + src/common/alignUtils.test.ts | 75 ++++++ src/common/alignUtils.ts | 50 +++- src/widgets/PlotWidget.vue | 418 +++++++++++++++++++++++++++++----- 6 files changed, 509 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index d713f48..f679a8c 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,8 @@ The component is the default export of `@opencor/plot`, and is also exported as | Type | Definition | Description | |---|---|---| -| `PlotData` | `{ traces, xAxis?, yAxis? }` | The data to plot (see [Data](#data)). | +| `PlotData` | `{ traces, title?, titlePosition?, xAxis?, yAxis? }` | The data to plot (see [Data](#data)). | +| `PlotTitlePosition` | `'top' \| 'left' \| 'right' \| 'bottom'` | Where the title of the plot is (see [Data](#data)). | | `PlotAxis` | `{ title?, range?, grid?, log? }` | An axis of the plot (see [Data](#data)). | | `PlotTrace` | `{ name, x, y, xValue, yValue, line?, marker?, traceId?, legendRank?, runLabel? }` | A trace to plot (see [Data](#data)). | | `PlotLineStyle` | `{ type?, color?, thickness? }` | The style of the line of a trace (see [Data](#data)). | @@ -109,6 +110,8 @@ The component is the default export of `@opencor/plot`, and is also exported as | Property | Type | Description | |---|---|---| | `traces` | [`PlotTrace`](#types)`[]` | The traces to plot. | +| `title` | `string` | The title of the plot. | +| `titlePosition` | [`PlotTitlePosition`](#types) | Where the title of the plot is: above the plot (`'top'`, the default) or below it (`'bottom'`), centred on its plotting area, or to its left (`'left'`), centred on its plotting area and reading from bottom to top (like the title of the Y axis), or to its right (`'right'`, i.e. between its plotting area and its legend), centred on its plotting area and reading from top to bottom. | | `xAxis`, `yAxis` | [`PlotAxis`](#types) | The axes. | [`PlotAxis`](#types): @@ -216,7 +219,7 @@ Also set the [`live`](#props) prop while the data is live, so that the last poin ### Several plots Plots can be shown together (e.g., stacked or side by side) and made to work as one, using a [`PlotGroup`](#types), i.e. a string or a symbol, which all the plots of a group share: -- **Aligned axes:** the plots of an [`xAxisAlign`](#props) group get the same left and right margins, so that their plotting areas line up when they are stacked, while those of a [`yAxisAlign`](#props) group get the same top and bottom margins, so that their plotting areas line up when they are side by side. +- **Aligned axes:** the plots of an [`xAxisAlign`](#props) group get the same left and right margins, so that their plotting areas line up when they are stacked, while those of a [`yAxisAlign`](#props) group get the same top and bottom margins, so that their plotting areas line up when they are side by side. This is also the case if some of them have a title and others don't, or if their titles are at different positions. In that case, a plot leaves room for the title of the plots that have one on the left (or right), so that its Y axis title (or legend) lines up with theirs. - **Synchronised axes:** the plots of an [`xAxisSync`](#props) (or [`yAxisSync`](#props)) group share the range and the scale (i.e. linear or logarithmic) of their X (or Y) axis. Zooming, panning, or resetting the zoom of one of them, or making its axis logarithmic (or not), does the same to the others, be it done by the user or using [`setRanges()`](#methods). Until one of them gets zoomed or panned, their axes fit the data of all of them. With a synchronised X axis, hovering one of them also shows the hover guide and tooltip of the others, at the same X value (or, for a plot that has no point there, at its closest point, as when it is hovered itself). Aligning and synchronising are independent of each other: plots can be aligned without being synchronised (e.g., when they show different X values), and synchronised without being aligned (e.g., when they are not shown next to each other). A plot can also be in different groups for its X and Y axes, and the groups of X axes are separate from those of Y axes, so the same group can be used for both. @@ -390,7 +393,7 @@ Set any of these CSS variables on an ancestor of the component. Each has a light | Variable | Used for | |---|---| | `--opencor-plot-background` | The background of the plot. | -| `--opencor-plot-text-color` | The axis titles, the legend, and the ring around the last point of a live trace. | +| `--opencor-plot-text-color` | The plot and axis titles, the legend, and the ring around the last point of a live trace. | | `--opencor-plot-muted-text-color` | Tick labels, the hover guide line, hidden traces in the legend, and secondary text in overlays. | | `--opencor-plot-primary-color` | The zoom box (and, by default, the keyboard focus ring). | | `--opencor-plot-grid-color` | Grid lines. | diff --git a/demo/App.vue b/demo/App.vue index 4ba8004..9fcbf41 100644 --- a/demo/App.vue +++ b/demo/App.vue @@ -148,6 +148,12 @@ +