diff --git a/CHANGELOG.md b/CHANGELOG.md index 2af509d0..84a605ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.23.0] +## [0.24.0] +### Add +- Allow to directly specify if axes are on or off in Python +### Fix +- LineSegment2D : If it is overloaded, MPL Plot now show the right edge_style instead of generating of random one +- Arc2D: mpl_plot + +## [0.23.0] ### Feat - Add events (Subject) to emit shape hovering and clicking - Highlight shapes when corresponding function is called from wrapper software @@ -16,6 +23,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Refactor - Implements InteractiveObject for handling all mouse objects in one class +## [0.22.5] +### Fix +- Fix global bug on RemoteFigure.resize methods, fixing a browser crasher bug + +## [0.22.4] +### Fix +- Fix bug on tooltip origin when mouse leaving while hovering a shape +- Remove unused code +- Fix html for prettier to work +- Remove name from add plot feature + +## [0.22.2] +### Fix +- Local import +- Add tooltip on any shape with Python with Shape object ## [0.22.0] ### Add diff --git a/code_pylint.py b/code_pylint.py index cc09dbae..62a31ce2 100644 --- a/code_pylint.py +++ b/code_pylint.py @@ -35,7 +35,7 @@ 'trailing-whitespace': 11, 'empty-docstring': 7, 'missing-module-docstring': 4, - 'too-many-arguments': 20, + 'too-many-arguments': 24, 'too-few-public-methods': 5, 'unnecessary-comprehension': 5, 'no-value-for-parameter': 2, diff --git a/cypress/e2e/figures.cy.ts b/cypress/e2e/figures.cy.ts index 472f9b94..6e57f5c8 100644 --- a/cypress/e2e/figures.cy.ts +++ b/cypress/e2e/figures.cy.ts @@ -35,7 +35,8 @@ describe("Figure", function() { { "name": "", "cx": 3, "cy": 3, "type_": "point" }, { "name": "", "cx": 8, "cy": 3, "type_": "point" }, { "name": "", "data": [66, 11.5, 73, 11.5], "point1": [66, 11.5], "point2": [73, 11.5], "type_": "linesegment2d" } - ] + ], + "axis_on": true }; it('should create a new instance of Figure from multiplot data with valid arguments', function() { @@ -209,7 +210,8 @@ describe("Histogram", function() { { "name": "", "values": { "x": 3, "y": 2 }, "x": 3, "y": 2 }, { "name": "", "values": { "x": 4, "y": 3 }, "x": 4, "y": 3 } ], - "type_": "histogram" + "type_": "histogram", + "axis_on": true }; const histogram = new Histogram(data, canvas.width, canvas.height, 0, 0, canvasID, false); histogram.setCanvas(canvas.id); @@ -270,7 +272,8 @@ describe("Scatter", function() { { "name": "", "values": { "x": 3, "y": 2 }, "x": 3, "y": 2 }, { "name": "", "values": { "x": 4, "y": 3 }, "x": 4, "y": 3 } ], - "type_": "scatterplot" + "type_": "scatterplot", + "axis_on": true } const scatter = new Scatter(data, canvas.width, canvas.height, 0, 0, canvasID, false); const frameMatrix = new DOMMatrix([ @@ -334,7 +337,8 @@ describe("Graph2D", function() { ] }, ], - "type_": "graph2d" + "type_": "graph2d", + "axis_on": true } const graph = new Graph2D(data, canvas.width, canvas.height, 0, 0, canvasID, false); @@ -366,7 +370,8 @@ describe("ParallelPlot", function() { { "name": "", "values": { "x": 3, "y": 2, "z": 2 }, "x": 3, "y": 2, "z": 2 }, { "name": "", "values": { "x": 4, "y": 3, "z": 5 }, "x": 4, "y": 3, "z": 5 } ], - "type_": "parallelplot" + "type_": "parallelplot", + "axis_on": true } const parallelplot = new ParallelPlot(data, canvas.width, canvas.height, 0, 0, canvasID, false); parallelplot.setCanvas(canvas.id); diff --git a/cypress/e2e/remoteFigure.cy.ts b/cypress/e2e/remoteFigure.cy.ts index f745ab71..e1e13d6a 100644 --- a/cypress/e2e/remoteFigure.cy.ts +++ b/cypress/e2e/remoteFigure.cy.ts @@ -147,6 +147,16 @@ describe("RemoteFigure.resizeUpdate", function() { }); }); +describe("RemoteFigure.resizeWindow", function() { + it("should resize figure with new window size", function() { + const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id); + figure.setCanvas(canvas.id); + figure.resizeWindow(700, 500); + expect(figure.size.x, "size.x").to.be.equal(700); + expect(figure.size.y, "size.y").to.be.equal(500); + }); +}); + describe("RemoteFigure.reset", function() { it("should reset scales and selectors", function() { const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id); diff --git a/cypress/e2e/visualRegressions.cy.ts b/cypress/e2e/visualRegressions.cy.ts index b51f9e0d..6fee2e1b 100644 --- a/cypress/e2e/visualRegressions.cy.ts +++ b/cypress/e2e/visualRegressions.cy.ts @@ -15,7 +15,7 @@ const FIGURES_DATA = [ { name: "parallelplot", data: parallelPlotData, threshold: 0.05 }, { name: "plotscatter", data: plotScatterData, threshold: 0.05 }, { name: "primitivegroupcontainer", data: primitiveGroupContainerData, threshold: 0.05 }, - { name: "scattermatrix", data: scattermatrixData, threshold: 0.07 }, + { name: "scattermatrix", data: scattermatrixData, threshold: 0.08 }, { name: "simpleshapes", data: simpleshapesData, threshold: 0.05 }, { name: "textscaling", data: textscalingData, threshold: 0.05 }, { name: "multiplot", data: multiplotData, threshold: 0.05 } @@ -77,11 +77,11 @@ FIGURES_DATA.forEach(figureData => { it("should hover line even if mouse is not exactly on line", function () { cy.window().then((win) => { const draw = win.eval('plot_data'); - let [canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 814, "offsetY": 196} as MouseEvent); + let [canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 809, "offsetY": 196} as MouseEvent); draw.castMouseMove(canvasMouse, frameMouse, mouseCoords); expect(draw.relativeObjects.shapes[23].isHovered).to.be.true; - [canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 822, "offsetY": 196} as MouseEvent); + [canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 816, "offsetY": 196} as MouseEvent); draw.castMouseMove(canvasMouse, frameMouse, mouseCoords); expect(draw.relativeObjects.shapes[23].isHovered).to.be.true; }); diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/GRAPH2D -- should draw a nice horizontal parallel plot-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/GRAPH2D -- should draw a nice horizontal parallel plot-base.png index 196e6538..c419a74d 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/GRAPH2D -- should draw a nice horizontal parallel plot-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/GRAPH2D -- should draw a nice horizontal parallel plot-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:783d412bb560327742c6dfd30e751de8a875c7c84e0432ab1815a0dcb64d2ca9 -size 203978 +oid sha256:65f1600224d3c1a80ca0967a6bb7e665f7291d7beda24a217aeb573947795bc8 +size 202822 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/GRAPH2D -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/GRAPH2D -- should draw canvas-base.png index ee6f9ba9..677d0538 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/GRAPH2D -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/GRAPH2D -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ce2a9f1279e7ca25b0ed7e33a83c969d4660aeccf5ba97d57ae6b3f330f87345 -size 120131 +oid sha256:5b9cb1c861edf1d42c27975799cebb6b2186976f49687d36670ffbc73a186b13 +size 119872 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/HISTOGRAM -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/HISTOGRAM -- should draw canvas-base.png index 1eb69b16..072dc8d6 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/HISTOGRAM -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/HISTOGRAM -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6773e01e627de36f3e1c071edf5e485f7bf87f862c35fa9fde9fb9a88b765f41 -size 90175 +oid sha256:6f6a6efd85a0a844ef8dacfc15867f1e2e29f010ba51b3f4c8fb6ef6a8000d6f +size 89885 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/MULTIPLOT -- should draw a canvas with text of empty data-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/MULTIPLOT -- should draw a canvas with text of empty data-base.png index c17bcae8..ec18df99 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/MULTIPLOT -- should draw a canvas with text of empty data-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/MULTIPLOT -- should draw a canvas with text of empty data-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6ff5582c92f85e49ebadf414bc390fb197821dc56489b63c5b8c471ca5ae5600 -size 44887 +oid sha256:5d5a772beb509cd5ef3c9ef318a1e16b8668db9d615a492e6bdc42815d4d94ab +size 40423 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/MULTIPLOT -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/MULTIPLOT -- should draw canvas-base.png index 9967beb7..023cfbcf 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/MULTIPLOT -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/MULTIPLOT -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fac311974e22e5f53cfb6ce583fc97edeb470433252cc275056288b384f72eaf -size 340611 +oid sha256:80068e8162e97d1ade1f796ef0741b430a4338dd2082da3ed420d16f5851758b +size 326178 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/PARALLELPLOT -- should draw a nice horizontal parallel plot-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/PARALLELPLOT -- should draw a nice horizontal parallel plot-base.png index ecb13b7d..aef80c00 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/PARALLELPLOT -- should draw a nice horizontal parallel plot-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/PARALLELPLOT -- should draw a nice horizontal parallel plot-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:79715a26a31e693899b8ad425d7082bb83609eb0b93735dff925e6b787ca532f -size 666550 +oid sha256:dca2e55896a83766925317070951562d19a7282f79b7e801d2fc62fc81792b67 +size 655819 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/PARALLELPLOT -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/PARALLELPLOT -- should draw canvas-base.png index baf17654..04ae3249 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/PARALLELPLOT -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/PARALLELPLOT -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa045b9d43e9db70498aab22bd94b19e8b9492edd1f91ed958d7243da32fc49b -size 592190 +oid sha256:e932008daf3ea9630d0df32a4dc44b6593f82c5ed90de34bd7cea609636bd111 +size 582425 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/PLOTSCATTER -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/PLOTSCATTER -- should draw canvas-base.png index 9f04b432..2bc6fba0 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/PLOTSCATTER -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/PLOTSCATTER -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:121641702687b4528027ab479450d6b2d70b3fb939f8bc7ed029ccd5a7d795f4 -size 144232 +oid sha256:a24c2c7ce6d9d571f719965bb3d226a4429362a5d81cef6e5f8e0702d9220de3 +size 145499 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/PRIMITIVEGROUPCONTAINER -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/PRIMITIVEGROUPCONTAINER -- should draw canvas-base.png index ef5b46db..422f57cd 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/PRIMITIVEGROUPCONTAINER -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/PRIMITIVEGROUPCONTAINER -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4f0791115bb195c2d1cd773708d4c6f4e22845e78a6ab32ad66c186955f88e10 -size 49057 +oid sha256:d1c54f00e7ba8ad6f69d912fb34cb1c0bb6fba58acfdd7904e82c335b39858de +size 39878 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/SCATTERMATRIX -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/SCATTERMATRIX -- should draw canvas-base.png index 0428318e..d77f7357 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/SCATTERMATRIX -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/SCATTERMATRIX -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2f365883c6b55019124706310268e3e05680b43dfead058d715c9a253a73bea7 -size 244378 +oid sha256:6833619c116ddf8d84014339f844d035f203c0e9b3ef91f95bf37ec31df522c6 +size 248539 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/SIMPLESHAPES -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/SIMPLESHAPES -- should draw canvas-base.png index 3b16a76a..67d997e5 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/SIMPLESHAPES -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/SIMPLESHAPES -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10621c3d7060f71ae61e78fc6bbcb085f0fbea52e051a24be29decd245998436 -size 183560 +oid sha256:a9024f19c2cbadd28a00fc5378b71d06d7157763d591de0198e6cde96578bef9 +size 178234 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/SIMPLESHAPES -- should draw tooltip on line-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/SIMPLESHAPES -- should draw tooltip on line-base.png index 1997bc44..6a6541e5 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/SIMPLESHAPES -- should draw tooltip on line-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/SIMPLESHAPES -- should draw tooltip on line-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a82962375538d5c7fb16259421acd1658fc91c5c8ac57b6d12265b5e20849e8e -size 185846 +oid sha256:f0c7893b1f1265d2870f3466376ab23815b0747110801d10d6912115348d388e +size 180862 diff --git a/cypress/snapshots/base/visualRegressions.cy.ts/TEXTSCALING -- should draw canvas-base.png b/cypress/snapshots/base/visualRegressions.cy.ts/TEXTSCALING -- should draw canvas-base.png index 056e90aa..7f77573e 100644 --- a/cypress/snapshots/base/visualRegressions.cy.ts/TEXTSCALING -- should draw canvas-base.png +++ b/cypress/snapshots/base/visualRegressions.cy.ts/TEXTSCALING -- should draw canvas-base.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04aa6af6f2b19427ae9e7aa8f9fb201aa59d52baa57b367ed828d45523b65820 -size 175565 +oid sha256:19edbbd4bff73b3bf395d160b9a0a7ee423baaceee29ef0a3114bbb42369b24f +size 165114 diff --git a/cypress/templates/emptyMultiplot.template.html b/cypress/templates/emptyMultiplot.template.html index 0fa26d9e..9f16d979 100644 --- a/cypress/templates/emptyMultiplot.template.html +++ b/cypress/templates/emptyMultiplot.template.html @@ -1,43 +1,83 @@
-    - - -    - Cluster:  -    - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+ +
+ + +
+
diff --git a/cypress/templates/graph2d.template.html b/cypress/templates/graph2d.template.html index 9f0fc142..61cc84a9 100644 --- a/cypress/templates/graph2d.template.html +++ b/cypress/templates/graph2d.template.html @@ -1,43 +1,77 @@
-    - - -    - Cluster:  -    - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+
diff --git a/cypress/templates/histogram.template.html b/cypress/templates/histogram.template.html index aaf3ec40..e44071c7 100644 --- a/cypress/templates/histogram.template.html +++ b/cypress/templates/histogram.template.html @@ -1,43 +1,79 @@
-    - - -    - Cluster:  -    - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+
+
diff --git a/cypress/templates/multiplot.template.html b/cypress/templates/multiplot.template.html index 950310d4..7f6f0717 100644 --- a/cypress/templates/multiplot.template.html +++ b/cypress/templates/multiplot.template.html @@ -1,44 +1,83 @@
-    - - -    - Cluster:  -    - - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+ +
+ + +
+
diff --git a/cypress/templates/parallelplot.template.html b/cypress/templates/parallelplot.template.html index 75db69b0..1cedf6fc 100644 --- a/cypress/templates/parallelplot.template.html +++ b/cypress/templates/parallelplot.template.html @@ -1,43 +1,79 @@
-    - - -    - Cluster:  -    - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+
+
diff --git a/cypress/templates/plotscatter.template.html b/cypress/templates/plotscatter.template.html index 9798fef4..8a9832f9 100644 --- a/cypress/templates/plotscatter.template.html +++ b/cypress/templates/plotscatter.template.html @@ -21,23 +21,59 @@ background: #04AA6D; cursor: pointer; } + + #buttons { + display: flex; + column-gap: 3rem; + row-gap: 0.5em; + flex-wrap: wrap; + margin-bottom: 0.5rem; + margin-top: 1rem; + margin: 0 auto; + } + + #sub_button { + display: flex; + gap: 0.5rem; + flex-wrap: wrap; + } +
-    - - -    - Cluster:  -    - - - - -
-
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+ +
+
diff --git a/cypress/templates/primitivegroupcontainer.template.html b/cypress/templates/primitivegroupcontainer.template.html index f0e3955d..2d85ebfb 100644 --- a/cypress/templates/primitivegroupcontainer.template.html +++ b/cypress/templates/primitivegroupcontainer.template.html @@ -21,23 +21,59 @@ background: #04AA6D; cursor: pointer; } + + #buttons { + display: flex; + column-gap: 3rem; + row-gap: 0.5em; + flex-wrap: wrap; + margin-bottom: 0.5rem; + margin-top: 1rem; + margin: 0 auto; + } + + #sub_button { + display: flex; + gap: 0.5rem; + flex-wrap: wrap; + } +
-    - - -    - Cluster:  -    - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+
+
diff --git a/cypress/templates/scattermatrix.template.html b/cypress/templates/scattermatrix.template.html index e7746d39..5bd851d8 100644 --- a/cypress/templates/scattermatrix.template.html +++ b/cypress/templates/scattermatrix.template.html @@ -21,24 +21,64 @@ background: #04AA6D; cursor: pointer; } + + #buttons { + display: flex; + column-gap: 3rem; + row-gap: 0.5em; + flex-wrap: wrap; + margin-bottom: 0.5rem; + margin-top: 1rem; + margin: 0 auto; + } + + #sub_button { + display: flex; + gap: 0.5rem; + flex-wrap: wrap; + } +
-    - - -    - Cluster:  -    - - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+ +
+ + +
+
diff --git a/cypress/templates/simpleshapes.template.html b/cypress/templates/simpleshapes.template.html index 87d58575..522721dd 100644 --- a/cypress/templates/simpleshapes.template.html +++ b/cypress/templates/simpleshapes.template.html @@ -2,42 +2,78 @@
-    - - -    - Cluster:  -    - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+
+
diff --git a/cypress/templates/textscaling.template.html b/cypress/templates/textscaling.template.html index 87d58575..522721dd 100644 --- a/cypress/templates/textscaling.template.html +++ b/cypress/templates/textscaling.template.html @@ -2,42 +2,78 @@
-    - - -    - Cluster:  -    - - - - -
+
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + +
+
+
diff --git a/plot_data/core.py b/plot_data/core.py index adbf6ba2..924078e1 100644 --- a/plot_data/core.py +++ b/plot_data/core.py @@ -110,9 +110,10 @@ class Figure(PlotDataObject): _standalone_in_db = True - def __init__(self, type_: str, width: int = 750, height: int = 400, name: str = '', **kwargs): + def __init__(self, type_: str, width: int = 750, height: int = 400, axis_on: bool = True, name: str = '', **kwargs): self.width = width self.height = height + self.axis_on = axis_on PlotDataObject.__init__(self, type_=type_, name=name, **kwargs) @property @@ -160,6 +161,14 @@ def __init__(self, type_: str, reference_path: str = "#", name: str = ""): super().__init__(type_=type_, name=name) +class Shape(ReferencedObject): + """ Shape object. """ + + def __init__(self, type_: str, reference_path: str = "#", tooltip: str = None, name: str = ""): + self.tooltip = tooltip + super().__init__(type_=type_, reference_path=reference_path, name=name) + + class Sample(ReferencedObject): """ Graph Point. """ @@ -426,7 +435,7 @@ def __init__(self, point_color: str, point_index: List[int], name: str = ''): PlotDataObject.__init__(self, type_=None, name=name) -class Text(ReferencedObject): +class Text(Shape): """ A class for displaying texts on canvas. Text is a primitive and can be instantiated by PrimitiveGroup. @@ -450,7 +459,7 @@ class Text(ReferencedObject): def __init__(self, comment: str, position_x: float, position_y: float, text_style: TextStyle = None, text_scaling: bool = None, max_width: float = None, height: float = None, multi_lines: bool = True, - reference_path: str = "#", name: str = ''): + reference_path: str = "#", tooltip: str = None, name: str = ''): self.comment = comment self.text_style = text_style self.position_x = position_x @@ -459,7 +468,7 @@ def __init__(self, comment: str, position_x: float, position_y: float, text_styl self.max_width = max_width self.height = height self.multi_lines = multi_lines - super().__init__(type_='text', reference_path=reference_path, name=name) + super().__init__(type_='text', reference_path=reference_path, tooltip=tooltip, name=name) def mpl_plot(self, ax=None, color='k', alpha=1., **kwargs): """ Plots using Matplotlib. """ @@ -469,7 +478,7 @@ def mpl_plot(self, ax=None, color='k', alpha=1., **kwargs): return ax -class Line2D(ReferencedObject): +class Line2D(Shape): """ An infinite line. Line2D is a primitive and can be instantiated by PrimitiveGroups. @@ -482,19 +491,18 @@ class Line2D(ReferencedObject): """ def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeStyle = None, - reference_path: str = "#", name: str = ''): + reference_path: str = "#", tooltip: str = None, name: str = ''): self.data = point1 + point2 # Retrocompatibility self.point1 = point1 self.point2 = point2 self.edge_style = edge_style - super().__init__(type_='line2d', reference_path=reference_path, name=name) + super().__init__(type_='line2d', reference_path=reference_path, tooltip=tooltip, name=name) def mpl_plot(self, ax=None, edge_style=None, **kwargs): """ Plots using matplotlib. """ if ax is None: _, ax = plt.subplots() - style = self.edge_style if edge_style: style = edge_style color = style.color_stroke.rgb @@ -505,7 +513,7 @@ def mpl_plot(self, ax=None, edge_style=None, **kwargs): return ax -class LineSegment2D(ReferencedObject): +class LineSegment2D(Shape): """ A line segment. This is a primitive that can be called by PrimitiveGroup. @@ -518,17 +526,16 @@ class LineSegment2D(ReferencedObject): """ def __init__(self, point1: List[float], point2: List[float], edge_style: EdgeStyle = None, - reference_path: str = "#", name: str = ''): + reference_path: str = "#", tooltip: str = None, name: str = ''): # Data is used in typescript self.data = point1 + point2 self.point1 = point1 self.point2 = point2 if edge_style is None: - self.edge_style = EdgeStyle() - else: - self.edge_style = edge_style - super().__init__(type_='linesegment2d', reference_path=reference_path, name=name) + edge_style = EdgeStyle() + self.edge_style = edge_style + super().__init__(type_='linesegment2d', reference_path=reference_path, tooltip=tooltip, name=name) def bounding_box(self): """ Get 2D bounding box of current LineSegment2D. """ @@ -546,17 +553,18 @@ def mpl_plot(self, ax=None, edge_style=None, **kwargs): if not ax: _, ax = plt.subplots() - if edge_style: - edge_style = self.edge_style - else: - edge_style = DEFAULT_EDGESTYLE + if edge_style is None: + if self.edge_style: + edge_style = self.edge_style + else: + edge_style = DEFAULT_EDGESTYLE ax.plot([self.point1[0], self.point2[0]], [self.point1[1], self.point2[1]], **edge_style.mpl_arguments(), **kwargs) return ax -class Wire(ReferencedObject): +class Wire(Shape): """ A set of connected lines. It also provides highlighting feature. @@ -572,8 +580,7 @@ def __init__(self, lines: List[Tuple[float, float]], edge_style: EdgeStyle = Non reference_path: str = "#", name: str = ""): self.lines = lines self.edge_style = edge_style - self.tooltip = tooltip - super().__init__(type_="wire", reference_path=reference_path, name=name) + super().__init__(type_="wire", reference_path=reference_path, tooltip=tooltip, name=name) def mpl_plot(self, ax=None, **kwargs): """ Plots using matplotlib. """ @@ -588,7 +595,7 @@ def mpl_plot(self, ax=None, **kwargs): return ax -class Circle2D(ReferencedObject): +class Circle2D(Shape): """ A circle. It is a primitive and can be instantiated by PrimitiveGroup. @@ -613,8 +620,7 @@ def __init__(self, cx: float, cy: float, r: float, edge_style: EdgeStyle = None, self.r = r self.cx = cx self.cy = cy - self.tooltip = tooltip - super().__init__(type_='circle', reference_path=reference_path, name=name) + super().__init__(type_='circle', reference_path=reference_path, tooltip=tooltip, name=name) def bounding_box(self): """ Get 2D bounding box of current Circle2D. """ @@ -628,7 +634,6 @@ def mpl_plot(self, ax=None, **kwargs): edge_style = self.edge_style else: edge_style = DEFAULT_EDGESTYLE - # dashes = DEFAULT_EDGESTYLE.dashline args = edge_style.mpl_arguments(surface=True) if 'dashes' in args: args.pop("dashes") @@ -644,7 +649,7 @@ def mpl_plot(self, ax=None, **kwargs): return ax -class Rectangle(ReferencedObject): +class Rectangle(Shape): """ Class to draw a rectangle. """ def __init__(self, x_coord: float, y_coord: float, width: float, height: float, edge_style: EdgeStyle = None, @@ -655,8 +660,7 @@ def __init__(self, x_coord: float, y_coord: float, width: float, height: float, self.height = height self.surface_style = surface_style self.edge_style = edge_style - self.tooltip = tooltip - super().__init__(type_='rectangle', reference_path=reference_path, name=name) + super().__init__(type_='rectangle', reference_path=reference_path, tooltip=tooltip, name=name) def bounding_box(self): """ Get 2D bounding box of current Circle2D. """ @@ -670,7 +674,6 @@ def mpl_plot(self, ax=None, **kwargs): edge_style = self.edge_style else: edge_style = DEFAULT_EDGESTYLE - # dashes = DEFAULT_EDGESTYLE.dashline args = edge_style.mpl_arguments(surface=True) if 'dashes' in args: args.pop("dashes") @@ -698,7 +701,7 @@ def __init__(self, x_coord: float, y_coord: float, width: float, height: float, self.radius = radius -class Point2D(ReferencedObject): +class Point2D(Shape): """ A class for instantiating a point. @@ -710,11 +713,12 @@ class Point2D(ReferencedObject): :type point_style: PointStyle """ - def __init__(self, cx: float, cy: float, point_style: PointStyle = None, reference_path: str = "#", name: str = ''): + def __init__(self, cx: float, cy: float, point_style: PointStyle = None, reference_path: str = "#", + tooltip: str = None, name: str = ''): self.cx = cx self.cy = cy self.point_style = point_style - super().__init__(type_='point', reference_path=reference_path, name=name) + super().__init__(type_='point', reference_path=reference_path, tooltip=tooltip, name=name) def bounding_box(self): """ Get 2D bounding box of current Circle2D. """ @@ -873,7 +877,7 @@ class Graph2D(Figure): def __init__(self, graphs: List[Dataset], x_variable: str, y_variable: str, axis: Axis = None, log_scale_x: bool = None, log_scale_y: bool = None, width: int = 750, height: int = 400, - name: str = ''): + axis_on: bool = True, name: str = ''): self.graphs = graphs self.attribute_names = [x_variable, y_variable] if axis is None: @@ -882,7 +886,7 @@ def __init__(self, graphs: List[Dataset], x_variable: str, y_variable: str, axis self.axis = axis self.log_scale_x = log_scale_x self.log_scale_y = log_scale_y - super().__init__(width=width, height=height, type_='graph2d', name=name) + super().__init__(width=width, height=height, type_='graph2d', axis_on=axis_on, name=name) def mpl_plot(self, ax=None, **kwargs): """ Plots using matplotlib. """ @@ -1049,7 +1053,7 @@ class Scatter(Figure): def __init__(self, x_variable: str = None, y_variable: str = None, tooltip: Tooltip = None, point_style: PointStyle = None, elements: List[Sample] = None, points_sets: List[PointFamily] = None, axis: Axis = None, log_scale_x: bool = None, log_scale_y: bool = None, heatmap: Heatmap = None, - heatmap_view: bool = None, width: int = 750, height: int = 400, name: str = ''): + heatmap_view: bool = None, width: int = 750, height: int = 400, axis_on: bool = True, name: str = ''): self.tooltip = tooltip self.attribute_names = [x_variable, y_variable] self.point_style = point_style @@ -1076,7 +1080,7 @@ def __init__(self, x_variable: str = None, y_variable: str = None, tooltip: Tool self.heatmap = heatmap self.heatmap_view = heatmap_view self.points_sets = points_sets - super().__init__(width=width, height=height, type_='scatterplot', name=name) + super().__init__(width=width, height=height, type_='scatterplot', axis_on=axis_on, name=name) class ScatterMatrix(Figure): @@ -1086,7 +1090,8 @@ class ScatterMatrix(Figure): _plot_buttons = "MULTIPLOT_BUTTONS" def __init__(self, elements: List[Sample] = None, axes: List[str] = None, point_style: PointStyle = None, - surface_style: SurfaceStyle = None, width: int = 750, height: int = 400, name: str = ""): + surface_style: SurfaceStyle = None, width: int = 750, height: int = 400, axis_on: bool = True, + name: str = ""): if elements is None: elements = [] sampled_elements = [] @@ -1106,7 +1111,7 @@ def __init__(self, elements: List[Sample] = None, axes: List[str] = None, point_ self.surface_style = surface_style self.plots = self._build_multiplot() self.initial_view_on = True - super().__init__(width=width, height=height, type_="multiplot", name=name) + super().__init__(width=width, height=height, type_="multiplot", axis_on=axis_on, name=name) def _build_multiplot(self): sample_attributes = self.elements[0].values.keys() @@ -1114,7 +1119,7 @@ def _build_multiplot(self): for row in sample_attributes for col in sample_attributes] -class Arc2D(ReferencedObject): +class Arc2D(Shape): """ A class for drawing arcs. Arc2D is a primitive and can be instantiated by PrimitiveGroup. By default, the arc is drawn anticlockwise. @@ -1140,7 +1145,7 @@ class Arc2D(ReferencedObject): """ def __init__(self, cx: float, cy: float, r: float, start_angle: float, end_angle: float, clockwise: bool = None, - edge_style: EdgeStyle = None, reference_path: str = "#", name: str = ''): + edge_style: EdgeStyle = None, reference_path: str = "#", tooltip: str = None, name: str = ''): self.cx = cx self.cy = cy self.r = r @@ -1148,7 +1153,7 @@ def __init__(self, cx: float, cy: float, r: float, start_angle: float, end_angle self.end_angle = end_angle self.clockwise = clockwise self.edge_style = edge_style - super().__init__(type_='arc', reference_path=reference_path, name=name) + super().__init__(type_='arc', reference_path=reference_path, tooltip=tooltip, name=name) def bounding_box(self): """ Get 2D bounding box of current Circle2D. """ @@ -1172,17 +1177,20 @@ def mpl_plot(self, ax=None, **kwargs): kwargs.pop("edge_style") else: edgecolor = plot_data.colors.BLACK.rgb + theta1, theta2 = self.start_angle, self.end_angle + if self.clockwise: + theta1, theta2 = self.end_angle, self.start_angle ax.add_patch( Arc((self.cx, self.cy), 2 * self.r, 2 * self.r, angle=0, - theta1=self.start_angle * 0.5 / math.pi * 360, - theta2=self.end_angle * 0.5 / math.pi * 360, + theta1=theta1 * 0.5 / math.pi * 360, + theta2=theta2 * 0.5 / math.pi * 360, edgecolor=edgecolor), **kwargs) return ax -class Contour2D(ReferencedObject): +class Contour2D(Shape): """ A Contour2D is a closed polygon that is formed by multiple primitives. @@ -1202,9 +1210,8 @@ def __init__(self, plot_data_primitives: List[Union[Arc2D, LineSegment2D]], edge self.plot_data_primitives = plot_data_primitives self.edge_style = edge_style self.surface_style = surface_style - self.tooltip = tooltip self.is_filled = surface_style is not None - super().__init__(type_='contour', reference_path=reference_path, name=name) + super().__init__(type_='contour', reference_path=reference_path, tooltip=tooltip, name=name) def bounding_box(self): """ Get 2D bounding box of current Contour2D. """ @@ -1294,10 +1301,10 @@ class PrimitiveGroup(Figure): def __init__(self, primitives: List[Union[Contour2D, Arc2D, LineSegment2D, Circle2D, Line2D, MultipleLabels, Wire, Point2D]], width: int = 750, - height: int = 400, attribute_names: List[str] = None, name: str = ''): + height: int = 400, attribute_names: List[str] = None, axis_on: bool = False, name: str = ''): self.primitives = primitives self.attribute_names = attribute_names - super().__init__(width=width, height=height, type_='draw', name=name) + super().__init__(width=width, height=height, type_='draw', axis_on=axis_on, name=name) def mpl_plot(self, ax=None, equal_aspect=True, **kwargs): """ Plots using matplotlib. """ @@ -1355,7 +1362,8 @@ class PrimitiveGroupsContainer(Figure): def __init__(self, primitive_groups: List[PrimitiveGroup], sizes: List[Tuple[float, float]] = None, coords: List[Tuple[float, float]] = None, associated_elements: List[int] = None, - x_variable: str = None, y_variable: str = None, width: int = 750, height: int = 400, name: str = ''): + x_variable: str = None, y_variable: str = None, width: int = 750, height: int = 400, + axis_on: bool = True, name: str = ''): for i, value in enumerate(primitive_groups): if not isinstance(value, PrimitiveGroup): primitive_groups[i] = PrimitiveGroup(primitives=value) @@ -1373,7 +1381,7 @@ def __init__(self, primitive_groups: List[PrimitiveGroup], sizes: List[Tuple[flo if y_variable: attribute_names.append(y_variable) self.association['attribute_names'] = attribute_names - super().__init__(width=width, height=height, type_='primitivegroupcontainer', name=name) + super().__init__(width=width, height=height, type_='primitivegroupcontainer', axis_on=axis_on, name=name) class ParallelPlot(Figure): @@ -1394,7 +1402,7 @@ class ParallelPlot(Figure): def __init__(self, elements: List[Sample] = None, edge_style: EdgeStyle = None, disposition: str = None, axes: List[str] = None, rgbs: List[Tuple[int, int, int]] = None, width: int = 750, height: int = 400, - name: str = ''): + axis_on: bool = True, name: str = ''): if elements is None: elements = [] sampled_elements = [] @@ -1413,7 +1421,7 @@ def __init__(self, elements: List[Sample] = None, edge_style: EdgeStyle = None, self.disposition = disposition self.attribute_names = axes self.rgbs = rgbs - super().__init__(width=width, height=height, type_='parallelplot', name=name) + super().__init__(width=width, height=height, type_='parallelplot', axis_on=axis_on, name=name) class Histogram(Figure): @@ -1441,7 +1449,7 @@ class Histogram(Figure): def __init__(self, x_variable: str, elements=None, axis: Axis = None, graduation_nb: float = None, edge_style: EdgeStyle = None, surface_style: SurfaceStyle = None, width: int = 750, height: int = 400, - name: str = ''): + axis_on: bool = True, name: str = ''): if elements is None: elements = [] sampled_elements = [] @@ -1461,7 +1469,7 @@ def __init__(self, x_variable: str, elements=None, axis: Axis = None, graduation self.graduation_nb = graduation_nb self.edge_style = edge_style self.surface_style = surface_style - super().__init__(width=width, height=height, type_='histogram', name=name) + super().__init__(width=width, height=height, type_='histogram', axis_on=axis_on, name=name) class MultiplePlots(Figure): @@ -1481,7 +1489,8 @@ class MultiplePlots(Figure): def __init__(self, plots: List[PlotDataObject], sizes: List[Window] = None, elements: List[Sample] = None, coords: List[Tuple[float, float]] = None, point_families: List[PointFamily] = None, - initial_view_on: bool = None, width: int = 750, height: int = 400, name: str = ''): + initial_view_on: bool = None, width: int = 750, height: int = 400, axis_on: bool = True, + name: str = ''): if elements is None: elements = [] sampled_elements = [] @@ -1501,14 +1510,14 @@ def __init__(self, plots: List[PlotDataObject], sizes: List[Window] = None, elem self.coords = coords self.points_sets = point_families self.initial_view_on = initial_view_on - super().__init__(width=width, height=height, type_='multiplot', name=name) + super().__init__(width=width, height=height, type_='multiplot', axis_on=axis_on, name=name) def plot_data_path(local: bool = False, version: str = None): """ Get path of plot_data package to write it in html file of Figure to draw. """ version, folder, filename = get_current_link(version=version) if local: - core_path = os.sep.join(os.getcwd().split(os.sep)[:-1] + [folder, filename]) + core_path = os.sep.join(__file__.split(os.sep)[:-2] + [folder, filename]) if os.path.isfile(core_path): return core_path.replace(" ", "%20") print(f'Local compiled {core_path} not found, fall back to CDN') diff --git a/plot_data/templates.py b/plot_data/templates.py index 5345de6e..6b11a064 100644 --- a/plot_data/templates.py +++ b/plot_data/templates.py @@ -28,36 +28,63 @@ background: #04AA6D; cursor: pointer; } + + #buttons { + display: flex; + column-gap: 3rem; + row-gap: 0.5em; + flex-wrap: wrap; + margin-bottom: 0.5rem; + margin-top: 1rem; + margin: 0 auto; + } + + #sub_button { + display: flex; + gap: 0.5rem; + flex-wrap: wrap; + } +
-    - - -    - Cluster:  -    -    - - - - +
+ +
+
+ + + +
+
+ Cluster: + +
+
+ + + + + + +
$specific_buttons -
+
- +