Skip to content

Commit f10c6d9

Browse files
authored
Merge pull request #355 from Dessia-tech/dev
v0.23.0
2 parents bb1ec26 + 78d4abb commit f10c6d9

33 files changed

+1039
-725
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
node_modules/
2-
lib/
3-
libdev/
4-
51
# CAD files
62
*.fcstd
73
*.fcstd1
@@ -26,7 +22,9 @@ downloads/
2622
eggs/
2723
.eggs/
2824
lib/
25+
libdev/
2926
lib64/
27+
node_modules/
3028
parts/
3129
sdist/
3230
var/

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,24 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.23.0]
9+
10+
### Feat
11+
- Add events (Subject) to emit shape hovering and clicking
12+
- Highlight shapes when corresponding function is called from wrapper software
13+
14+
### Fix
15+
- Remove offline mode
16+
17+
### Refactor
18+
- Implements InteractiveObject for handling all mouse objects in one class
19+
820
## [0.22.0]
921
### Add
1022
- Integer axes only show integer ticks
1123
- Handle date as continuous value on axes
1224
- Allow to log scale axes
25+
- Offline mode
1326

1427
### Fix
1528
- Add reference_path to all Primitive / Elementary drawing Objects

cypress/e2e/axes.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ describe('Axis', function() {
2222

2323
axis.draw(context);
2424

25-
cy.wrap(context.fill).should('have.been.calledWith', axis.drawPath);
26-
cy.wrap(context.stroke).should('have.been.calledWith', axis.drawPath);
25+
cy.wrap(context.fill).should('have.been.calledWith', axis.drawnPath);
26+
cy.wrap(context.stroke).should('have.been.calledWith', axis.drawnPath);
2727
});
2828

