Skip to content

Commit f362f3b

Browse files
authored
Merge pull request #343 from Dessia-tech/dev
v0.22.0
2 parents 131f369 + a4e6cb3 commit f362f3b

24 files changed

+419
-152
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ 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.22.0]
9+
### Add
10+
- Integer axes only show integer ticks
11+
- Handle date as continuous value on axes
12+
- Allow to log scale axes
13+
14+
### Fix
15+
- Add reference_path to all Primitive / Elementary drawing Objects
16+
- Remove data attr from class Arc in Python
17+
- Light improvement of class Arc in Python
18+
819
## [0.21.0]
920
### Add
1021
- Tests of typescript app

code_pylint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
'trailing-whitespace': 11,
3636
'empty-docstring': 7,
3737
'missing-module-docstring': 4,
38-
'too-many-arguments': 19,
38+
'too-many-arguments': 20,
3939
'too-few-public-methods': 5,
4040
'unnecessary-comprehension': 5,
4141
'no-value-for-parameter': 2,

cypress/e2e/axes.cy.ts

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isIntegerArray } from "../../instrumented/functions";
12
import { Vertex } from "../../instrumented/baseShape";
23
import { Rect } from "../../instrumented/primitives";
34
import { Axis, ParallelAxis } from "../../instrumented/axes";
@@ -30,7 +31,7 @@ describe('Axis', function() {
3031
const ticks = [-1, 0, 1, 2]
3132
expect(axis.ticks).to.deep.equal(ticks);
3233
expect(axis.isDiscrete, `isDiscrete`).to.be.true;
33-
});
34+
});
3435

