A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Update Plotly to 3.3.1 and add heatmap click event (#8255)
Florian Verdonck1e0240b81157
diff --git a/frontend/islands/vite.config.mts b/frontend/islands/vite.config.mtsindex 610c486b4c..13abe2096f 100644--- a/frontend/islands/vite.config.mts+++ b/frontend/islands/vite.config.mts@@ -41,6 +41,7 @@ export default defineConfig({},define: {"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),+ "process.env.DEBUG": JSON.stringify(process.env.DEBUG ?? ""),"process.env.LOG": JSON.stringify(""),"process.env.VSCODE_TEXTMATE_DEBUG": JSON.stringify(false),"process.env.NODE_DEBUG": JSON.stringify(false),diff --git a/frontend/package.json b/frontend/package.jsonindex 7f1a47d13e..3003dda444 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -144,7 +144,7 @@"mermaid": "^11.12.2","partysocket": "1.1.10","path-to-regexp": "^8.3.0",- "plotly.js": "^2.35.3",+ "plotly.js": "^3.3.1","pyodide": "0.27.7","react-arborist": "^3.4.3","react-aria": "3.44.0",diff --git a/frontend/src/plugins/impl/plotly/Plot.tsx b/frontend/src/plugins/impl/plotly/Plot.tsxindex a65e534828..a977dc6bcb 100644--- a/frontend/src/plugins/impl/plotly/Plot.tsx+++ b/frontend/src/plugins/impl/plotly/Plot.tsx@@ -35,6 +35,7 @@ export interface PlotProps {onRelayouting?: (event: PlotlyTypes.PlotRelayoutEvent) => void;onSelected?: (event: PlotlyTypes.PlotSelectionEvent) => void;onDeselect?: () => void;+ onClick?: (event: PlotlyTypes.PlotMouseEvent) => void;onSunburstClick?: (event: PlotlyTypes.PlotMouseEvent) => void;onTreemapClick?: (event: PlotlyTypes.PlotMouseEvent) => void;onError?: (err: Error) => void;@@ -48,6 +49,7 @@ const EVENT_NAMES = ["Relayouting","Selected","Deselect",+ "Click","SunburstClick","TreemapClick",] as const;diff --git a/frontend/src/plugins/impl/plotly/PlotlyPlugin.tsx b/frontend/src/plugins/impl/plotly/PlotlyPlugin.tsxindex d275e79012..ed115223c8 100644--- a/frontend/src/plugins/impl/plotly/PlotlyPlugin.tsx+++ b/frontend/src/plugins/impl/plotly/PlotlyPlugin.tsx@@ -193,6 +193,24 @@ export const PlotlyComponent = memo(}));})}config={plotlyConfig}+ onClick={useEvent((evt: Readonly<Plotly.PlotMouseEvent>) => {+ if (!evt) {+ return;+ }+ // Only handle clicks for chart types where box/lasso selection+ // (onSelected) doesn't work, such as heatmaps.+ const isHeatmap = evt.points.some(+ (point) => point.data?.type === "heatmap",+ );+ if (!isHeatmap) {+ return;+ }+ setValue((prev) => ({+ ...prev,+ points: extractPoints(evt.points),+ indices: evt.points.map((point) => point.pointIndex),+ }));+ })}onSelected={useEvent((evt: Readonly<Plotly.PlotSelectionEvent>) => {if (!evt) {return;@@ -224,6 +242,17 @@ PlotlyComponent.displayName = "PlotlyComponent";* instead of the ones that Plotly uses internally,* by using the hovertemplate.*/+const STANDARD_POINT_KEYS: string[] = [+ "x",+ "y",+ "z",+ "lat",+ "lon",+ "curveNumber",+ "pointNumber",+ "pointIndex",+];+function extractPoints(points: Plotly.PlotDatum[],): Record<AxisName, AxisDatum>[] {@@ -238,6 +267,13 @@ function extractPoints(const hovertemplate = Array.isArray(point.data.hovertemplate)? point.data.hovertemplate[0]: point.data.hovertemplate;++ // For chart types with standard point keys (e.g. heatmaps),+ // or when there's no hovertemplate, pick keys directly from the point.+ if (!hovertemplate || point.data?.type === "heatmap") {+ return pick(point, STANDARD_POINT_KEYS);+ }+// Update or create a parserparser = parser? parser.update(hovertemplate)diff --git a/frontend/vite.config.mts b/frontend/vite.config.mtsindex 1c8fa585db..622e171024 100644--- a/frontend/vite.config.mts+++ b/frontend/vite.config.mts@@ -290,6 +290,7 @@ export default defineConfig({? JSON.stringify(process.env.VITE_MARIMO_VERSION): JSON.stringify("latest"),"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),+ "process.env.DEBUG": JSON.stringify(process.env.DEBUG ?? ""),},build: {minify: isDev ? false : "oxc", // default is "oxc"diff --git a/marimo/_smoke_tests/third_party/plotly_example.py b/marimo/_smoke_tests/third_party/plotly_example.pyindex 6f1be2a497..01ef946811 100644--- a/marimo/_smoke_tests/third_party/plotly_example.py+++ b/marimo/_smoke_tests/third_party/plotly_example.py@@ -2,20 +2,23 @@# requires-python = ">=3.11"# dependencies = [# "plotly==5.24.1",-# "pandas==2.2.3",+# "pandas==3.0.0",# "marimo",+# "vega-datasets==0.9.0",# ]# ///import marimo-__generated_with = "0.15.5"+__generated_with = "0.19.9"app = marimo.App(width="full")@app.celldef _(mo):- mo.md("""# Plotly Express Chart""")+ mo.md("""+ # Plotly Express Chart+ """)return@@ -67,7 +70,9 @@ def _(mo, plot):@app.celldef _(mo):- mo.md("""# Plotly Graph Objects Chart""")+ mo.md("""+ # Plotly Graph Objects Chart+ """)return@@ -129,7 +134,9 @@ def _(mo, plot2):@app.celldef _(mo):- mo.md("""# Re-rendering Chart""")+ mo.md("""+ # Re-rendering Chart+ """)return@@ -174,7 +181,9 @@ def _(mo, plot3):@app.celldef _(mo):- mo.md("""# 3D Chart""")+ mo.md("""+ # 3D Chart+ """)return@@ -251,5 +260,41 @@ def _(go, pd):return+def _(mo):+ mo.md("""+ # Heatmap Click+ """)+ return++[email protected](hide_code=True)+def _(go, mo):+ _fig = go.Figure(+ data=go.Heatmap(+ z=[[1, 20, 30], [20, 1, 60], [30, 60, 1]],+ x=["A", "B", "C"],+ y=["X", "Y", "Z"],+ colorscale="Viridis",+ )+ )+ _fig.update_layout(title="Click on a cell", width=500, height=400)++ heatmap = mo.ui.plotly(_fig)+ heatmap+ return (heatmap,)+++def _(heatmap, mo):+ mo.vstack(+ [+ mo.ui.table(heatmap.value, label="Points", selection=None),+ heatmap.indices,+ ]+ )+ return++if __name__ == "__main__":app.run()diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 4abcdfd4aa..4a7256bd85 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -407,8 +407,8 @@ importers:specifier: ^8.3.0version: 8.3.0plotly.js:- specifier: ^2.35.3+ specifier: ^3.3.1+ version: 3.3.1([email protected])pyodide:specifier: 0.27.7version: 0.27.7@@ -5076,9 +5076,15 @@ packages:resolution: {integrity: sha512-VaX97wsqrMwLSOR6H7rU1Doa2zyVdmShabKrPEIFywLlHoibgD3QW9Dw6fSqM4+H/LfjprDNAUUW31qEQcGzNw==}+ resolution: {integrity: sha512-PPwZYkEY3M2THEHHV6Y95sGUie77S7X8v+h1r6LSAPF3/LL2xJ8duUXSrkic31Nzc4odPwHgUbiX/XuTYzQHQg==}+resolution: {integrity: sha512-A6WMiFzunQ8KEPFmj02OnnoUnqhmSaHaZ/0LVFcPTdlvm8+3aMJ5x1HRHy3bDHPkovkf4sS0f4wsVvwk71fKkg==}+ resolution: {integrity: sha512-BcKnbOEsOarCwyoLstcoEztwT0IJxqqQkNwDuA3a65sICvvHL2yoeV13psoDFh5IuiOMnIOKdQDwB4Mk3BypiA==}+resolution: {integrity: sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==}@@ -5235,18 +5241,6 @@ packages:resolution: {integrity: sha512-X1xgQhkZ9n94WDwntqst5D/FKkmiU0GlJSFZSV3kLvyJ1WC5VeyoXDOuleUD+SIuH9C7W05is++0Woh0CGfKjQ==}- resolution: {integrity: sha512-6WvYYn7l/XEGN8Xu2vWFt9nVzrCn39vKyTEFf/ExEyoksJjjSZV/0/35XPlMbpnr6VGhZIUg5yJrL8tGfes/FA==}- engines: {node: '>= 18.12.0'}- peerDependencies:- '@rspack/core': 0.x || 1.x- webpack: ^5.27.0- peerDependenciesMeta:- '@rspack/core':- optional: true- webpack:- optional: true-resolution: {integrity: sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==}@@ -6634,12 +6628,6 @@ packages:resolution: {integrity: sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==}engines: {node: '>=0.10.0'}- resolution: {integrity: sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==}- engines: {node: ^10 || ^12 || >= 14}- peerDependencies:- postcss: ^8.1.0-resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}@@ -8003,8 +7991,9 @@ packages:engines: {node: '>=18'}hasBin: true- resolution: {integrity: sha512-7RaC6FxmCUhpD6H4MpD+QLUu3hCn76I11rotRefrh3m1iDvWqGnVqVk9dSaKmRAhFD3vsNsYea0OxnR1rc2IzQ==}+ resolution: {integrity: sha512-SrGSZ02HvCWQIYsbQX4sgjgGo7k4T+Oz8a+RQwE5Caz+yu1vputBM1UThmiOPY51B5HzO9ajym8Rl4pmLj+i9Q==}+ engines: {node: '>=18.0.0'}resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}@@ -8122,30 +8111,6 @@ packages:peerDependencies:postcss: ^8.4.32- resolution: {integrity: sha512-k3kNe0aNFQDAZGbin48pL2VNidTF0w4/eASDsxlyspobzU3wZQLOGj7L9gfRe0Jo9/4uud09DsjFNH7winGv8Q==}- engines: {node: ^10 || ^12 || >= 14}- peerDependencies:- postcss: ^8.1.0-- resolution: {integrity: sha512-5kcJm/zk+GJDSfw+V/42fJ5fhjL5YbFDl8nVdXkJPLLW+Vf9mTD5Xe0wqIaDnLuL2U6cDNpTr+UQ+v2HWIBhzw==}- engines: {node: ^10 || ^12 || >= 14}- peerDependencies:- postcss: ^8.1.0-- resolution: {integrity: sha512-m9jZstCVaqGjTAuny8MdgE88scJnCiQSlSrOWcTQgM2t32UBe+MUmFSO5t7VMSfAf/FJKImAxBav8ooCHJXCJA==}- engines: {node: ^10 || ^12 || >= 14}- peerDependencies:- postcss: ^8.1.0-- resolution: {integrity: sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ==}- engines: {node: ^10 || ^12 || >= 14}- peerDependencies:- postcss: ^8.1.0-resolution: {integrity: sha512-sn413ofhSQHlZFae//m9FTOfkmiZ+YQXsbosqOWRiVQncU2BA3daX3n0VF3cG6rGLSFVc5Di/yns0dFfh8NFgQ==}engines: {node: ^18.12.0 || ^20.9.0 || >=22.0}@@ -9188,12 +9153,6 @@ packages:resolution: {integrity: sha512-i0TFx4wPcO0FwX+4RkLJi1MxmcTv90jNZgxMu9XRnMXMeFUY1VJlIoXpZunPUvUUqbCT1pg5PEkFqqpcaElNaA==}- resolution: {integrity: sha512-1V4WqhhZZgjVAVJyt7TdDPZoPBPNHbekX4fWnCJL1yQukhCeZhJySUL+gL9y6sNdN95uEOS83Y55SqHcP7MzLA==}- engines: {node: '>= 18.12.0'}- peerDependencies:- webpack: ^5.27.0-resolution: {integrity: sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==}@@ -11580,6 +11539,7 @@ snapshots:dependencies:'@jridgewell/gen-mapping': 0.3.13'@jridgewell/trace-mapping': 0.3.31+ optional: true'@jridgewell/[email protected]': {}@@ -14539,11 +14499,13 @@ snapshots:dependencies:'@types/eslint': 9.6.1'@types/estree': 1.0.8+ optional: true'@types/[email protected]':dependencies:'@types/estree': 1.0.8'@types/json-schema': 7.0.15+ optional: true'@types/[email protected]':dependencies:@@ -14583,7 +14545,8 @@ snapshots:'@types/tough-cookie': 4.0.5parse5: 7.3.0- '@types/[email protected]': {}+ '@types/[email protected]':+ optional: true'@types/[email protected]': {}@@ -14988,20 +14951,26 @@ snapshots:dependencies:'@webassemblyjs/helper-numbers': 1.13.2'@webassemblyjs/helper-wasm-bytecode': 1.13.2+ optional: true- '@webassemblyjs/[email protected]': {}+ '@webassemblyjs/[email protected]':+ optional: true- '@webassemblyjs/[email protected]': {}+ '@webassemblyjs/[email protected]':+ optional: true- '@webassemblyjs/[email protected]': {}+ '@webassemblyjs/[email protected]':+ optional: true'@webassemblyjs/[email protected]':dependencies:'@webassemblyjs/floating-point-hex-parser': 1.13.2'@webassemblyjs/helper-api-error': 1.13.2'@xtuc/long': 4.2.2+ optional: true- '@webassemblyjs/[email protected]': {}+ '@webassemblyjs/[email protected]':+ optional: true'@webassemblyjs/[email protected]':dependencies:@@ -15009,16 +14978,20 @@ snapshots:'@webassemblyjs/helper-buffer': 1.14.1'@webassemblyjs/helper-wasm-bytecode': 1.13.2'@webassemblyjs/wasm-gen': 1.14.1+ optional: true'@webassemblyjs/[email protected]':dependencies:'@xtuc/ieee754': 1.2.0+ optional: true'@webassemblyjs/[email protected]':dependencies:'@xtuc/long': 4.2.2+ optional: true- '@webassemblyjs/[email protected]': {}+ '@webassemblyjs/[email protected]':+ optional: true'@webassemblyjs/[email protected]':dependencies:@@ -15030,6 +15003,7 @@ snapshots:'@webassemblyjs/wasm-opt': 1.14.1'@webassemblyjs/wasm-parser': 1.14.1'@webassemblyjs/wast-printer': 1.14.1+ optional: true'@webassemblyjs/[email protected]':dependencies:@@ -15038,6 +15012,7 @@ snapshots:'@webassemblyjs/ieee754': 1.13.2'@webassemblyjs/leb128': 1.13.2'@webassemblyjs/utf8': 1.13.2+ optional: true'@webassemblyjs/[email protected]':dependencies:@@ -15045,6 +15020,7 @@ snapshots:'@webassemblyjs/helper-buffer': 1.14.1'@webassemblyjs/wasm-gen': 1.14.1'@webassemblyjs/wasm-parser': 1.14.1+ optional: true'@webassemblyjs/[email protected]':dependencies:@@ -15054,11 +15030,13 @@ snapshots:'@webassemblyjs/ieee754': 1.13.2'@webassemblyjs/leb128': 1.13.2'@webassemblyjs/utf8': 1.13.2+ optional: true'@webassemblyjs/[email protected]':dependencies:'@webassemblyjs/ast': 1.14.1'@xtuc/long': 4.2.2+ optional: true'@xterm/[email protected]': {}@@ -15076,9 +15054,11 @@ snapshots:'@xterm/[email protected]': {}- '@xtuc/[email protected]': {}+ '@xtuc/[email protected]':+ optional: true- '@xtuc/[email protected]': {}+ '@xtuc/[email protected]':+ optional: true'@zed-industries/[email protected]':dependencies:@@ -15094,6 +15074,7 @@ snapshots:dependencies:acorn: 8.15.0+ optional: truedependencies:@@ -15116,11 +15097,13 @@ snapshots:optionalDependencies:ajv: 8.17.1+ optional: truedependencies:ajv: 8.17.1fast-deep-equal: 3.1.3+ optional: truedependencies:@@ -15514,7 +15497,8 @@ snapshots:dependencies:readdirp: 4.1.2- [email protected]: {}+ optional: true@@ -15634,11 +15618,18 @@ snapshots:color-parse: 1.4.3color-space: 1.16.0+ dependencies:+ color-parse: 2.0.0+ color-space: 2.3.2+dependencies:hsluv: 0.0.3mumath: 3.3.4+ [email protected]: {}+@@ -15781,19 +15772,6 @@ snapshots:- dependencies:- icss-utils: 5.1.0([email protected])- postcss: 8.5.6- postcss-modules-extract-imports: 3.1.0([email protected])- postcss-modules-local-by-default: 4.2.0([email protected])- postcss-modules-scope: 3.2.1([email protected])- postcss-modules-values: 4.0.0([email protected])- postcss-value-parser: 4.2.0- semver: 7.7.3- optionalDependencies:- webpack: 5.100.2([email protected])-dependencies:boolbase: 1.0.0@@ -16672,6 +16650,7 @@ snapshots:dependencies:esrecurse: 4.3.0estraverse: 4.3.0+ optional: truedependencies:@@ -17105,7 +17084,8 @@ snapshots:dependencies:is-glob: 4.0.3- [email protected]: {}+ optional: truedependencies:@@ -17546,10 +17526,6 @@ snapshots:dependencies:safer-buffer: 2.1.2- dependencies:- postcss: 8.5.6-@@ -17836,6 +17812,7 @@ snapshots:'@types/node': 24.10.9merge-stream: 2.0.0supports-color: 8.1.1+ optional: true@@ -18073,7 +18050,8 @@ snapshots:- [email protected]: {}+ optional: truedependencies:@@ -18405,7 +18383,8 @@ snapshots:dependencies:source-map: 0.5.7- [email protected]: {}+ optional: true@@ -18791,7 +18770,8 @@ snapshots:- [email protected]: {}+ optional: true@@ -19133,12 +19113,13 @@ snapshots:optionalDependencies:fsevents: 2.3.2dependencies:'@plotly/d3': 3.8.2'@plotly/d3-sankey': 0.7.2'@plotly/d3-sankey-circular': 0.33.1'@plotly/mapbox-gl': 1.13.4([email protected])+ '@plotly/regl': 2.1.2'@turf/area': 7.2.0'@turf/bbox': 7.2.0'@turf/centroid': 7.2.0@@ -19147,9 +19128,8 @@ snapshots:color-alpha: 1.0.4color-normalize: 1.5.0color-parse: 2.0.0- color-rgba: 2.1.1+ color-rgba: 3.0.0country-regex: 1.1.0- css-loader: 7.1.2([email protected]([email protected]))d3-force: 1.2.1d3-format: 1.4.5d3-geo: 1.12.1@@ -19173,13 +19153,11 @@ snapshots:point-in-polygon: 1.1.0polybooljs: 1.2.2probe-image-size: 7.2.3- regl: '@plotly/[email protected]'regl-error2d: 2.0.12regl-line2d: 3.1.3regl-scatter2d: 3.3.1regl-splom: 1.0.14strongly-connected-components: 1.0.1- style-loader: 4.0.0([email protected]([email protected]))superscript-text: 1.0.0svg-path-sdf: 1.1.3tinycolor2: 1.6.0@@ -19188,10 +19166,8 @@ snapshots:webgl-context: 2.2.0world-calendars: 1.0.4transitivePeerDependencies:- - '@rspack/core'- mapbox-gl- supports-color- - webpack@@ -19292,27 +19268,6 @@ snapshots:postcss: 8.5.6postcss-selector-parser: 7.1.0- dependencies:- postcss: 8.5.6-- dependencies:- icss-utils: 5.1.0([email protected])- postcss: 8.5.6- postcss-selector-parser: 7.1.0- postcss-value-parser: 4.2.0-- dependencies:- postcss: 8.5.6- postcss-selector-parser: 7.1.0-- dependencies:- icss-utils: 5.1.0([email protected])- postcss: 8.5.6-dependencies:postcss: 8.5.6@@ -19523,6 +19478,7 @@ snapshots:dependencies:safe-buffer: 5.2.1+ optional: true@@ -20347,6 +20303,7 @@ snapshots:ajv: 8.17.1ajv-formats: 2.1.1([email protected])ajv-keywords: 5.1.0([email protected])+ optional: true@@ -20373,6 +20330,7 @@ snapshots:dependencies:randombytes: 2.1.0+ optional: truedependencies:@@ -20473,6 +20431,7 @@ snapshots:dependencies:buffer-from: 1.1.2source-map: 0.6.1+ optional: true@@ -20736,10 +20695,6 @@ snapshots:- dependencies:- webpack: 5.100.2([email protected])-@@ -20843,6 +20798,7 @@ snapshots:dependencies:has-flag: 4.0.0+ optional: truedependencies:@@ -20929,6 +20885,7 @@ snapshots:webpack: 5.100.2([email protected])optionalDependencies:esbuild: 0.27.2+ optional: truedependencies:@@ -20936,6 +20893,7 @@ snapshots:acorn: 8.15.0commander: 2.20.3source-map-support: 0.5.21+ optional: true@@ -21903,6 +21861,7 @@ snapshots:dependencies:glob-to-regexp: 0.4.1graceful-fs: 4.2.11+ optional: true@@ -21918,7 +21877,8 @@ snapshots:- [email protected]: {}+ optional: true@@ -21953,6 +21913,7 @@ snapshots:- '@swc/core'- esbuild- uglify-js+ optional: truedependencies: