From 0e0522175434a108e71fa808b08b3bb9ff1eef88 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 1 Dec 2026 17:22:01 +1300 Subject: [PATCH 01/12] New version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 590adcc..9206471 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ ], "type": "module", "types": "dist/index.d.ts", - "version": "0.20261127.0", + "version": "0.20261201.0", "exports": { ".": { "types": "./dist/index.d.ts", From 38c497c30f1b96dc808ce6f8dccf45895b0732df Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 1 Dec 2026 12:49:01 +1300 Subject: [PATCH 02/12] Plot: replaced the `margins` prop and `marginsUpdated` event with an `xAxisAlign` prop. --- README.md | 5 +- demo/App.vue | 39 ++---- demo/data.ts | 2 +- index.ts | 1 - src/common/alignUtils.test.ts | 252 ++++++++++++++++++++++++++++++++++ src/common/alignUtils.ts | 155 +++++++++++++++++++++ src/widgets/PlotWidget.vue | 150 ++++++++------------ 7 files changed, 476 insertions(+), 128 deletions(-) create mode 100644 src/common/alignUtils.test.ts create mode 100644 src/common/alignUtils.ts diff --git a/README.md b/README.md index c0dfac2..4fe8e02 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,6 @@ The component is the default export of `@opencor/plot`, and is also exported as |---|---|---| | `PlotData` | `{ traces, xAxisTitle?, yAxisTitle?, xAxisRange?, yAxisRange? }` | The data to plot (see [Data](#data)). | | `PlotTrace` | `{ name, x, y, xValue, yValue, color, traceId?, legendRank?, runLabel? }` | A trace to plot (see [Data](#data)). | -| `PlotMargins` | `{ left: number; right: number }` | The left and right margins (in pixels) of a plot, i.e. the space taken by its Y axis and legend (see the [`margins`](#props) prop and the [`marginsUpdated`](#events) event). | | `PlotTheme` | `'system' \| 'light' \| 'dark'` | The value of the [`theme`](#props) prop. | | `PlotCsvExportEvent` | `PlotCsvExportStartedEvent \| PlotCsvExportProgressEvent \| PlotCsvExportFinishedEvent` | The payload of the [`csvExport`](#events) event. Use its `type` to tell which one it is. | | `PlotCsvExportStartedEvent` | `{ type: 'started' }` | An export to CSV has started. | @@ -145,7 +144,7 @@ Also set the [`live`](#props) prop while the data is live, so that the last poin | `data` | [`PlotData`](#types) | (required) | The data to plot. | | `showLegend` | `boolean` | `true` | Whether to show the legend. The legend takes at most 40% of the width of the plot (with long trace names truncated, and shown in full when hovered or in the context menu of their legend item), and is hidden if the plot is too narrow for it to be useful. | | `theme` | [`PlotTheme`](#types) | `'system'` | Whether to use light or dark mode, or whatever the system uses. | -| `margins` | [`PlotMargins`](#types) | | Margins shared with other plots, so that their plotting areas line up (see [`marginsUpdated`](#events)). | +| `xAxisAlign` | `string \| symbol` | | The group of plots whose X axes are to line up with this plot's, i.e. whose plotting areas are to have the same left and right edges (e.g., when they are stacked). A symbol is unique, so that unrelated parts of a page can't end up in the same group by using the same string. | | `appendTo` | `HTMLElement \| string` | `body` | Where to append our overlays (context menu, hover tooltip, etc.). | | `customContextMenu` | `boolean` | `false` | Whether to emit a [`contextMenu`](#events) event rather than show our own context menu. To have no context menu at all, set it and don't handle the `contextMenu` event. | | `levelOfDetail` | `boolean` | `true` | Whether to only go through the points that are needed for a trace to look the same when drawing it (see [Large and live data](#large-and-live-data)). Hovering a trace whose X values are sorted always does. Only meant to be disabled to see how much it helps. | @@ -157,7 +156,6 @@ To draw traces without our level of detail, use `:levelOfDetail="false"`. Our pa | Event | Payload | Description | |---|---|---| -| `marginsUpdated` | [`PlotMargins`](#types) | The margins that the plot needs have changed. To line up several plots, pass the largest left and right margins of all of them to each plot's [`margins`](#props) prop. | | `csvExport` | [`PlotCsvExportEvent`](#types) | An export to CSV has `'started'`, made `'progress'` (with a `percent`), or `'finished'` (with whether it was a `success`), so that its progress can be shown. | | `imageExport` | [`PlotImageExportEvent`](#types) | The plot has been copied to the clipboard or exported to an image (or has failed to be), so that the user can be told about it. | | `contextMenu` | [`PlotContextMenuEvent`](#types) | Only with [`customContextMenu`](#props): the context menu was requested at `clientX`/`clientY`, with the `items` that our context menu would have shown. If `usingKeyboard` is true, the custom menu should take the keyboard focus. The custom menu should call the `command` of the chosen item while handling the click (or tap, or key press) that chose it, and it shouldn't move the keyboard focus afterwards (calling [`contextMenuHidden()`](#methods) instead), since some commands (e.g., to edit the range of an axis) give the keyboard focus to an editor that closes when it loses it, and iOS only shows its virtual keyboard for such an editor while handling a user interaction. If it calls that `command` while handling a key press (e.g., Enter or Space), it should also prevent that key's default action (using `preventDefault()`), since the key would otherwise also be typed into such an editor, replacing its selected value. | @@ -168,7 +166,6 @@ Available through a template ref: | Method | Description | |---|---| -| `resetMargins()` | Emit [`marginsUpdated`](#events) again, e.g. after the shared margins have been reset. | | `contextMenuHidden()` | Tell the plot that a custom context menu (see [`contextMenu`](#events)) has been hidden, so that it can get the keyboard focus back (unless something else, e.g. an editor opened by the chosen item, has it). | | `pointCounts()` | The number of points of the visible traces (`nbOfPoints`), and how many of them were last drawn (`nbOfDrawnPoints`), as a [`PlotPointCounts`](#types). Meant for testing and benchmarking. | | `memoryUsage()` | The memory (in bytes) used by the component itself, not counting the data, as a [`PlotMemoryUsage`](#types): by its levels of detail (`levelOfDetail`) and by the logarithm of its values along logarithmic axes (`logValues`). Meant for testing and benchmarking. | diff --git a/demo/App.vue b/demo/App.vue index ed384d6..176381b 100644 --- a/demo/App.vue +++ b/demo/App.vue @@ -9,10 +9,9 @@ :live="liveRunning" :showLegend="showLegend" :customContextMenu="customContextMenu" - :margins="sharedMargins ? margins : undefined" + :xAxisAlign="alignedXAxes ? ALIGN_GROUP : undefined" @contextMenu="(event) => onContextMenu(event, index)" @csvExport="onCsvExport" - @marginsUpdated="(newMargins) => onMarginsUpdated(newMargins, index)" /> @@ -113,8 +112,8 @@ + + +