diff --git a/README.md b/README.md index e9002b0..f3e419e 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,7 @@ License: MIT

-**Documentation: [powershell-universal-components.eize.dev](https://powershell-universal-components.eize.dev/)**: every module, parameter and chart type, with live examples. - -Supported and tested versions: [Requirements](https://powershell-universal-components.eize.dev/#requirements). +**[Documentation](https://powershell-universal-components.eize.dev/)** · [Getting started](https://powershell-universal-components.eize.dev/getting-started/) · [Requirements](https://powershell-universal-components.eize.dev/#requirements) · [Releases](https://github.com/eizedev/powershell-universal-components/releases) > [!NOTE] > The modules are 0.x. A minor release can break things, so read the module's `CHANGELOG.md` before @@ -30,7 +28,7 @@ Supported and tested versions: [Requirements](https://powershell-universal-compo ### ECharts -ECharts: a service review page with a KPI matrix of sparklines and bar charts +ECharts: monthly mean temperature of six cities in 2024 and 2025 as lines, with a zoom slider `New-UDEChart` draws 29 [Apache ECharts](https://echarts.apache.org/) chart types, from bars and lines to gantt charts, network graphs, and KPI matrices. Clicks filter other elements. Readers zoom, export, and go full screen. @@ -40,9 +38,9 @@ charts, network graphs, and KPI matrices. Clicks filter other elements. Readers ### Pivot -Pivot: report builder with field list, zones and a table +Pivot: mean temperature per month and city of six cities as a colour scale from blue to orange, with the tabs Table, Chart and Both -`New-UDPivotReport` is a pivot report builder on [pivotkit](https://github.com/eizedev/pivotkit). Readers drag +`New-UDPivotReport` is a pivot report builder on [pivotkit](https://pivotkit.eize.dev/) ([live demo](https://pivotkit.eize.dev/demo/)). Readers drag fields into rows, columns, values and filters and get a table or a chart. They save views and export to Excel. - [Docs](https://powershell-universal-components.eize.dev/pivot/) · [PowerShell Gallery](https://www.powershellgallery.com/packages/PowerShellUniversal.Component.Pivot) @@ -50,7 +48,7 @@ fields into rows, columns, values and filters and get a table or a chart. They s ### Perspective -Perspective: datagrid grouped and split by the reader +Perspective: a bar chart of the mean temperature of six cities, with the toolbar Edit view, Table and Chart `New-UDPerspective` is the [Perspective](https://perspective-dev.github.io/) datagrid, pivot table, and WebGL charts in one. Readers group, split, filter, and sort. A WebAssembly engine handles large row counts. @@ -106,4 +104,5 @@ Contributors and coding agents: [PRODUCT.md](PRODUCT.md), [AGENTS.md](AGENTS.md) [MIT](LICENSE). Bundled libraries keep their own licenses. The build writes their texts into each module's `THIRD-PARTY-NOTICES.txt`. Icon, header and social preview in `assets/` are generated in [eizedev/brand](https://github.com/eizedev/brand) -and licensed [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). +and licensed [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The weather in the screenshots: data by +[Open-Meteo.com](https://open-meteo.com/), [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), with modified Copernicus Climate Change Service information ([sources](docs/site/data/SOURCES.md)). diff --git a/build/growth-baseline.json b/build/growth-baseline.json index 3819012..ef92735 100644 --- a/build/growth-baseline.json +++ b/build/growth-baseline.json @@ -1,9 +1,9 @@ { "docs": { "pages": { - "README.md": [109] + "README.md": [108] }, - "totalLines": 4358 + "totalLines": 4369 }, "javascript": { "complexity": { @@ -22,7 +22,7 @@ }, "powershell": { "files": { - "docs/site/examples.ps1": [510], + "docs/site/examples.ps1": [552], "modules/PowerShellUniversal.Component.ECharts.Demo/Apps/Showcase.ps1": [1330], "modules/PowerShellUniversal.Component.Pivot.Demo/Apps/Showcase.ps1": [305], "tests/powershell/Pivot.Tests.ps1": [521], diff --git a/docs/assets/echarts-weather-dark.png b/docs/assets/echarts-weather-dark.png new file mode 100644 index 0000000..5c64a67 Binary files /dev/null and b/docs/assets/echarts-weather-dark.png differ diff --git a/docs/assets/echarts-weather-light.png b/docs/assets/echarts-weather-light.png new file mode 100644 index 0000000..6527b15 Binary files /dev/null and b/docs/assets/echarts-weather-light.png differ diff --git a/docs/assets/perspective-weather-dark.png b/docs/assets/perspective-weather-dark.png new file mode 100644 index 0000000..1213f7e Binary files /dev/null and b/docs/assets/perspective-weather-dark.png differ diff --git a/docs/assets/perspective-weather-light.png b/docs/assets/perspective-weather-light.png new file mode 100644 index 0000000..b1277ea Binary files /dev/null and b/docs/assets/perspective-weather-light.png differ diff --git a/docs/assets/pivot-report-dark.png b/docs/assets/pivot-report-dark.png deleted file mode 100644 index dcdf46a..0000000 Binary files a/docs/assets/pivot-report-dark.png and /dev/null differ diff --git a/docs/assets/pivot-report-light.png b/docs/assets/pivot-report-light.png deleted file mode 100644 index 70e434a..0000000 Binary files a/docs/assets/pivot-report-light.png and /dev/null differ diff --git a/docs/assets/pivot-weather-dark.png b/docs/assets/pivot-weather-dark.png new file mode 100644 index 0000000..7f23528 Binary files /dev/null and b/docs/assets/pivot-weather-dark.png differ diff --git a/docs/assets/pivot-weather-light.png b/docs/assets/pivot-weather-light.png new file mode 100644 index 0000000..6c76474 Binary files /dev/null and b/docs/assets/pivot-weather-light.png differ diff --git a/docs/development/index.md b/docs/development/index.md index dc715dc..fc24ebe 100644 --- a/docs/development/index.md +++ b/docs/development/index.md @@ -51,11 +51,11 @@ of these sections; `tests/js/llms-sections.test.js` fails otherwise. | --- | --- | | An example's text | `Text` in `examples.ps1`; parameters (`-View`), commands (`New-UDDynamic`) and variables (`$EventData`) become code. | | An example as a whole app | `App` in `examples.ps1` (the app's title): the page shows the code once more inside `New-UDApp -Content { }`. | -| Public data in an example | `Invoke-RestMethod` with the real address; the build answers it from the snapshot in `docs/site/data//`, so it needs no network. `docs/site/Update-Data.ps1` fetches the snapshots again; sources, licences and the attribution each source asks for (`Source` in `examples.ps1`, shown under the example) are in [data/SOURCES.md](https://github.com/eizedev/powershell-universal-components/blob/HEAD/docs/site/data/SOURCES.md). | +| Public data in an example | `Invoke-RestMethod` with the real address; the build answers it from the snapshot in `docs/site/data//` (for an address with a query string, the file `data/Addresses.psd1` names), so it needs no network. `docs/site/Update-Data.ps1` fetches the snapshots again; sources, licences and the attribution each source asks for (`Source` in `examples.ps1`, shown under the example) are in [data/SOURCES.md](https://github.com/eizedev/powershell-universal-components/blob/HEAD/docs/site/data/SOURCES.md). | | The pivot showcase app | Runs the pivot examples of `examples.ps1` and reads the snapshots in `docs/site/data/` (`Addresses.psd1` holds the exact address of a snapshot whose address has a query string); `Build.psd1` of the demo module copies both into it, so a change of an example or a snapshot reaches the app with its next release. | | What PSU provides | Stubs in `Build-Site.ps1`: the `[Endpoint]` type, `New-UDDynamic` (draws its `-Content`), a signed-in reader with the role `Administrator` (`$User`, `$Roles`) and `$Repository`. | | The pivot report on a page | Drawn into a shadow root of its placeholder, with the module's stylesheets inside it, so the page's typography stays outside. | -| The pivot screenshots of the start page | `node docs/site/screenshots.mjs ` on the built and served site, light and dark, into `docs/assets/`. | +| The screenshots of the README and the start page (`echarts-weather-*`, `perspective-weather-*`, `pivot-weather-*`) | `node docs/site/screenshots.mjs ` on the built and served site, light and dark, into `docs/assets/`. | | The Pivot showcase screenshots (`pivot-showcase-*`) | `PSU_PIVOT_DEMO_URL= node docs/site/screenshots.mjs` against `New-UDPivotShowcase` on a PSU instance, light and dark, into `docs/assets/`. | ## Browser tests on PSU diff --git a/docs/echarts/lines-and-time.md b/docs/echarts/lines-and-time.md index df8810d..619afb7 100644 --- a/docs/echarts/lines-and-time.md +++ b/docs/echarts/lines-and-time.md @@ -8,6 +8,10 @@ lines, `-SecondaryY` puts named series on a second axis, `-LogScale` makes the v --8<-- "examples/time-axis-with-zoom-and-a-reference-line.md" +## Temperature of six cities + +--8<-- "examples/temperature-of-six-cities.md" + ## Reference lines and pins `-MarkLine 'median', 'average'` per series, or fixed lines: `@{ value = 48; name = 'SLA'; color = '#e53935' }` diff --git a/docs/index.md b/docs/index.md index 471b181..235f1e3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,8 +35,8 @@ Install-PSResource -Name PowerShellUniversal.Component.ECharts In the PowerShell Gallery: [PowerShellUniversal.Component.ECharts](https://www.powershellgallery.com/packages/PowerShellUniversal.Component.ECharts). -![The quick start app in the light theme: stacked bars of PowerShell commands per verb, cmdlets and functions](assets/images/screenshot-quickstart-light.png#only-light) -![The quick start app in the dark theme: stacked bars of PowerShell commands per verb, cmdlets and functions](assets/images/screenshot-quickstart-dark.png#only-dark) +![ECharts in the light theme: monthly mean temperature of six cities in 2024 and 2025 as lines, with a zoom slider](assets/echarts-weather-light.png#only-light) +![ECharts in the dark theme: monthly mean temperature of six cities in 2024 and 2025 as lines, with a zoom slider](assets/echarts-weather-dark.png#only-dark) [ECharts overview](echarts/index.md){ .md-button .md-button--primary } [Showcase app (demo)](demo.md){ .md-button title="PowerShellUniversal.Component.ECharts.Demo: 14 pages of New-UDEChart examples" } @@ -53,8 +53,8 @@ Install-PSResource -Name PowerShellUniversal.Component.Perspective In the PowerShell Gallery: [PowerShellUniversal.Component.Perspective](https://www.powershellgallery.com/packages/PowerShellUniversal.Component.Perspective). -![The Perspective viewer in the light theme with its toolbar: Edit view, Table and Chart](assets/perspective-viewer-1-light.png#only-light) -![The Perspective viewer in the dark theme with its toolbar: Edit view, Table and Chart](assets/perspective-viewer-1-dark.png#only-dark) +![The Perspective viewer in the light theme: a bar chart of the mean temperature of six cities, with the toolbar Edit view, Table and Chart](assets/perspective-weather-light.png#only-light) +![The Perspective viewer in the dark theme: a bar chart of the mean temperature of six cities, with the toolbar Edit view, Table and Chart](assets/perspective-weather-dark.png#only-dark) [Perspective overview](perspective/index.md){ .md-button .md-button--primary } [Using the viewer](perspective/using.md){ .md-button } @@ -77,10 +77,10 @@ New-UDPivotReport -Id 'python' -Data (Invoke-RestMethod 'https://endoflife.date/ In the PowerShell Gallery: [PowerShellUniversal.Component.Pivot](https://www.powershellgallery.com/packages/PowerShellUniversal.Component.Pivot). -![The pivot report in the light theme: release cycles of nine products from endoflife.date per product and LTS, with the field list and the admin panel](assets/pivot-report-light.png#only-light) -![The pivot report in the dark theme: release cycles of nine products from endoflife.date per product and LTS, with the field list and the admin panel](assets/pivot-report-dark.png#only-dark) +![The pivot report in the light theme: mean temperature per month and city of six cities as a colour scale, with the tabs Table, Chart and Both](assets/pivot-weather-light.png#only-light) +![The pivot report in the dark theme: mean temperature per month and city of six cities as a colour scale, with the tabs Table, Chart and Both](assets/pivot-weather-dark.png#only-dark) -Release data by [endoflife.date](https://endoflife.date/), MIT licence, Copyright 2020 endoflife.date contributors ([sources and licence](https://github.com/eizedev/powershell-universal-components/blob/HEAD/docs/site/data/SOURCES.md)). +The pictures on this page: weather data by [Open-Meteo.com](https://open-meteo.com/), [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), with modified Copernicus Climate Change Service information ([sources and licences](https://github.com/eizedev/powershell-universal-components/blob/HEAD/docs/site/data/SOURCES.md)). [Pivot overview](pivot/index.md){ .md-button .md-button--primary } [Templates, view files and roles](pivot/templates.md){ .md-button } diff --git a/docs/perspective/view.md b/docs/perspective/view.md index 7c42c1e..b2afce5 100644 --- a/docs/perspective/view.md +++ b/docs/perspective/view.md @@ -25,6 +25,10 @@ of expression columns from `-Config` count as columns. --8<-- "examples/pivot-tickets-per-team-and-priority.md" +## Temperature per city + +--8<-- "examples/temperature-per-city.md" + ## Perspective chart: open tickets per team --8<-- "examples/perspective-chart-open-tickets-per-team.md" diff --git a/docs/pivot/index.md b/docs/pivot/index.md index ecd29a0..887c07b 100644 --- a/docs/pivot/index.md +++ b/docs/pivot/index.md @@ -26,6 +26,10 @@ To see it with data first, the [showcase app](demo.md) is a module of its own --8<-- "examples/pivot-report-from-a-web-api.md" +## Weather of six cities + +--8<-- "examples/weather-of-six-cities.md" + Then, depending on what the report needs: | You want | Where | diff --git a/docs/site/Build-Site.ps1 b/docs/site/Build-Site.ps1 index 087fb93..27d555c 100644 --- a/docs/site/Build-Site.ps1 +++ b/docs/site/Build-Site.ps1 @@ -47,13 +47,19 @@ $moduleNames = @(Get-ChildItem -LiteralPath $modulesDir -Directory | Sort-Object # PSU's endpoint type, as in the Pester tests: event script blocks become a marker the page replaces . (Join-Path $repo 'build' 'Add-EndpointType.ps1') -# a public API in an example: the snapshot of that address in data/ (data//), returned as -# Invoke-RestMethod returns JSON (an array is one object in the pipeline, as there) +# a public API in an example: the snapshot of that address in data/ (data//, or the file +# data/Addresses.psd1 names for an address with a query string), returned as Invoke-RestMethod returns +# JSON (an array is one object in the pipeline, as there) +$snapshotOf = Import-PowerShellDataFile -LiteralPath (Join-Path $site 'data' 'Addresses.psd1') function Invoke-RestMethod { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidOverwritingBuiltInCmdlets', '', Justification = 'Answers the examples from snapshots while the site is built')] param([Parameter(Mandatory, Position = 0)][uri]$Uri) $file = Join-Path $site 'data' $Uri.Host $Uri.AbsolutePath.TrimStart('/') - if ($Uri.Scheme -ne 'https' -or $Uri.Query -or -not (Test-Path -LiteralPath $file -PathType Leaf)) { + if ($Uri.Query) { + $path = $snapshotOf.Keys | Where-Object { $snapshotOf[$_] -eq $Uri.OriginalString } | Select-Object -First 1 + $file = if ($path) { Join-Path $site 'data' $path } + } + if ($Uri.Scheme -ne 'https' -or -not $file -or -not (Test-Path -LiteralPath $file -PathType Leaf)) { throw "No snapshot of $Uri in docs/site/data/ (see data/SOURCES.md)." } Get-Content -LiteralPath $file -Raw | ConvertFrom-Json -NoEnumerate diff --git a/docs/site/data/Addresses.psd1 b/docs/site/data/Addresses.psd1 index 68fe560..5eac6f2 100644 --- a/docs/site/data/Addresses.psd1 +++ b/docs/site/data/Addresses.psd1 @@ -2,6 +2,7 @@ # Every other file is the answer of https:// (Update-Data.ps1). @{ # daily weather of six cities (Berlin, London, Madrid, New York, Tokyo, Sydney), 2024 and 2025; - # the showcase app of PowerShellUniversal.Component.Pivot.Demo asks for exactly this address + # the showcase app of PowerShellUniversal.Component.Pivot.Demo and the weather examples of + # ../examples.ps1 ask for exactly this address 'archive-api.open-meteo.com/v1/archive.json' = 'https://archive-api.open-meteo.com/v1/archive?latitude=52.52,51.51,40.42,40.71,35.69,-33.87&longitude=13.41,-0.13,-3.70,-74.01,139.69,151.21&start_date=2024-01-01&end_date=2025-12-31&daily=temperature_2m_max,temperature_2m_min,temperature_2m_mean,precipitation_sum,sunshine_duration&timezone=auto' } diff --git a/docs/site/examples.ps1 b/docs/site/examples.ps1 index a85333b..5d755ae 100644 --- a/docs/site/examples.ps1 +++ b/docs/site/examples.ps1 @@ -11,6 +11,8 @@ # the attribution endoflife.date's licence asks for, under every example with its data $endoflife = 'Release data by [endoflife.date](https://endoflife.date/), MIT licence, Copyright 2020 endoflife.date contributors; on this page a snapshot ([date, sources and licence](https://github.com/eizedev/powershell-universal-components/blob/HEAD/docs/site/data/SOURCES.md)).' +# the attribution Open-Meteo's licence asks for, under every example with its weather data +$openMeteo = 'Weather data by [Open-Meteo.com](https://open-meteo.com/), [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); changed: daily values mapped to rows. Contains modified Copernicus Climate Change Service information 2026; neither the European Commission nor ECMWF is responsible for any use that may be made of the Copernicus information or data it contains; on this page a snapshot ([sources and licences](https://github.com/eizedev/powershell-universal-components/blob/HEAD/docs/site/data/SOURCES.md)).' @( #region Start @@ -57,6 +59,18 @@ $endoflife = 'Release data by [endoflife.date](https://endoflife.date/), MIT lic New-UDEChart -Data $latency -Type area -X Time -Y Ms -MarkLine @{ value = 150; name = 'SLA'; color = '#e53935' } -Thresholds @{ value = 150; color = '#43a047' }, @{ value = 100000; color = '#e53935' } -Height 320px } } + @{ Section = 'Lines and time'; Title = 'Temperature of six cities'; Source = $openMeteo; Text = 'Daily weather from the Open-Meteo archive, one answer per city. Each day counts for the first of its month, and -Aggregate Avg combines the days of a month into its mean.'; Code = { + $cities = 'Berlin', 'London', 'Madrid', 'New York', 'Tokyo', 'Sydney' + $answers = Invoke-RestMethod 'https://archive-api.open-meteo.com/v1/archive?latitude=52.52,51.51,40.42,40.71,35.69,-33.87&longitude=13.41,-0.13,-3.70,-74.01,139.69,151.21&start_date=2024-01-01&end_date=2025-12-31&daily=temperature_2m_max,temperature_2m_min,temperature_2m_mean,precipitation_sum,sunshine_duration&timezone=auto' + $days = for ($c = 0; $c -lt $cities.Count; $c++) { + $daily = $answers[$c].daily + for ($d = 0; $d -lt $daily.time.Count; $d++) { + [pscustomobject]@{ City = $cities[$c]; Month = [datetime]($daily.time[$d].Substring(0, 7) + '-01'); Temperature = $daily.temperature_2m_mean[$d] } + } + } + New-UDEChart -Data $days -Type line -X Month -Y Temperature -GroupBy City -Aggregate Avg -Smooth -Format 'number:1' -YTitle 'Celsius' -Height 380px + } + } @{ Section = 'Lines and time'; Title = 'Trend to a limit: when is the datastore full?'; Text = '-Trend Linear with -TrendTarget continues the least-squares line and marks the date.'; Code = { $fill = 0..59 | ForEach-Object { [pscustomobject]@{ Day = ([datetime]'2026-09-01').AddDays($_); Used = [math]::Round(60 + 0.42 * $_ + [math]::Sin($_) * 1.5, 1) } } New-UDEChart -Data $fill -Type line -X Day -Y Used -Format 'percent100:0' -Trend Linear -TrendTarget 100 -YMax 105 -Height 320px @@ -355,6 +369,18 @@ $endoflife = 'Release data by [endoflife.date](https://endoflife.date/), MIT lic New-UDPerspective -Data $tickets -GroupBy Team -SplitBy Priority -Columns Id, LeadHours -Aggregates @{ Id = 'count'; LeadHours = 'avg' } -Height 320px } } + @{ Section = 'Perspective'; Title = 'Temperature per city'; Source = $openMeteo; Text = 'One row per city and day from the Open-Meteo archive, 2024 and 2025. The Y Bar chart groups them by city: the mean temperature in degrees Celsius. title in -Config names the view above the chart; Table shows the grid.'; Code = { + $cities = 'Berlin', 'London', 'Madrid', 'New York', 'Tokyo', 'Sydney' + $answers = Invoke-RestMethod 'https://archive-api.open-meteo.com/v1/archive?latitude=52.52,51.51,40.42,40.71,35.69,-33.87&longitude=13.41,-0.13,-3.70,-74.01,139.69,151.21&start_date=2024-01-01&end_date=2025-12-31&daily=temperature_2m_max,temperature_2m_min,temperature_2m_mean,precipitation_sum,sunshine_duration&timezone=auto' + $days = for ($c = 0; $c -lt $cities.Count; $c++) { + $daily = $answers[$c].daily + for ($d = 0; $d -lt $daily.time.Count; $d++) { + [pscustomobject]@{ City = $cities[$c]; Temperature = $daily.temperature_2m_mean[$d] } + } + } + New-UDPerspective -Data $days -Plugin 'Y Bar' -GroupBy City -Columns Temperature -Aggregates @{ Temperature = 'avg' } -Config @{ title = 'Mean temperature per city' } -Height 360px + } + } @{ Section = 'Perspective'; Title = 'Perspective chart: open tickets per team'; Text = 'A chart plugin with a filter; the WebGL charts redraw as the reader changes the grouping.'; Code = { $rng = [System.Random]::new(3) $tickets = foreach ($i in 1..800) { @@ -370,6 +396,23 @@ $endoflife = 'Release data by [endoflife.date](https://endoflife.date/), MIT lic New-UDPivotReport -Id 'python' -Data (Invoke-RestMethod 'https://endoflife.date/api/python.json') } } + @{ Section = 'Pivot'; Title = 'Weather of six cities'; Source = $openMeteo; Text = 'One row per city and day from the Open-Meteo archive. The start view is a table of the mean temperature per month of the year and city, as a colour scale from blue to orange. Chart draws it as lines; Both shows the table and the chart side by side on a report at least 1,024 pixels wide.'; Code = { + $cities = 'Berlin', 'London', 'Madrid', 'New York', 'Tokyo', 'Sydney' + $answers = Invoke-RestMethod 'https://archive-api.open-meteo.com/v1/archive?latitude=52.52,51.51,40.42,40.71,35.69,-33.87&longitude=13.41,-0.13,-3.70,-74.01,139.69,151.21&start_date=2024-01-01&end_date=2025-12-31&daily=temperature_2m_max,temperature_2m_min,temperature_2m_mean,precipitation_sum,sunshine_duration&timezone=auto' + $days = for ($c = 0; $c -lt $cities.Count; $c++) { + $daily = $answers[$c].daily + for ($d = 0; $d -lt $daily.time.Count; $d++) { + [pscustomobject]@{ City = $cities[$c]; Date = [datetime]$daily.time[$d]; Temperature = $daily.temperature_2m_mean[$d] } + } + } + New-UDPivotReport -Id 'weather' -Data $days -Height 760px -Zones Folded -FieldList Collapsed -Tips Off -TimeZone UTC -View @{ + derived = @(@{ name = 'Month'; field = 'Date'; by = 'month' }) + rows = @('Month'); cols = @('City') + values = @(@{ field = 'Temperature'; agg = 'average'; format = 'number:1'; conditional = @{ type = 'colorScale'; colors = @('#2a78d6', '#f2f2f2', '#eb6834') } }) + display = 'table'; chart = @{ type = 'line' } + } + } + } @{ Section = 'Pivot'; Title = 'Start view, field names and templates'; App = 'End of life'; Source = $endoflife; Text = 'Five products from the same API. -View opens the report with end of life per year and product, -FieldDefaults gives the fields names, descriptions and types, -Locale en-GB formats dates and numbers, and -Templates puts two views into the Views menu.'; Code = { $cycles = foreach ($product in 'python', 'nodejs', 'postgresql', 'ubuntu', 'powershell') { # eol and lts are a date or $true/$false: keep eol's dates, lts as $true/$false diff --git a/docs/site/screenshots.mjs b/docs/site/screenshots.mjs index 717416a..5a77b00 100644 --- a/docs/site/screenshots.mjs +++ b/docs/site/screenshots.mjs @@ -1,7 +1,7 @@ // Screenshots for the documentation, in the light and the dark theme. The files land in docs/assets/ // and are committed; look at them before committing. // -// The live examples of the start page: each one is the example's element on the built site, drawn by +// The live examples of the README and the start page: each one is the example's element on the built site, drawn by // the module's own component. Build and serve the site first (docs/development/), then: // // node docs/site/screenshots.mjs [http://127.0.0.1:8765] @@ -20,20 +20,32 @@ const demo = (process.env.PSU_PIVOT_DEMO_URL || "").replace(/\/$/, ""); // ---- the site's live examples ---------------------------------------------------------------------- const base = process.argv[2] || "http://127.0.0.1:8765"; -// page, example id and file name (without -light/-dark) -const SHOTS = [["/pivot/", "a-report-app-with-loading-views-per-reader-and-roles", "pivot-report"]]; +// what shows that an example has drawn: the pivot report's table, a chart's canvas, Perspective's grid +const DRAWN = { pivot: ".pk-result td", echarts: "canvas", perspective: "perspective-viewer" }; +// page, example id, file name (without -light/-dark) and kind of component +const SHOTS = [ + ["/echarts/lines-and-time/", "temperature-of-six-cities", "echarts-weather", "echarts"], + ["/perspective/view/", "temperature-per-city", "perspective-weather", "perspective"], + ["/pivot/", "weather-of-six-cities", "pivot-weather", "pivot"], +]; +// for the shots only: the header scrolls away, and the content takes the window's width without the +// navigation and the table of contents, so every example is as wide and the pivot report is wide +// enough (1,024 pixels) for its tab Both +const SHOT_LAYOUT = `.md-header { position: static !important; } +.md-sidebar { display: none !important; } +.md-grid, .md-main__inner, .md-content { max-width: none !important; } +.md-content { margin: 0 !important; }`; async function siteShots(browser) { for (const scheme of ["light", "dark"]) { - const page = await browser.newPage({ viewport: { width: 1440, height: 900 }, colorScheme: scheme, deviceScaleFactor: 2 }); - for (const [path, id, name] of SHOTS) { + const page = await browser.newPage({ viewport: { width: 1200, height: 900 }, colorScheme: scheme, deviceScaleFactor: 2 }); + for (const [path, id, name, kind] of SHOTS) { await page.goto(base + path); const example = page.locator(`[data-example="${id}"]`); - // the report has drawn its table - await example.locator(".pk-result td").first().waitFor(); - await example.scrollIntoViewIfNeeded(); - // let fonts and the table's layout settle - await page.waitForTimeout(500); + await example.locator(DRAWN[kind]).first().waitFor(); + await page.addStyleTag({ content: SHOT_LAYOUT }); + // let fonts, the new width and the charts' entry animation settle + await page.waitForTimeout(2500); await example.screenshot({ path: `${out}${name}-${scheme}.png`, animations: "disabled" }); console.log(`${name}-${scheme}.png`); }