Skip to content

Commit eff392c

Browse files
authored
Merge pull request #334 from Dessia-tech/feat/interactiveobject
[8] Feat/interactiveobject
2 parents 7712142 + dd9b09e commit eff392c

18 files changed

+931
-945
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ downloads/
2222
eggs/
2323
.eggs/
2424
lib/
25+
libdev/
2526
lib64/
2627
node_modules/
2728
parts/

.pre-commit-config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ repos:
66
rev: v3.2.0
77
hooks:
88
- id: trailing-whitespace
9-
exclude: libdev/
109
- id: check-docstring-first
1110
- id: check-json
1211
- id: check-added-large-files
@@ -15,4 +14,3 @@ repos:
1514
- id: requirements-txt-fixer
1615
- id: check-merge-conflict
1716
- id: end-of-file-fixer
18-
exclude: libdev/

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ 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+
### Fix
10+
- Remove offline mode
11+
12+
### Refactor
13+
- Implements InteractiveObject for handling all mouse objects in one class
14+
815
## [0.22.0]
916
### Add
1017
- Integer axes only show integer ticks

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
});

libdev/plot-data.js

Lines changed: 0 additions & 260 deletions
This file was deleted.

0 commit comments

Comments
 (0)