Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6611d1e

Browse filesBrowse files
committed
add makeColorMap tests
1 parent 76e9641 commit 6611d1e
Copy full SHA for 6611d1e

File tree

Expand file treeCollapse file tree

1 file changed

+85
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+85
-0
lines changed
Open diff view settings
Collapse file

‎test/jasmine/tests/contour_test.js‎

Copy file name to clipboardExpand all lines: test/jasmine/tests/contour_test.js
+85Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var Plots = require('@src/plots/plots');
22
var Contour = require('@src/traces/contour');
3+
var makeColorMap = require('@src/traces/contour/make_color_map');
4+
var colorScales = require('@src/components/colorscale/scales');
35

46

57
describe('Test contour', function() {
@@ -47,4 +49,87 @@ describe('Test contour', function() {
4749
expect(traceOut.autocontour).toBe(true);
4850
});
4951
});
52+
53+
describe('makeColorMap', function() {
54+
it('should make correct color map function (\'fill\' coloring case)', function() {
55+
var trace = {
56+
contours: {
57+
coloring: 'fill',
58+
start: -1.5,
59+
size: 0.5,
60+
end: 2.005
61+
},
62+
colorscale: [[
63+
0, 'rgb(12,51,131)'
64+
], [
65+
0.25, 'rgb(10,136,186)'
66+
], [
67+
0.5, 'rgb(242,211,56)'
68+
], [
69+
0.75, 'rgb(242,143,56)'
70+
], [
71+
1, 'rgb(217,30,30)'
72+
]]
73+
};
74+
75+
var colorMap = makeColorMap(trace);
76+
77+
expect(colorMap.domain()).toEqual(
78+
[-1.75, -0.75, 0.25, 1.25, 2.25]
79+
);
80+
81+
expect(colorMap.range()).toEqual([
82+
'rgb(12,51,131)', 'rgb(10,136,186)', 'rgb(242,211,56)',
83+
'rgb(242,143,56)', 'rgb(217,30,30)'
84+
]);
85+
});
86+
87+
it('should make correct color map function (\'heatmap\' coloring case)', function() {
88+
var trace = {
89+
contours: {
90+
coloring: 'heatmap',
91+
start: 1.5,
92+
size: 0.5,
93+
end: 5.505
94+
},
95+
colorscale: colorScales.RdBu,
96+
zmin: 1,
97+
zmax: 6
98+
};
99+
100+
var colorMap = makeColorMap(trace);
101+
102+
expect(colorMap.domain()).toEqual(
103+
[1, 2.75, 3.5, 4, 4.5, 6]
104+
);
105+
106+
expect(colorMap.range()).toEqual([
107+
'rgb(5,10,172)', 'rgb(106,137,247)', 'rgb(190,190,190)',
108+
'rgb(220,170,132)', 'rgb(230,145,90)', 'rgb(178,10,28)'
109+
]);
110+
});
111+
112+
it('should make correct color map function (\'lines\' coloring case)', function() {
113+
var trace = {
114+
contours: {
115+
coloring: 'lines',
116+
start: 1.5,
117+
size: 0.5,
118+
end: 5.505
119+
},
120+
colorscale: colorScales.RdBu
121+
};
122+
123+
var colorMap = makeColorMap(trace);
124+
125+
expect(colorMap.domain()).toEqual(
126+
[1.5, 2.9, 3.5, 3.9, 4.3, 5.5]
127+
);
128+
129+
expect(colorMap.range()).toEqual([
130+
'rgb(5,10,172)', 'rgb(106,137,247)', 'rgb(190,190,190)',
131+
'rgb(220,170,132)', 'rgb(230,145,90)', 'rgb(178,10,28)'
132+
]);
133+
});
134+
});
50135
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.