2929
it('should be well created without vector features', function() {

cypress/e2e/baseShape.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('Shape', function() {
153153
it('should initialize Shape without any arguments', function() {
154154
const shape = new Shape();
155155
expect(shape.path instanceof Path2D, "path").to.be.true;
156-
expect(shape.scaledPath instanceof Path2D, "scaledPath").to.be.true;
156+
expect(shape.drawnPath instanceof Path2D, "drawnPath").to.be.true;
157157
expect(shape.inStrokeScale.y, "inStrokeScale").to.equal(1);
158158
expect(shape.lineWidth, "lineWidth").to.equal(1);
159159
expect(shape.dashLine.length, "dashLine").to.equal(0);
@@ -187,8 +187,8 @@ describe('Shape', function() {
187187

188188
shape.draw(context);
189189

190-
cy.wrap(context.fill).should('have.been.calledWith', shape.scaledPath);
191-
cy.wrap(context.stroke).should('have.been.calledWith', shape.scaledPath);
190+
cy.wrap(context.fill).should('have.been.calledWith', shape.drawnPath);
191+
cy.wrap(context.stroke).should('have.been.calledWith', shape.drawnPath);
192192
});
193193

194194
// Shape can be hovered over

cypress/e2e/figures.cy.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,20 @@ describe("Figure", function() {
122122
]);
123123
scatter.initRubberBandMultiplot(multiplotRubberBands);
124124

125-
expect(multiplotRubberBands, "empty multiplotRubberBands").to.deep.equal(referenceRubberBands);
125+
scatter.axes.forEach(axis => {
126+
expect(multiplotRubberBands.get(axis.name).minValue, `empty rubberband ${axis.name}.minValue`).to.deep.equal(referenceRubberBands.get(axis.name).minValue);
127+
expect(multiplotRubberBands.get(axis.name).maxValue, `empty rubberband ${axis.name}.minValue`).to.deep.equal(referenceRubberBands.get(axis.name).maxValue);
128+
});
126129

127130
scatter.axes[0].rubberBand.minValue = 1;
128131
scatter.axes[0].rubberBand.maxValue = 4;
129132
scatter.axes[1].rubberBand.minValue = 2;
130133
scatter.axes[1].rubberBand.maxValue = 5;
131134
scatter.updateRubberBandMultiplot(multiplotRubberBands);
132-
133-
expect(multiplotRubberBands, "edited multiplotRubberBands").to.deep.equal(referenceRubberBands);
135+
scatter.axes.forEach(axis => {
136+
expect(multiplotRubberBands.get(axis.name).minValue, `edited rubberband ${axis.name}.minValue`).to.deep.equal(referenceRubberBands.get(axis.name).minValue);
137+
expect(multiplotRubberBands.get(axis.name).maxValue, `edited rubberband ${axis.name}.minValue`).to.deep.equal(referenceRubberBands.get(axis.name).maxValue);
138+
});
134139
});
135140
});
136141

@@ -233,12 +238,12 @@ describe("Histogram", function() {
233238

234239
it("should hover/click on bar", function () {
235240
const [canvasMouse, frameMouse, mouseCoords] = histogram.projectMouse({"offsetX": 350, "offsetY": 420} as MouseEvent);
236-
histogram.mouseMove(canvasMouse, frameMouse, mouseCoords);
241+
histogram.castMouseMove(canvasMouse, frameMouse, mouseCoords);
237242
expect(histogram.hoveredIndices[1], "hoveredIndices[1]").to.equal(7);
238243
expect(histogram.hoveredIndices.length, "hoveredIndices.length").to.equal(3);
239244

240-
histogram.mouseDown(canvasMouse, frameMouse, mouseCoords);
241-
histogram.mouseUp(false)
245+
histogram.castMouseDown(canvasMouse, frameMouse, mouseCoords);
246+
histogram.castMouseUp(false)
242247
expect(histogram.clickedIndices[2], "clickedIndices[2]").to.equal(8);
243248
expect(histogram.clickedIndices[0], "clickedIndices[0]").to.equal(6);
244249
});

cypress/e2e/visualRegressions.cy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ FIGURES_DATA.forEach(figureData => {
6666
cy.window().then((win) => {
6767
const draw = win.eval('plot_data');
6868
const [canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 746, "offsetY": 176} as MouseEvent);
69-
draw.mouseMove(canvasMouse, frameMouse, mouseCoords);
70-
draw.mouseDown(canvasMouse, frameMouse, mouseCoords);
71-
draw.mouseUp(false);
69+
draw.castMouseMove(canvasMouse, frameMouse, mouseCoords);
70+
draw.castMouseDown(canvasMouse, frameMouse, mouseCoords);
71+
draw.castMouseUp(false);
7272
draw.draw();
7373
cy.compareSnapshot(describeTitle + this.test.title, 0.05);
7474
});
@@ -78,11 +78,11 @@ FIGURES_DATA.forEach(figureData => {
7878
cy.window().then((win) => {
7979
const draw = win.eval('plot_data');
8080
let [canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 814, "offsetY": 196} as MouseEvent);
81-
draw.mouseMove(canvasMouse, frameMouse, mouseCoords);
81+
draw.castMouseMove(canvasMouse, frameMouse, mouseCoords);
8282
expect(draw.relativeObjects.shapes[23].isHovered).to.be.true;
8383

8484
[canvasMouse, frameMouse, mouseCoords] = draw.projectMouse({"offsetX": 822, "offsetY": 196} as MouseEvent);
85-
draw.mouseMove(canvasMouse, frameMouse, mouseCoords);
85+
draw.castMouseMove(canvasMouse, frameMouse, mouseCoords);
8686
expect(draw.relativeObjects.shapes[23].isHovered).to.be.true;
8787
});
8888
});

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,15 @@
99
"build": "npm run instrument && NODE_ENV=production webpack --config webpack.config.js",
1010
"dev": "npm run instrument && NODE_ENV=development webpack --config webpack-dev.config.cjs",
1111
"cov": "npm run instrument && NODE_ENV=coverage webpack --config webpack-dev.config.cjs",
12-
1312
"format": "prettier --write \"src/**/*.ts\"",
1413
"lint": "tslint -p tsconfig.json",
1514
"start": "http-server -a localhost -p 3030",
16-
1715
"merge_reports": "mochawesome-merge cypress/results/*.json > cypress/results/full_report.json",
1816
"generate_mochawesome_report": "marge cypress/results/full_report.json --reportDir cypress/results",
19-
2017
"cy:run-base": "cypress run --env type=base --browser firefox",
2118
"cy:run-actual": "node ./cypress_run_report.cjs",
2219
"cy:run-open": "cypress open --env type=actual",
2320
"cy:open": "npm run cov & start-server-and-test start http-get://localhost:3030 cy:run-open",
24-
2521
"test": "npm run cov && start-server-and-test start http-get://localhost:3030 cy:run-actual",
2622
"base-test": "npm run cov && start-server-and-test start http-get://localhost:3030 cy:run-base"
2723
},
@@ -78,6 +74,7 @@
7874
"fs": "^0.0.1-security",
7975
"html-webpack-plugin": "^5.5.0",
8076
"ignore-errors": "^2.0.0",
77+
"rxjs": "^7.8.1",
8178
"ts-loader": "^9.2.6",
8279
"typedoc": "^0.23.28",
8380
"webpack": "^5.75.0"

plot_data/core.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,21 @@ def _export_formats(self) -> List[ExportFormat]:
127127
formats.append(ExportFormat(selector="html", extension="html", method_name="to_html_stream", text=False))
128128
return formats
129129

130-
def _to_html(self, debug_mode: bool = False, canvas_id: str = 'canvas', version: str = None):
131-
lib_path = plot_data_path(debug_mode=debug_mode, version=version)
130+
def _to_html(self, local: bool = False, canvas_id: str = 'canvas', version: str = None):
131+
lib_path = plot_data_path(local=local, version=version)
132132
return self.template.substitute(data=json.dumps(self.to_dict()), core_path=lib_path, canvas_id=canvas_id,
133133
width=self.width, height=self.height)
134134

135-
def to_html_stream(self, stream, debug_mode: bool = False, canvas_id: str = 'canvas', version: str = None):
135+
def to_html_stream(self, stream, local: bool = False, canvas_id: str = 'canvas', version: str = None):
136136
""" Export current Figure to its equivalent html stream file. """
137-
html = self._to_html(debug_mode=debug_mode, canvas_id=canvas_id, version=version)
137+
html = self._to_html(local=local, canvas_id=canvas_id, version=version)
138138
stream.write(html)
139139

140-
def to_html(self, filepath: str = None, debug_mode: bool = False, canvas_id: str = 'canvas', version: str = None):
140+
def to_html(self, filepath: str = None, local: bool = False, canvas_id: str = 'canvas', version: str = None):
141141
""" Export current Figure to an HTML file given by the filepath. """
142142
filepath = make_filepath(filepath=filepath)
143143
with open(filepath, 'w', encoding="utf-8") as file:
144-
self.to_html_stream(file, debug_mode=debug_mode, canvas_id=canvas_id, version=version)
144+
self.to_html_stream(file, local=local, canvas_id=canvas_id, version=version)
145145
return filepath
146146

147147
def plot_data(self, **kwargs):
@@ -165,7 +165,6 @@ class Sample(ReferencedObject):
165165

166166
def __init__(self, values, reference_path: str = "#", name: str = ""):
167167
self.values = values
168-
self.reference_path = reference_path
169168
super().__init__(type_="sample", reference_path=reference_path, name=name)
170169

171170
def to_dict(self, use_pointers: bool = True, memo=None, path: str = '#', id_method=True,
@@ -1505,10 +1504,10 @@ def __init__(self, plots: List[PlotDataObject], sizes: List[Window] = None, elem
15051504
super().__init__(width=width, height=height, type_='multiplot', name=name)
15061505

15071506

1508-
def plot_data_path(debug_mode: bool = False, version: str = None):
1507+
def plot_data_path(local: bool = False, version: str = None):
15091508
""" Get path of plot_data package to write it in html file of Figure to draw. """
15101509
version, folder, filename = get_current_link(version=version)
1511-
if debug_mode:
1510+
if local:
15121511
core_path = os.sep.join(os.getcwd().split(os.sep)[:-1] + [folder, filename])
15131512
if os.path.isfile(core_path):
15141513
return core_path.replace(" ", "%20")
@@ -1526,17 +1525,17 @@ def make_filepath(filepath: str = None):
15261525
return filepath
15271526

15281527

1529-
def plot_canvas(plot_data_object: Figure, filepath: str = None, debug_mode: bool = False, canvas_id: str = 'canvas',
1528+
def plot_canvas(plot_data_object: Figure, filepath: str = None, local: bool = False, canvas_id: str = 'canvas',
15301529
force_version: str = None, width: float = None, height: float = None):
15311530
"""
15321531
Creates a html file and plots input data in web browser.
15331532
15341533
:param plot_data_object: a PlotDataObject(ie Scatter, ParallelPlot,\
15351534
MultiplePlots, Graph2D, PrimitiveGroup or PrimitiveGroupContainer)
15361535
:type plot_data_object: PlotDataObject
1537-
:param debug_mode: uses local library if True, uses typescript \
1536+
:param local: uses local library if True, uses typescript \
15381537
library from cdn if False
1539-
:type debug_mode: bool
1538+
:type local: bool
15401539
:param canvas_id: set canvas' id, ie name
15411540
:type canvas_id: str
15421541
:param width: set the canvas' width:
@@ -1550,7 +1549,7 @@ def plot_canvas(plot_data_object: Figure, filepath: str = None, debug_mode: bool
15501549
plot_data_object.width = width
15511550
if height:
15521551
plot_data_object.height = height
1553-
plot_data_object.plot(filepath=filepath, debug_mode=debug_mode, canvas_id=canvas_id, version=force_version)
1552+
plot_data_object.plot(filepath=filepath, local=local, canvas_id=canvas_id, version=force_version)
15541553

15551554

15561555
def write_json_for_tests(plot_data_object: PlotDataObject, json_path: str):

script/graph2D.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# The graph's definition has been moved to test_objects.graph_test.py to
66
# make MultiplePlots.py' imports more convenient
77
plot_data_object = graph2d
8-
plot_data.plot_canvas(plot_data_object=graph2d, canvas_id='canvas', debug_mode=True)
8+
plot_data.plot_canvas(plot_data_object=graph2d, canvas_id='canvas', local=True)

script/histogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
surface_style=plot_data.SurfaceStyle("rgb(50, 50, 220)"),
2323
edge_style=plot_data.EdgeStyle(1, "rgb(0, 255, 0)", [5, 3]))
2424

25-
plot_data.plot_canvas(plot_data_object=plot_data_object, debug_mode=True)
25+
plot_data.plot_canvas(plot_data_object=plot_data_object, local=True)

script/minimal_dataviz.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88

99
import random
10+
import plot_data
1011

1112
random.seed(7)
1213

@@ -37,4 +38,4 @@
3738
multipleplots = plot_data.MultiplePlots(elements=elements, plots=plots,
3839
initial_view_on=True)
3940

40-
plot_data.plot_canvas(plot_data_object=multipleplots, debug_mode=True)
41+
plot_data.plot_canvas(plot_data_object=multipleplots, local=True)

script/multiplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@
7979
plot_data.PointFamily('rgb(146, 178, 78)', [11,21,31,41,25,26,27])])
8080

8181
# Display
82-
plot_data_object.plot(debug_mode=True, canvas_id='canvas')
83-
# plot_data.plot_canvas(plot_data_object=multiplot, debug_mode=True)
82+
plot_data_object.plot(local=True, canvas_id='canvas')
83+
# plot_data.plot_canvas(plot_data_object=multiplot, local=True)

script/networkx_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
text_align_x='center',
1919
text_align_y='middle')))
2020

21-
plot_data.plot_canvas(plotdata_nx_graph, debug_mode=True)
21+
plot_data.plot_canvas(plotdata_nx_graph, local=True)

script/parallel_plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@
5555
disposition=disposition,
5656
rgbs=rgbs)
5757

58-
# if debug_mode == True, set it to False
59-
plot_data.plot_canvas(plot_data_object=plot_data_object, debug_mode=True)
58+
# if local == True, set it to False
59+
plot_data.plot_canvas(plot_data_object=plot_data_object, local=True)

script/plot_scatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@
7373
tooltip=tooltip,
7474
heatmap=heatmap)
7575

76-
# if debug_mode is True, set it to False
77-
plot_data.plot_canvas(plot_data_object=plot_data_object, debug_mode=True)
76+
# if local is True, set it to False
77+
plot_data.plot_canvas(plot_data_object=plot_data_object, local=True)

script/primitive_group_container.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030

3131
plot_data_object = plot_data.PrimitiveGroupsContainer(primitive_groups=primitive_groups)
3232

33-
# if debug_mode is True, set it to False
34-
plot_data.plot_canvas(plot_data_object=plot_data_object, debug_mode=True)
33+
# if local is True, set it to False
34+
plot_data.plot_canvas(plot_data_object=plot_data_object, local=True)

script/scatter_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
})
2121

2222
plot_data_object = plot_data.ScatterMatrix(elements=elements)
23-
plot_data.plot_canvas(plot_data_object=plot_data_object, debug_mode=True)
23+
plot_data.plot_canvas(plot_data_object=plot_data_object, local=True)

script/simple_shapes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
# plot_data_object.mpl_plot()
1717

1818
plot_data_object.save_to_image('primitive_group.png')
19-
plot_data.plot_canvas(plot_data_object=plot_data_object, debug_mode=True)
19+
plot_data.plot_canvas(plot_data_object=plot_data_object, local=True)

script/test_objects/primitive_group_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@
128128
# labels = plot_data.MultipleLabels(labels=[label_custo_1, label_custo_2])
129129
primitives += [label_custo_1, label_custo_2]
130130
primitive_group = plot_data.PrimitiveGroup(primitives=primitives)
131-
# plot_data.plot_canvas(primitive_group, debug_mode=True)
131+
# plot_data.plot_canvas(primitive_group, local=True)

script/text_scaling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ def plot_data(self, pos_y=0.):
121121

122122
ff = primitives + texts
123123
plot_data_object = plot_data.PrimitiveGroup(primitives=ff)
124-
plot_data.plot_canvas(plot_data_object, debug_mode=True)
124+
plot_data.plot_canvas(plot_data_object, local=True)

0 commit comments

Comments
 (0)