3536
it('should be well created with empty vector features', function() {
3637
const axis = new Axis([], boundingBox, origin, end, name, initScale, nTicks);
@@ -40,8 +41,19 @@ describe('Axis', function() {
4041
});
4142

4243
it('should be well created without only one feature', function() {
43-
const axis = new Axis([1], boundingBox, origin, end, name, initScale, nTicks);
44-
expect(axis.ticks.length, `length ticks`).to.equal(7);
44+
const axis = new Axis([1.2], boundingBox, origin, end, name, initScale, nTicks);
45+
expect(axis.ticks.length, `length ticks`).to.equal(5);
46+
});
47+
48+
it('should be only show integer ticks', function() {
49+
const axis = new Axis(vector, boundingBox, origin, end, name, initScale, nTicks);
50+
expect(isIntegerArray(axis.ticks), `integer ticks`).to.be.true;
51+
axis.updateScale(new Vertex(20, 20), new Vertex(2, 0.5), new Vertex());
52+
expect(isIntegerArray(axis.ticks), `integer ticks`).to.be.true;
53+
axis.updateScale(new Vertex(20, 20), new Vertex(-2, -0.5), new Vertex());
54+
expect(isIntegerArray(axis.ticks), `integer ticks`).to.be.true;
55+
axis.updateScale(new Vertex(20, 20), new Vertex(10, 0.5), new Vertex());
56+
expect(isIntegerArray(axis.ticks), `integer ticks`).to.be.true;
4557
});
4658

4759
it("should scale axis with another one", function() {
@@ -75,6 +87,13 @@ describe('Axis', function() {
7587
expect(axis.maxValue, "maxValue").to.be.closeTo(8.7, 0.05);
7688
});
7789

90+
it("should scale axis in a logarithmic way", function() {
91+
const axis = new Axis(vector, boundingBox, origin, end, name, initScale, nTicks);
92+
expect(vector.map(element => Math.floor(axis.relativeToAbsolute(element))), "projected values").to.deep.equal([4, 27, 50, 72, 95]);
93+
axis.switchLogScale(vector);
94+
expect(vector.map(element => Math.floor(axis.relativeToAbsolute(element))), "projected log values").to.deep.equal([-19, -12, -8, -5, -3]);
95+
});
96+
7897
it('should update axis with translation and style', function() {
7998
const axis = new Axis(vector, boundingBox, origin, end, name, initScale, nTicks);
8099
const viewPoint = new Vertex(0, 0);
@@ -112,7 +131,43 @@ describe('Axis', function() {
112131

113132
numericStringVector.forEach((value, index) => expect(stringAxis.labels[value], `string value ${index}`).to.equal(stringVector[index]));
114133
numericNumberVector.forEach((value, index) => expect(value, `number value ${index}`).to.equal(numberVector[index]));
115-
})
134+
});
135+
136+
it("should be drawn with date labels", function() {
137+
const timeZoneOffSet = new Date().getTimezoneOffset() * 60;
138+
const dateVector = [
139+
new Date((123456789 + timeZoneOffSet) * 1000),
140+
new Date((234242524 + timeZoneOffSet) * 1000),
141+
new Date((326472910 + timeZoneOffSet) * 1000),
142+
new Date((564927592 + timeZoneOffSet) * 1000),
143+
new Date((675829471 + timeZoneOffSet) * 1000)
144+
];
145+
const dateAxis = new Axis(dateVector, boundingBox, origin, end, name, initScale, nTicks);
146+
const controlLabels = timeZoneOffSet == 0 ?
147+
[
148+
"07/03/1973 - 09:46:40",
149+
"02/05/1976 - 19:33:20",
150+
"05/07/1979 - 05:20:00",
151+
"07/09/1982 - 15:06:40",
152+
"03/11/1985 - 00:53:20",
153+
"05/01/1989 - 10:40:00",
154+
"07/03/1992 - 20:26:40"
155+
]
156+
:
157+
[
158+
"07/03/1973 - 10:46:40",
159+
"02/05/1976 - 21:33:20",
160+
"05/07/1979 - 07:20:00",
161+
"07/09/1982 - 17:06:40",
162+
"03/11/1985 - 01:53:20",
163+
"05/01/1989 - 11:40:00",
164+
"07/03/1992 - 21:26:40"
165+
];
166+
const controlTicks = [100000000000, 200000000000, 300000000000, 400000000000, 500000000000, 600000000000, 700000000000];
167+
expect(dateAxis.labels, "labels").to.deep.equal(controlLabels);
168+
expect(dateAxis.ticks, "labels").to.deep.equal(controlTicks);
169+
170+
});
116171
});
117172

118173
describe("RubberBand", function() {

cypress/e2e/figures.cy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe("Frame", function() {
138138
const data = {
139139
"name": "",
140140
"elements": [
141-
{ "name": "", "values": { "x": 0, "y": 1 }, "x": 0, "y": 1 },
141+
{ "name": "", "values": { "x": 0.1, "y": 1.1 }, "x": 0.1, "y": 1.1 },
142142
{ "name": "", "values": { "x": 1, "y": 2 }, "x": 1, "y": 2 },
143143
{ "name": "", "values": { "x": 2, "y": 3 }, "x": 2, "y": 3 }
144144
]
@@ -148,8 +148,8 @@ describe("Frame", function() {
148148
const frame = new Frame(data, canvas.width, canvas.height, 0, 0, canvasID, false);
149149
expect(frame.xFeature, "xFeature").to.be.equal("x");
150150
expect(frame.yFeature, "yFeature").to.be.equal("y");
151-
expect(frame.axes[0].ticks[0], "axes[0].ticks[0]").to.be.equal(0);
152-
expect(frame.axes[0].ticks[4], "axes[0].ticks[4]").to.be.equal(0.8);
151+
expect(frame.axes[0].ticks[0], "axes[0].ticks[0]").to.be.equal(0.2);
152+
expect(frame.axes[0].ticks[4], "axes[0].ticks[4]").to.be.equal(1);
153153
});
154154

155155
it("should be built with empty attribute_names", function() {
@@ -158,7 +158,7 @@ describe("Frame", function() {
158158
expect(frame.xFeature, "xFeature").to.be.equal("indices");
159159
expect(frame.yFeature, "yFeature").to.be.equal("x");
160160
expect(frame.axes[0].ticks[0], "axes[0].ticks[0]").to.be.equal(0);
161-
expect(frame.axes[0].ticks[4], "axes[0].ticks[4]").to.be.equal(0.8);
161+
expect(frame.axes[0].ticks[2], "axes[0].ticks[2]").to.be.equal(2);
162162
});
163163

164164
it("should change axis feature", function() {
Lines changed: 2 additions & 2 deletions
Loading
Loading
Lines changed: 2 additions & 2 deletions
Loading
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)