Skip to content

Commit 2e5e84c

Browse files
committed
Merge remote-tracking branch 'origin/v4.0' into cam/7678/enable-typescript-type-checking
2 parents 41b43f0 + 3c2f49a commit 2e5e84c

26 files changed

Lines changed: 242 additions & 1278 deletions

File tree

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
outputs:
2424
stackgl_modules: ${{ steps.check.outputs.stackgl_modules }}
2525
topojson: ${{ steps.check.outputs.topojson }}
26+
regl_codegen: ${{ steps.check.outputs.regl_codegen }}
2627
steps:
2728
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2829
with:
@@ -42,6 +43,12 @@ jobs:
4243
if git diff --name-only "$BASE"...HEAD -- stackgl_modules/ | grep -q .; then
4344
echo "stackgl_modules=true" >> "$GITHUB_OUTPUT"
4445
fi
46+
# If any of the directories listed below have changed, we need to re-run the regl-codegen step
47+
# stackgl_modules/ is listed here too because the regl-* shader libs live there;
48+
# changes can alter shader output and require regenerating the precompiled shaders.
49+
if git diff --name-only "$BASE"...HEAD -- src/traces/scattergl/ src/traces/scatterpolargl/ src/traces/splom/ src/traces/parcoords/ src/lib/prepare_regl.js stackgl_modules/ devtools/regl_codegen/ | grep -q .; then
50+
echo "regl_codegen=true" >> "$GITHUB_OUTPUT"
51+
fi
4552
4653
# ============================================================
4754
# Root build job - all dependent jobs fan out from here
@@ -656,3 +663,54 @@ jobs:
656663
name: topojson-dist
657664
retention-days: 7
658665
path: topojson/dist/
666+
667+
check-regl-codegen:
668+
needs: [detect-changes, install-and-cibuild]
669+
if: >-
670+
(github.event_name == 'push' && github.ref_name == github.event.repository.default_branch) ||
671+
needs.detect-changes.outputs.regl_codegen == 'true'
672+
runs-on: ubuntu-latest
673+
timeout-minutes: 10
674+
steps:
675+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
676+
- uses: ./.github/actions/setup-workspace
677+
- uses: ./.github/actions/setup-chrome
678+
679+
- name: Run regl codegen
680+
run: |
681+
# Wipe the codegen output dir so orphaned shader files surface as deletions in the diff below.
682+
rm -rf src/generated/regl-codegen/*
683+
node devtools/regl_codegen/server.mjs &
684+
SERVER_PID=$!
685+
until curl -sf -o /dev/null http://localhost:3000/build/regl_codegen-bundle.js 2>/dev/null; do
686+
sleep 1
687+
done
688+
$CHROME_BIN --headless=new --no-sandbox --enable-unsafe-swiftshader --ignore-gpu-blocklist http://localhost:3000/devtools/regl_codegen/index.html &
689+
wait $SERVER_PID
690+
691+
- name: Check regl precompiled shaders are up to date
692+
run: |
693+
# git add -N so newly-generated (untracked) shader files show up in git diff
694+
git add -N src/generated/regl-codegen/
695+
if ! git diff --exit-code \
696+
src/generated/regl-codegen/ \
697+
src/traces/scattergl/regl_precompiled.js \
698+
src/traces/scatterpolargl/regl_precompiled.js \
699+
src/traces/splom/regl_precompiled.js \
700+
src/traces/parcoords/regl_precompiled.js; then
701+
echo "::error::Regl precompiled shaders are out of date. Download the 'regl-codegen' artifact from this workflow run, extract it into src/, and commit the updated files to this pull request."
702+
exit 1
703+
fi
704+
705+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
706+
name: Upload updated regl codegen files
707+
if: failure()
708+
with:
709+
name: regl-codegen
710+
retention-days: 7
711+
path: |
712+
src/generated/regl-codegen/
713+
src/traces/scattergl/regl_precompiled.js
714+
src/traces/scatterpolargl/regl_precompiled.js
715+
src/traces/splom/regl_precompiled.js
716+
src/traces/parcoords/regl_precompiled.js

CONTRIBUTING.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,54 @@ npm run schema
163163
#### Step 9: REGL - Review & commit potential changes to precompiled regl shaders
164164

165165
If you are implementing a new feature that involves regl shaders, or if you are
166-
making changes that affect the usage of regl shaders, you would need to run
166+
making changes that affect the usage of regl shaders, you will need to regenerate the precompiled regl shader code. In practice, that means edits under:
167167

168-
```bash
169-
npm run regl-codegen
170-
```
168+
- `src/traces/{scattergl,scatterpolargl,splom,parcoords}/`
169+
- `src/lib/prepare_regl.js`
170+
- `stackgl_modules/` (where the `regl-*` shader libs live)
171+
- `devtools/regl_codegen/`
171172

172-
to regenerate the regl code. This will prompt you to open a browser window. This will then run through all
173-
traces with 'regl' in the tags, and store the captured code into
174-
[src/generated/regl-codegen](https://github.com/plotly/plotly.js/blob/master/src/generated/regl-codegen). If no updates are necessary, it will be a no-op, but if there are changes, you will need to commit them.
173+
CI's `check-regl-codegen` job uses this same list as its trigger — see [`.github/workflows/ci.yml`](.github/workflows/ci.yml) for the authoritative version.
175174

176175
This is needed because regl performs codegen in runtime which breaks CSP
177176
compliance, and so for strict builds we pre-generate regl shader code here.
178177

178+
The CI pipeline will automatically detect when regl-related files have changed and
179+
run the codegen process. If the precompiled shaders are out of date, the
180+
`check-regl-codegen` job will fail and upload a `regl-codegen` artifact containing
181+
the updated files. The artifact represents the full desired state of the codegen
182+
output (CI wipes the output directory before regenerating, so any orphaned shader
183+
files are pruned). To fix this:
184+
185+
1. Download the `regl-codegen` artifact from the failed workflow run
186+
2. Delete `src/generated/regl-codegen/` in your working tree, then unzip the
187+
artifact into `src/` so it replaces (rather than merges into) the existing
188+
directory. Note that `actions/upload-artifact` strips the longest common
189+
parent path from the uploaded paths, so the zip's root contains
190+
`generated/regl-codegen/` and `traces/{scattergl,scatterpolargl,splom,parcoords}/regl_precompiled.js`
191+
directly — extracting into `src/` restores the correct layout and
192+
overwrites the four `regl_precompiled.js` files in one step.
193+
3. Commit and push the changes to your pull request
194+
195+
Alternatively, you can regenerate the code locally:
196+
197+
```bash
198+
rm -rf src/generated/regl-codegen/*
199+
npm run regl-codegen
200+
```
201+
202+
The `rm -rf` step is needed to clean up any orphaned shader files left over from
203+
previous changes. `npm run regl-codegen` will prompt you to open
204+
a browser window, run through the mocks for each regl-using trace
205+
(`parcoords`, `scattergl`, `scatterpolargl`, `splom`), and store the captured
206+
shader code into
207+
[src/generated/regl-codegen](https://github.com/plotly/plotly.js/blob/master/src/generated/regl-codegen).
208+
The four `src/traces/{parcoords,scattergl,scatterpolargl,splom}/regl_precompiled.js`
209+
files are rewritten in the same pass so their imports point at the freshly
210+
generated shader files. Commit any changes that result — both the
211+
`src/generated/regl-codegen/` updates and any modified `regl_precompiled.js`
212+
files.
213+
179214
#### Other npm scripts that may be of interest in development
180215

181216
- `npm run preprocess`: pre-processes the css and svg source file in js. This

devtools/regl_codegen/server.mjs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,20 @@ function handleCodegen(data) {
8585
var exports = ['', '/* eslint-disable quote-props */', 'module.exports = {', ''].join('\n');
8686
var varId = 0;
8787

88-
Object.entries(generated).forEach(function (kv) {
89-
var key = kv[0];
90-
var value = kv[1];
91-
var filePath = path.join(pathToReglCodegenSrc, key);
92-
fs.writeFileSync(filePath, 'module.exports = ' + value);
93-
94-
imports += 'var v' + varId + " = require('../../" + path.join(constants.reglCodegenSubdir, key) + "');\n";
95-
exports += " '" + key + "': v" + varId + ',\n';
96-
varId++;
97-
});
88+
// Sort by shader-hash key so the emitted import/export order is deterministic
89+
// across machines (fs.readdir mock order varies by OS/filesystem, which would
90+
// otherwise leak into regl_precompiled.js).
91+
Object.keys(generated)
92+
.sort()
93+
.forEach((key) => {
94+
var value = generated[key];
95+
var filePath = path.join(pathToReglCodegenSrc, key);
96+
fs.writeFileSync(filePath, 'module.exports = ' + value);
97+
98+
imports += 'var v' + varId + " = require('../../" + path.join(constants.reglCodegenSubdir, key) + "');\n";
99+
exports += " '" + key + "': v" + varId + ',\n';
100+
varId++;
101+
});
98102

99103
if (varId > 0) {
100104
exports = exports.slice(0, -2) + '\n};\n';

draftlogs/7825_update.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Enable scattermap icons to render in color, upgrade Maki icons version to 8.2, and standardize scattermap legend icons to circles [[#7825](https://github.com/plotly/plotly.js/pull/7825)]

src/components/drawing/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,10 @@ function getMarkerAngle(d, trace) {
18661866

18671867
if (angle === undefined) {
18681868
angle = trace.marker.angle;
1869-
if (!angle || Lib.isArrayOrTypedArray(angle)) {
1869+
// For scattermap traces, `trace.marker.angle` defaults to 'auto',
1870+
// which is meaningful for the MapLibre code but not for plotly.js itself.
1871+
// Therefore we need to coerce any non-numeric values to 0 (no rotation).
1872+
if (!isNumeric(angle) || Lib.isArrayOrTypedArray(angle)) {
18701873
angle = 0;
18711874
}
18721875
}

src/components/legend/style.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,12 @@ module.exports = function style(s, gd, legend) {
207207

208208
if (showMarker) {
209209
dEdit.mc = boundVal('marker.color', pickFirst);
210-
dEdit.mx = boundVal('marker.symbol', pickFirst);
210+
// Scattermap traces use marker.symbol to specify the Maki icon used in
211+
// the map itself, which usually doesn't correspond to a valid
212+
// Plotly symbol. Always draw a circle so the swatch is consistent
213+
// across symbols rather than silently mismatched.
214+
var isScattermapTrace = trace.type === 'scattermap' || trace.type === 'scattermapbox';
215+
dEdit.mx = isScattermapTrace ? 'circle' : boundVal('marker.symbol', pickFirst);
211216
dEdit.mo = boundVal('marker.opacity', Lib.mean, [0.2, 1]);
212217
dEdit.mlc = boundVal('marker.line.color', pickFirst);
213218
dEdit.mlw = boundVal('marker.line.width', Lib.mean, [0, 5], CST_MARKER_LINE_WIDTH);

src/components/modebar/buttons.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ modeBarButtons.sendDataToCloud = {
7676
}
7777
};
7878

79-
modeBarButtons.editInChartStudio = {
80-
name: 'editInChartStudio',
81-
title: function(gd) { return _(gd, 'Edit in Chart Studio'); },
82-
icon: Icons.pencil,
83-
click: function(gd) {
84-
Plots.sendDataToCloud(gd);
85-
}
86-
};
87-
8879
modeBarButtons.zoom2d = {
8980
name: 'zoom2d',
9081
_cat: 'zoom',

src/components/modebar/manage.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ function getButtonGroups(gd) {
145145

146146
// buttons common to all plot types
147147
var commonGroup = ['toImage'];
148-
if(context.showEditInChartStudio) commonGroup.push('editInChartStudio');
149-
else if(context.showSendToCloud) commonGroup.push('sendDataToCloud');
148+
if(context.showSendToCloud) commonGroup.push('sendDataToCloud');
150149
addGroup(commonGroup);
151150

152151
var zoomGroup = [];

src/plot_api/plot_api.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ function _doPlot(gd, data, layout, config) {
373373
subroutines.drawData,
374374
subroutines.finalDraw,
375375
initInteractions,
376-
Plots.addLinks,
377376
Plots.rehover,
378377
Plots.redrag,
379378
Plots.reselect,
@@ -485,7 +484,6 @@ function setPlotContext(gd, config) {
485484
context.scrollZoom = false;
486485
context.doubleClick = false;
487486
context.showTips = false;
488-
context.showLink = false;
489487
context.displayModeBar = false;
490488
}
491489

src/plot_api/plot_config.js

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ var configAttributes = {
3636
dflt: '',
3737
description: [
3838
'When set it determines base URL for',
39-
'the \'Edit in Chart Studio\' `showEditInChartStudio`/`showSendToCloud` mode bar button',
40-
'and the showLink/sendData on-graph link.',
39+
'the \'Edit in Chart Studio\' `showSendToCloud` mode bar button.',
4140
'To enable sending your data to Chart Studio Cloud, you need to',
4241
'set both `plotlyServerURL` to \'https://chart-studio.plotly.com\' and',
4342
'also set `showSendToCloud` to true.'
@@ -227,40 +226,6 @@ var configAttributes = {
227226
description: 'Determines whether or not notifier is displayed.'
228227
},
229228

230-
showLink: {
231-
valType: 'boolean',
232-
dflt: false,
233-
description: [
234-
'Determines whether a link to Chart Studio Cloud is displayed',
235-
'at the bottom right corner of resulting graphs.',
236-
'Use with `sendData` and `linkText`.'
237-
].join(' ')
238-
},
239-
linkText: {
240-
valType: 'string',
241-
dflt: 'Edit chart',
242-
noBlank: true,
243-
description: [
244-
'Sets the text appearing in the `showLink` link.'
245-
].join(' ')
246-
},
247-
sendData: {
248-
valType: 'boolean',
249-
dflt: true,
250-
description: [
251-
'If *showLink* is true, does it contain data',
252-
'just link to a Chart Studio Cloud file?'
253-
].join(' ')
254-
},
255-
showSources: {
256-
valType: 'any',
257-
dflt: false,
258-
description: [
259-
'Adds a source-displaying function to show sources on',
260-
'the resulting graphs.'
261-
].join(' ')
262-
},
263-
264229
displayModeBar: {
265230
valType: 'enumerated',
266231
values: ['hover', true, false],
@@ -286,15 +251,6 @@ var configAttributes = {
286251
'until you arrive at the Chart Studio and explicitly click "Save".'
287252
].join(' ')
288253
},
289-
showEditInChartStudio: {
290-
valType: 'boolean',
291-
dflt: false,
292-
description: [
293-
'Same as `showSendToCloud`, but use a pencil icon instead of a floppy-disk.',
294-
'Note that if both `showSendToCloud` and `showEditInChartStudio` are turned,',
295-
'only `showEditInChartStudio` will be honored.'
296-
].join(' ')
297-
},
298254
modeBarButtonsToRemove: {
299255
valType: 'any',
300256
dflt: [],

0 commit comments

Comments
 (0)