From 9133153b9d267acb4e2e737d9b390e4ff1a10b58 Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Thu, 4 Jul 2019 17:25:12 +0200 Subject: [PATCH 01/15] Release 0.3.1 --- ipympl/_version.py | 2 +- js/package-lock.json | 2 +- js/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ipympl/_version.py b/ipympl/_version.py index ce79add3..dede9ff0 100644 --- a/ipympl/_version.py +++ b/ipympl/_version.py @@ -1,2 +1,2 @@ -version_info = (0, 3, 0) +version_info = (0, 3, 1) __version__ = '.'.join(map(str, version_info)) diff --git a/js/package-lock.json b/js/package-lock.json index b477a803..f48bde18 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "jupyter-matplotlib", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/js/package.json b/js/package.json index 73c1f0a5..551594b6 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "jupyter-matplotlib", - "version": "0.3.0", + "version": "0.4.0", "description": "Matplotlib Jupyter Interactive Widget", "author": "Matplotlib Development team", "license": "BSD-3-Clause", From 61e796a0f517b3245eb050224efd575c60db32fa Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Thu, 4 Jul 2019 17:31:12 +0200 Subject: [PATCH 02/15] Make use of CSS variables --- js/package-lock.json | 187 ++++++++++++++++++++---------------------- js/package.json | 2 +- js/src/mpl_widget.css | 4 +- setup.py | 2 +- 4 files changed, 94 insertions(+), 101 deletions(-) diff --git a/js/package-lock.json b/js/package-lock.json index f48bde18..407938c2 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -5,16 +5,16 @@ "requires": true, "dependencies": { "@jupyter-widgets/base": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@jupyter-widgets/base/-/base-1.2.5.tgz", - "integrity": "sha512-D/cYIo0o0wnTeR2uFTZqwxyxglE4UkJ2mGPEhN1G1a1pnIip+3GcONPjYY+w6OLzShKz10R9V7hUQTqcvRaW8Q==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@jupyter-widgets/base/-/base-2.0.1.tgz", + "integrity": "sha512-jRNeQzvEf6MMGUaEPfBzgZ+IT4XOInpw8Ef+CunNUmUCiQZ8WfNpFR671S0Vu3xO6yGKMTU2QPdk8/aCsJRw9w==", "requires": { - "@jupyterlab/services": "^1.0.1 || ^2.0.0 || ^3.0.0 || 4.0.0-alpha.3 || 4.0.0-alpha.6 || 4.0.0-alpha.8", + "@jupyterlab/services": "^4.0.0", "@phosphor/coreutils": "^1.2.0", "@phosphor/messaging": "^1.2.1", "@phosphor/widgets": "^1.3.0", - "@types/backbone": "^1.3.33", - "@types/lodash": "^4.14.66", + "@types/backbone": "^1.4.1", + "@types/lodash": "^4.14.134", "backbone": "1.2.3", "base64-js": "^1.2.1", "jquery": "^3.1.1", @@ -22,45 +22,58 @@ } }, "@jupyterlab/coreutils": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@jupyterlab/coreutils/-/coreutils-2.2.1.tgz", - "integrity": "sha512-XkGMBXqEAnENC4fK/L3uEqqxyNUtf4TI/1XNDln7d5VOPHQJSBTbYlBAZ0AQotn2qbs4WqmV6icxje2ITVedqQ==", - "requires": { - "@phosphor/algorithm": "^1.1.2", - "@phosphor/coreutils": "^1.3.0", - "@phosphor/disposable": "^1.1.2", - "@phosphor/signaling": "^1.2.2", - "ajv": "~5.1.6", - "comment-json": "^1.1.3", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@jupyterlab/coreutils/-/coreutils-3.0.0.tgz", + "integrity": "sha512-l48G1qhff4CZpsxjje92S6caLUixzfDMAD5vjNZL9obexUAMF+344cpVWsm2r2CQROUW7bPB8wjAtFbp8nK/QQ==", + "requires": { + "@phosphor/commands": "^1.6.3", + "@phosphor/coreutils": "^1.3.1", + "@phosphor/disposable": "^1.2.0", + "@phosphor/properties": "^1.1.3", + "@phosphor/signaling": "^1.2.3", + "ajv": "^6.5.5", + "json5": "^2.1.0", "minimist": "~1.2.0", - "moment": "~2.21.0", + "moment": "^2.24.0", "path-posix": "~1.0.0", "url-parse": "~1.4.3" + }, + "dependencies": { + "json5": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", + "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", + "requires": { + "minimist": "^1.2.0" + } + } } }, "@jupyterlab/observables": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@jupyterlab/observables/-/observables-2.1.1.tgz", - "integrity": "sha512-PzmJ/jF5fWzHCvjPAWBi3YjtHRAF0bwyjpd8W8aJt64TzhEZh0se8xCNGOURzD+8TxOsTF9JpQ9wIDBr4V226Q==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@jupyterlab/observables/-/observables-2.2.0.tgz", + "integrity": "sha512-/oi7vl70yAX5QTXmZafyDSwU8fT1Oa/MdpDDYGkc5IklW0kU3NDqSoawfLovkdgGZvCOCM+6JQqUPRdhn8VZqg==", "requires": { - "@phosphor/algorithm": "^1.1.2", - "@phosphor/coreutils": "^1.3.0", - "@phosphor/disposable": "^1.1.2", - "@phosphor/messaging": "^1.2.2", - "@phosphor/signaling": "^1.2.2" + "@phosphor/algorithm": "^1.1.3", + "@phosphor/coreutils": "^1.3.1", + "@phosphor/disposable": "^1.2.0", + "@phosphor/messaging": "^1.2.3", + "@phosphor/signaling": "^1.2.3" } }, "@jupyterlab/services": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/@jupyterlab/services/-/services-3.2.1.tgz", - "integrity": "sha512-zCMruGGYxTe427ESK4YUO1V/liFOFYpebYPRsJ+j9CFdV+Hm760+nx4pFX6N6Z9TbS+5cs8BgZ+ebm8unRZrJg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@jupyterlab/services/-/services-4.0.0.tgz", + "integrity": "sha512-yCchogfzZqGWXagDJDRxsEMbKwsmf+EFVJRzf5H5OKZs7c/0yNemhG2qjRSmcErD87nUezB3NHkJSVPqz11D3g==", "requires": { - "@jupyterlab/coreutils": "^2.2.1", - "@jupyterlab/observables": "^2.1.1", - "@phosphor/algorithm": "^1.1.2", - "@phosphor/coreutils": "^1.3.0", - "@phosphor/disposable": "^1.1.2", - "@phosphor/signaling": "^1.2.2" + "@jupyterlab/coreutils": "^3.0.0", + "@jupyterlab/observables": "^2.2.0", + "@phosphor/algorithm": "^1.1.3", + "@phosphor/coreutils": "^1.3.1", + "@phosphor/disposable": "^1.2.0", + "@phosphor/signaling": "^1.2.3", + "node-fetch": "^2.6.0", + "ws": "^7.0.0" } }, "@phosphor/algorithm": { @@ -153,9 +166,9 @@ } }, "@phosphor/widgets": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@phosphor/widgets/-/widgets-1.8.0.tgz", - "integrity": "sha512-Tkjk1bJks9Dtm7lhxTcpA+cSGwdNvRWG5TrolS0waSUiEdgrStWc8QnkMga3zwUZ9Wrz3cLZWnqBfxMjDqwMnA==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@phosphor/widgets/-/widgets-1.8.1.tgz", + "integrity": "sha512-OY5T0nAioYTitPks/lCHm7a6QpjRB/XviIT2j6WtYm5J1U8MluIPpClqZ/NQbZfm23BYpmJeiQQyZA+5YphsDA==", "requires": { "@phosphor/algorithm": "^1.1.3", "@phosphor/commands": "^1.6.3", @@ -180,17 +193,17 @@ } }, "@types/jquery": { - "version": "3.3.29", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.29.tgz", - "integrity": "sha512-FhJvBninYD36v3k6c+bVk1DSZwh7B5Dpb/Pyk3HKVsiohn0nhbefZZ+3JXbWQhFyt0MxSl2jRDdGQPHeOHFXrQ==", + "version": "3.3.30", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.30.tgz", + "integrity": "sha512-chB+QbLulamShZAFcTJtl8opZwHFBpDOP6nRLrPGkhC6N1aKWrDXg2Nc71tEg6ny6E8SQpRwbWSi9GdstH5VJA==", "requires": { "@types/sizzle": "*" } }, "@types/lodash": { - "version": "4.14.134", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.134.tgz", - "integrity": "sha512-2/O0khFUCFeDlbi7sZ7ZFRCcT812fAeOLm7Ev4KbwASkZ575TDrDcY7YyaoHdTOzKcNbfiwLYZqPmoC4wadrsw==" + "version": "4.14.135", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.135.tgz", + "integrity": "sha512-Ed+tSZ9qM1oYpi5kzdsBuOzcAIn1wDW+e8TFJ50IMJMlSopGdJgKAbhHzN6h1E1OfjlGOr2JepzEWtg9NIfoNg==" }, "@types/sizzle": { "version": "2.3.2", @@ -198,9 +211,9 @@ "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==" }, "@types/underscore": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.9.0.tgz", - "integrity": "sha512-1koEJ2AhXaR0HVP3VlN0pCb51n87g5QL9rUiGaY+Nte9gBd2FYf/zNvS5ZtHg7o6owYNS6QA/4ZJ/mIiz2q1hA==" + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@types/underscore/-/underscore-1.9.2.tgz", + "integrity": "sha512-KgOKTAD+9X+qvZnB5S1+onqKc4E+PZ+T6CM/NA5ohRPLHJXb+yCJMVf8pWOnvuBuKFNUAJW8N97IA6lba6mZGg==" }, "acorn": { "version": "5.7.3", @@ -226,13 +239,14 @@ } }, "ajv": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.1.6.tgz", - "integrity": "sha1-Sy8aGd7Ok9V6whYDfj6XkcfdFWQ=", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", "requires": { - "co": "^4.6.0", - "json-schema-traverse": "^0.3.0", - "json-stable-stringify": "^1.0.1" + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, "ajv-errors": { @@ -374,6 +388,11 @@ "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", "dev": true }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" + }, "atob": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", @@ -738,11 +757,6 @@ "wordwrap": "0.0.2" } }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -772,14 +786,6 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, - "comment-json": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-1.1.3.tgz", - "integrity": "sha1-aYbDMw/uDEyeAMI5jNYa+l2PI54=", - "requires": { - "json-parser": "^1.0.0" - } - }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -1166,11 +1172,6 @@ "estraverse": "^4.1.1" } }, - "esprima": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", - "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=" - }, "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", @@ -2310,26 +2311,10 @@ "integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==", "dev": true }, - "json-parser": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/json-parser/-/json-parser-1.1.5.tgz", - "integrity": "sha1-5i7FJh0aal/CDoEqMgdAxtkAVnc=", - "requires": { - "esprima": "^2.7.0" - } - }, "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "requires": { - "jsonify": "~0.0.0" - } + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json5": { "version": "0.5.1", @@ -2346,11 +2331,6 @@ "graceful-fs": "^4.1.6" } }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" - }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -2599,9 +2579,9 @@ } }, "moment": { - "version": "2.21.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.21.0.tgz", - "integrity": "sha512-TCZ36BjURTeFTM/CwRcViQlfkMvL1/vFISuNLO5GkcVm1+QHfbSiNqZuWeMFjj1/3+uAjXswgRk30j1kkLYJBQ==" + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" }, "ms": { "version": "2.0.0", @@ -2655,6 +2635,11 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, "node-libs-browser": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz", @@ -4079,6 +4064,14 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "ws": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.0.1.tgz", + "integrity": "sha512-ILHfMbuqLJvnSgYXLgy4kMntroJpe8hT41dOVWM8bxRuw6TK4mgMp9VJUNsZTEc5Bh+Mbs0DJT4M0N+wBG9l9A==", + "requires": { + "async-limiter": "^1.0.0" + } + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/js/package.json b/js/package.json index 551594b6..552a58b2 100644 --- a/js/package.json +++ b/js/package.json @@ -27,7 +27,7 @@ "webpack": "^3.5.5" }, "dependencies": { - "@jupyter-widgets/base": "^1.1.0 || ^2.0.0", + "@jupyter-widgets/base": "^2.0.0", "css-loader": "^3.0.0", "lodash": "^4.17.4", "style-loader": "^0.23.1" diff --git a/js/src/mpl_widget.css b/js/src/mpl_widget.css index de365326..8442bd5e 100644 --- a/js/src/mpl_widget.css +++ b/js/src/mpl_widget.css @@ -6,7 +6,7 @@ /* Toolbar */ .jupyter-matplotlib-button { - width: 34px; /* calc(var(--jp-widgets-inline-width-tiny) / 2 - 2px) */ + width: calc(var(--jp-widgets-inline-width-tiny) / 2 - 2px); padding: 0; } @@ -23,5 +23,5 @@ } .jupyter-matplotlib-canvas_div:focus { - outline: 1px solid; /* 1px solid var(--jp-widgets-input-focus-border-color); */ + outline: 1px solid var(--jp-widgets-input-focus-border-color); } diff --git a/setup.py b/setup.py index 84d0d1f1..7d7ada0f 100644 --- a/setup.py +++ b/setup.py @@ -155,7 +155,7 @@ def run(self): 'data_files': get_data_files(), 'install_requires': [ 'ipykernel>=4.7', - 'ipywidgets>=7.0.0', + 'ipywidgets>=7.5.0', 'matplotlib>=2.0.0' ], 'packages': find_packages(), From 8c052b8142f5a0e3552cdcf8cb9de8d829426e65 Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Fri, 5 Jul 2019 00:29:03 +0200 Subject: [PATCH 03/15] Release 0.3.2 --- environment.yml | 2 +- ipympl/_version.py | 2 +- js/package-lock.json | 2 +- js/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/environment.yml b/environment.yml index f9fcd573..18a5b235 100644 --- a/environment.yml +++ b/environment.yml @@ -4,4 +4,4 @@ channels: dependencies: - numpy - matplotlib-base>=2.2.2 - - ipympl=0.3.0 + - ipympl=0.3.2 diff --git a/ipympl/_version.py b/ipympl/_version.py index dede9ff0..8b2ddd08 100644 --- a/ipympl/_version.py +++ b/ipympl/_version.py @@ -1,2 +1,2 @@ -version_info = (0, 3, 1) +version_info = (0, 3, 2) __version__ = '.'.join(map(str, version_info)) diff --git a/js/package-lock.json b/js/package-lock.json index 407938c2..e3c421ae 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "jupyter-matplotlib", - "version": "0.4.0", + "version": "0.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/js/package.json b/js/package.json index 552a58b2..a8867239 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "jupyter-matplotlib", - "version": "0.4.0", + "version": "0.4.1", "description": "Matplotlib Jupyter Interactive Widget", "author": "Matplotlib Development team", "license": "BSD-3-Clause", From bbd66f4e2d3c6e658cf404a3c66a5390212f65ca Mon Sep 17 00:00:00 2001 From: martinRenou Date: Fri, 5 Jul 2019 09:06:37 +0200 Subject: [PATCH 04/15] Fix rubberband on Firefox --- js/src/mpl_widget.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index fb399eb0..5da3773b 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -226,10 +226,8 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ this.canvas.setAttribute('height', height * this.ratio); this.canvas.style.width = width + 'px'; - this.rubberband_canvas.setAttribute('width', width * this.ratio); - this.rubberband_canvas.setAttribute('height', height * this.ratio); - this.rubberband_canvas.style.height = height + 'px'; - this.rubberband_canvas.style.height = height + 'px'; + this.rubberband_canvas.setAttribute('width', width); + this.rubberband_canvas.setAttribute('height', height); }, send_message: function(type, message = {}) { From cc54ca4582dcecf14fb45cc0097fdb797bb42370 Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Fri, 5 Jul 2019 14:13:32 +0200 Subject: [PATCH 05/15] Fixup jlab layout --- js/src/mpl_widget.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index 5da3773b..c8c8585d 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -142,6 +142,7 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ var canvas = this.canvas = document.createElement('canvas'); canvas.style.display = 'block'; + canvas.style.position = 'absolute'; canvas.style.left = 0; canvas.style.top = 0; canvas.style.zIndex = 0; From 089e8209355fc3da643f034e10fe932f44aa4fe8 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Fri, 5 Jul 2019 15:13:18 +0200 Subject: [PATCH 06/15] Release 0.3.3 --- environment.yml | 2 +- ipympl/_version.py | 2 +- js/package-lock.json | 2 +- js/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/environment.yml b/environment.yml index 18a5b235..279203df 100644 --- a/environment.yml +++ b/environment.yml @@ -4,4 +4,4 @@ channels: dependencies: - numpy - matplotlib-base>=2.2.2 - - ipympl=0.3.2 + - ipympl=0.3.3 diff --git a/ipympl/_version.py b/ipympl/_version.py index 8b2ddd08..55ff383a 100644 --- a/ipympl/_version.py +++ b/ipympl/_version.py @@ -1,2 +1,2 @@ -version_info = (0, 3, 2) +version_info = (0, 3, 3) __version__ = '.'.join(map(str, version_info)) diff --git a/js/package-lock.json b/js/package-lock.json index e3c421ae..ca1a11d0 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "jupyter-matplotlib", - "version": "0.4.1", + "version": "0.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/js/package.json b/js/package.json index a8867239..bc1b4ac3 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "jupyter-matplotlib", - "version": "0.4.1", + "version": "0.4.2", "description": "Matplotlib Jupyter Interactive Widget", "author": "Matplotlib Development team", "license": "BSD-3-Clause", From 6208f8833d3babeedc243b2943e78bf4b9703eb2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2019 18:33:37 +0000 Subject: [PATCH 07/15] Bump lodash from 4.17.11 to 4.17.13 in /js Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.13. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.13) Signed-off-by: dependabot[bot] --- js/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/package-lock.json b/js/package-lock.json index ca1a11d0..a9ce5d18 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -2404,9 +2404,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.13", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.13.tgz", + "integrity": "sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA==" }, "longest": { "version": "1.0.1", From d6995eedc2ce428364d7dbb1e878f8e64f91a23a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2019 18:33:39 +0000 Subject: [PATCH 08/15] Bump mixin-deep from 1.3.1 to 1.3.2 in /js Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2. - [Release notes](https://github.com/jonschlinkert/mixin-deep/releases) - [Commits](https://github.com/jonschlinkert/mixin-deep/compare/1.3.1...1.3.2) Signed-off-by: dependabot[bot] --- js/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/package-lock.json b/js/package-lock.json index ca1a11d0..47e24686 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -2541,9 +2541,9 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", From 81a49160c06368f5520bb449d6b755d8c2ff26fa Mon Sep 17 00:00:00 2001 From: Kyle Boone Date: Thu, 24 Oct 2019 13:53:54 -0700 Subject: [PATCH 09/15] Prevent the context menu from opening on right click. --- js/src/mpl_widget.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index c8c8585d..9945b7e9 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -182,6 +182,8 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ // Disable right mouse context menu. this.rubberband_canvas.addEventListener('contextmenu', function(e) { + event.preventDefault(); + event.stopPropagation(); return false; }); }, From bd36db062a4c8ae53ead6694d47449315469bf2c Mon Sep 17 00:00:00 2001 From: Kyle Boone Date: Thu, 24 Oct 2019 15:48:37 -0700 Subject: [PATCH 10/15] Rate limit text updates --- js/src/mpl_widget.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index c8c8585d..dbd2b130 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -374,6 +374,7 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ mouse_event: function(name) { var that = this; + var last_update = 0; return function(event) { var canvas_pos = utils.get_mouse_position(event); @@ -391,12 +392,18 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ that.canvas_div.focus(); } - var x = canvas_pos.x * that.ratio; - var y = canvas_pos.y * that.ratio; + // Rate-limit the position text updates so that we don't overwhelm the + // system. + if (Date.now() > last_update + 40) { + last_update = Date.now(); - that.send_message(name, {x: x, y: y, button: event.button, - step: event.step, - guiEvent: utils.get_simple_keys(event)}); + var x = canvas_pos.x * that.ratio; + var y = canvas_pos.y * that.ratio; + + that.send_message(name, {x: x, y: y, button: event.button, + step: event.step, + guiEvent: utils.get_simple_keys(event)}); + } /* This prevents the web browser from automatically changing to * the text insertion cursor when the button is pressed. We want From aac46a72b848dd0bcd1173d6654d546de23270af Mon Sep 17 00:00:00 2001 From: Kyle Boone Date: Thu, 24 Oct 2019 18:32:11 -0700 Subject: [PATCH 11/15] Change to "notebook"-like behavior --- js/src/mpl_widget.css | 7 ++++--- js/src/mpl_widget.js | 14 +++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/js/src/mpl_widget.css b/js/src/mpl_widget.css index 8442bd5e..90c0eda1 100644 --- a/js/src/mpl_widget.css +++ b/js/src/mpl_widget.css @@ -1,6 +1,7 @@ .jupyter-matplotlib { - height: 500px; flex: 1 1 auto; + width: auto; + height: auto; } /* Toolbar */ @@ -13,8 +14,8 @@ /* Figure */ .jupyter-matplotlib-figure { - width: 100%; - height: 100%; + width: auto; + height: auto; } .jupyter-matplotlib-canvas_div { diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index bf8d2777..8e780fe1 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -231,6 +231,9 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ this.rubberband_canvas.setAttribute('width', width); this.rubberband_canvas.setAttribute('height', height); + + this.canvas_div.style.width = width + 'px'; + this.canvas_div.style.height = height + 'px'; }, send_message: function(type, message = {}) { @@ -363,17 +366,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ } }, - processPhosphorMessage: function(msg) { - MPLCanvasView.__super__.processPhosphorMessage.apply(this, arguments); - - switch (msg.type) { - case 'resize': - // case 'after-show': - this.request_resize(); - break; - } - }, - mouse_event: function(name) { var that = this; var last_update = 0; From 18157b0e75e484fc0bf673d7c2fd08c1e885e7e8 Mon Sep 17 00:00:00 2001 From: Kyle Boone Date: Tue, 29 Oct 2019 17:30:22 -0700 Subject: [PATCH 12/15] Sync the widget layout interface with matplotlib --- js/src/mpl_widget.css | 6 ++++ js/src/mpl_widget.js | 79 +++++++++++++++++++++++++++++++++++++++---- js/src/utils.js | 35 ++++++++++++++++++- 3 files changed, 113 insertions(+), 7 deletions(-) diff --git a/js/src/mpl_widget.css b/js/src/mpl_widget.css index 90c0eda1..bc5d0b52 100644 --- a/js/src/mpl_widget.css +++ b/js/src/mpl_widget.css @@ -6,8 +6,13 @@ /* Toolbar */ +.jupyter-matplotlib-toolbar { + flex: 0 0 auto; +} + .jupyter-matplotlib-button { width: calc(var(--jp-widgets-inline-width-tiny) / 2 - 2px); + overflow: hidden; padding: 0; } @@ -16,6 +21,7 @@ .jupyter-matplotlib-figure { width: auto; height: auto; + overflow: hidden; } .jupyter-matplotlib-canvas_div { diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index 8e780fe1..32b81822 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -56,8 +56,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ that.model_events(); - window.addEventListener('resize', that.request_resize.bind(that)); - that.send_initialization_message(); }); }, @@ -112,6 +110,8 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ this.el.appendChild(this.toolbar_view.el); } } + + this.request_resize(); }, clear: function() { @@ -123,6 +123,8 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ _init_header: function() { this.header = document.createElement('div'); this.header.style.textAlign = 'center'; + this.header.style.flexGrow = 0; + this.header.style.flexShrink = 0; this.header.classList = 'jupyter-widgets widget-label'; this.figure.appendChild(this.header); }, @@ -212,15 +214,57 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ _init_footer: function() { this.footer = document.createElement('div'); this.footer.style.textAlign = 'center'; + this.header.style.flexGrow = 0; + this.header.style.flexShrink = 0; this.footer.classList = 'jupyter-widgets widget-label'; this.figure.appendChild(this.footer); }, + _calculate_decorations_size: function() { + // Calculate the size of the decorations on the figure. + var decorations_width = 0; + var decorations_height = 0; + + // Toolbar size + var toolbar_position = this.model.get('toolbar_position'); + if (toolbar_position == 'top' || toolbar_position == 'bottom') { + decorations_height += utils.get_full_size(this.toolbar_view.el).height; + } else { + decorations_width += utils.get_full_size(this.toolbar_view.el).width; + } + + // Label sizes + decorations_height += utils.get_full_size(this.header).height; + decorations_height += utils.get_full_size(this.footer).height; + + // Margins on the canvas + var canvas_div_margins = utils.get_margin_size(this.canvas_div); + decorations_width += canvas_div_margins.width; + decorations_height += canvas_div_margins.height; + + // Margins on the figure div + var figure_margins = utils.get_margin_size(this.figure); + decorations_width += figure_margins.width; + decorations_height += figure_margins.height; + + return { + width: decorations_width, + height: decorations_height + }; + }, + request_resize: function() { - // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client, - // which will in turn request a refresh of the image. - var rect = this.canvas_div.getBoundingClientRect(); - this.send_message('resize', {'width': rect.width, 'height': rect.height}); + // Using the given widget size, figure out how big the canvas should be. + var decorations_size = this._calculate_decorations_size(); + + var new_canvas_width = this.el.clientWidth - decorations_size.width; + var new_canvas_height = this.el.clientHeight - decorations_size.height; + + // Ensure that the canvas size is a positive number. + new_canvas_width = new_canvas_width < 1 ? 1 : new_canvas_width; + new_canvas_height = new_canvas_height < 1 ? 1 : new_canvas_height; + + this.send_message('resize', {'width': new_canvas_width, 'height': new_canvas_height}); }, _resize_canvas: function(width, height) { @@ -234,6 +278,13 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ this.canvas_div.style.width = width + 'px'; this.canvas_div.style.height = height + 'px'; + + // Figure out the widget size. + var decorations_size = this._calculate_decorations_size(); + + // Reset the widget size to adapt to this figure. + this.el.style.width = width + decorations_size.width + 'px'; + this.el.style.height = height + decorations_size.height + 'px'; }, send_message: function(type, message = {}) { @@ -366,6 +417,22 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ } }, + processPhosphorMessage: function(msg) { + MPLCanvasView.__super__.processPhosphorMessage.apply(this, arguments); + + switch (msg.type) { + case 'resize': + // Ensure that the image already exists. We ignore the very first call to + // resize because we want the widget to adapt to the figure size set in + // matplotlib. + if (this.image.src) { + this.request_resize(); + } + break; + } + }, + + mouse_event: function(name) { var that = this; var last_update = 0; diff --git a/js/src/utils.js b/js/src/utils.js index de0a6629..b96270e3 100644 --- a/js/src/utils.js +++ b/js/src/utils.js @@ -41,8 +41,41 @@ function get_simple_keys(original) { }, {}); } +/* + * Return the total size of the margins for an element in both width and height. + */ +function get_margin_size(el) { + var style = getComputedStyle(el); + + var margin_width = parseFloat(style.marginLeft) + parseFloat(style.marginRight); + var margin_height = parseFloat(style.marginTop) + parseFloat(style.marginBottom); + + return { + width: margin_width, + height: margin_height, + }; +} + + +/* + * Return the full size of an element, including margins. + */ +function get_full_size(el) { + var margin_size = get_margin_size(el); + + var full_width = el.scrollWidth + margin_size.width; + var full_height = el.scrollHeight + margin_size.height; + + return { + width: full_width, + height: full_height, + }; +} + module.exports = { offset: offset, get_mouse_position: get_mouse_position, - get_simple_keys: get_simple_keys + get_simple_keys: get_simple_keys, + get_margin_size: get_margin_size, + get_full_size: get_full_size, } From a688ecee3bd8ee1360b4ca91ef8648d6037e9a9c Mon Sep 17 00:00:00 2001 From: Kyle Boone Date: Wed, 30 Oct 2019 11:10:34 -0700 Subject: [PATCH 13/15] Only allow resizes after the original matplotlib figure has been created. --- js/src/mpl_widget.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index 32b81822..d62f66cd 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -254,6 +254,13 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ }, request_resize: function() { + // Ensure that the image already exists. We ignore the first calls to resize + // because we want the widget to first adapt to the figure size set in + // matplotlib. + if (!this.image.src) { + return; + } + // Using the given widget size, figure out how big the canvas should be. var decorations_size = this._calculate_decorations_size(); @@ -422,12 +429,7 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ switch (msg.type) { case 'resize': - // Ensure that the image already exists. We ignore the very first call to - // resize because we want the widget to adapt to the figure size set in - // matplotlib. - if (this.image.src) { - this.request_resize(); - } + this.request_resize(); break; } }, From 28e3bf02c2f14ec8f0ec8d128340c380240788f4 Mon Sep 17 00:00:00 2001 From: Kyle Boone Date: Wed, 30 Oct 2019 11:41:02 -0700 Subject: [PATCH 14/15] Change the rate limiting to 60 fps. --- js/src/mpl_widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/mpl_widget.js b/js/src/mpl_widget.js index bf8d2777..3ab1fb87 100644 --- a/js/src/mpl_widget.js +++ b/js/src/mpl_widget.js @@ -396,7 +396,7 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({ // Rate-limit the position text updates so that we don't overwhelm the // system. - if (Date.now() > last_update + 40) { + if (Date.now() > last_update + 16) { last_update = Date.now(); var x = canvas_pos.x * that.ratio; From 1615e84c4e47cbcec841583857dbe1174e7d367d Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Tue, 17 Dec 2019 02:43:43 +0100 Subject: [PATCH 15/15] Release 0.4.0 --- environment.yml | 2 +- ipympl/_version.py | 2 +- js/package-lock.json | 2 +- js/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/environment.yml b/environment.yml index 279203df..e9558ea2 100644 --- a/environment.yml +++ b/environment.yml @@ -4,4 +4,4 @@ channels: dependencies: - numpy - matplotlib-base>=2.2.2 - - ipympl=0.3.3 + - ipympl=0.4.0 diff --git a/ipympl/_version.py b/ipympl/_version.py index 55ff383a..3d7a0fec 100644 --- a/ipympl/_version.py +++ b/ipympl/_version.py @@ -1,2 +1,2 @@ -version_info = (0, 3, 3) +version_info = (0, 4, 0) __version__ = '.'.join(map(str, version_info)) diff --git a/js/package-lock.json b/js/package-lock.json index 4f3c82bc..4ce58bb5 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1,6 +1,6 @@ { "name": "jupyter-matplotlib", - "version": "0.4.2", + "version": "0.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/js/package.json b/js/package.json index bc1b4ac3..0c20dc49 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "jupyter-matplotlib", - "version": "0.4.2", + "version": "0.5.0", "description": "Matplotlib Jupyter Interactive Widget", "author": "Matplotlib Development team", "license": "BSD-3-Clause",