Skip to content

Commit ebde1c1

Browse files
committed
Merge branch 'master' of https://github.com/plotly/streambed into share_key_api_v2_access
Conflicts: shelly/plots/tests/test_plots_endpoint.py
2 parents 518d1ce + 001b1e5 commit ebde1c1

39 files changed

+362
-102
lines changed

3d-test-dashboard/testplots/generateImages.js renamed to 3d-test-dashboard/generateImages.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
var plotly = require('plotly')('BenPostlethwaite','hqsfedlbhi');
1+
/*
2+
* Enter your username and api key of your local instance.
3+
*/
4+
var plotly = require('plotly')('etpinard','rmkfg621kv');
5+
plotly.host = 'local.plot.ly';
6+
27
var ProgressBar = require('progress');
38
var fs = require('fs');
49

5-
610
var imgOpts = {
711
format: 'png',
812
width: 1000,
913
height: 600
1014
};
1115

16+
var figDir = './testplots/';
17+
1218
var Bert = {
1319

1420
queue: [],
@@ -65,7 +71,7 @@ var Bert = {
6571
return;
6672
}
6773

68-
var fileStream = fs.createWriteStream(job.name + '.png');
74+
var fileStream = fs.createWriteStream(figDir + job.name + '.png');
6975
imageStream.pipe(fileStream);
7076

7177
self.checkJobProgress();
@@ -74,11 +80,11 @@ var Bert = {
7480
}
7581
};
7682

77-
fs.readdirSync('./').filter(function (plotjson) {
83+
fs.readdirSync(figDir).filter(function (plotjson) {
7884
return plotjson.indexOf('json') !== -1;
7985

8086
}).forEach(function (plotjson) {
81-
var figure = require('./'+plotjson);
87+
var figure = require(figDir + plotjson);
8288
Bert.addsJob({
8389
name: plotjson.split('.json')[0],
8490
workload: figure

3d-test-dashboard/test.js

+3
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ plots['ribbons'] = require('./testplots/ribbons.json');
165165
plots['date-time'] = require('./testplots/scatter-date.json');
166166
plots['cufflinks'] = require('./testplots/cufflinks.json');
167167
plots['chrisp-nan-1'] = require('./testplots/chrisp-nan-1.json');
168+
plots['marker-arrays'] = require('./testplots/marker-arrays.json');
169+
plots['scatter3d-colorscale'] = require('./testplots/scatter3d-colorscale.json');
170+
plots['autocolorscale'] = require('./testplots/autocolorscale.json');
168171

169172

170173
plotButtons(plots);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"data": [
3+
{
4+
"type": "surface",
5+
"z": [
6+
[
7+
8.41,
8+
3,
9+
4
10+
],
11+
[
12+
1,
13+
2,
14+
3
15+
],
16+
[
17+
2,
18+
43,
19+
1
20+
]
21+
],
22+
"autocolorscale": true
23+
}
24+
],
25+
"layout": {
26+
"title": "Simple surface",
27+
"scene": {
28+
"aspectratio": {
29+
"x": 1,
30+
"y": 1,
31+
"z": 1
32+
}
33+
},
34+
"height": 598,
35+
"width": 1080,
36+
"autosize": true,
37+
"showlegend": false
38+
}
39+
}
62.9 KB
Loading
501 Bytes
Loading

3d-test-dashboard/testplots/bunny.png

777 Bytes
Loading
114 KB
Loading
1.72 KB
Loading
114 KB
Loading
-291 Bytes
Loading
38.2 KB
Loading
-625 Bytes
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"data": [
3+
{
4+
"type": "scatter3d",
5+
"x": [
6+
100.75,
7+
157.53,
8+
140.72,
9+
134.03
10+
],
11+
"y": [
12+
-102.63,
13+
-110.53,
14+
-96.97,
15+
-163.59
16+
],
17+
"z": [
18+
-102.63,
19+
-110.53,
20+
-96.97,
21+
-163.59
22+
],
23+
"marker": {
24+
"color": [
25+
"blue",
26+
"red",
27+
"orange",
28+
"black"
29+
],
30+
"line": {
31+
"color": [
32+
"black",
33+
"blue"
34+
],
35+
"width": 1
36+
},
37+
"size": [
38+
10,
39+
20,
40+
30,
41+
40
42+
],
43+
"symbol": [
44+
"circle",
45+
"square",
46+
"cross"
47+
]
48+
},
49+
"uid": "2899cc"
50+
}
51+
],
52+
"layout": {
53+
"title": "Scatter3d arrayOk",
54+
"scene": {
55+
"aspectratio": {
56+
"x": 1,
57+
"y": 1,
58+
"z": 1
59+
}
60+
},
61+
"height": 579,
62+
"width": 1071,
63+
"autosize": true,
64+
"showlegend": false
65+
}
66+
}
41.6 KB
Loading
-320 Bytes
Loading
-551 Bytes
Loading
-449 Bytes
Loading
Loading
Loading
Loading
148 KB
Loading
-25 Bytes
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"data": [
3+
{
4+
"x": [
5+
1,
6+
2,
7+
3,
8+
4,
9+
5
10+
],
11+
"y": [
12+
1,
13+
2,
14+
3,
15+
4,
16+
5
17+
],
18+
"z": [
19+
5,
20+
1,
21+
4,
22+
2,
23+
3
24+
],
25+
"marker": {
26+
"color": [
27+
2,
28+
2,
29+
3,
30+
4,
31+
10
32+
],
33+
"size": [
34+
10,
35+
20,
36+
30,
37+
40,
38+
50
39+
],
40+
"colorscale": "Greens",
41+
"colorbar": {
42+
"title": "WOW"
43+
}
44+
},
45+
"type": "scatter3d",
46+
"mode": "markers"
47+
}
48+
],
49+
"layout": {
50+
"title": "scatter3d + colorbar = <3"
51+
}
52+
}
Loading
-252 Bytes
Loading
3.41 KB
Loading
-375 Bytes
Loading
-362 Bytes
Loading
239 Bytes
Loading
2.35 KB
Loading
-252 Bytes
Loading

shelly/plotlyjs/static/plotlyjs/src/colorscale.js

+41-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
/* global d3:false */
4+
35
var colorscale = module.exports = {},
46
Plotly = require('./plotly'),
57
tinycolor = require('tinycolor2'),
@@ -96,8 +98,8 @@ function isValidScaleArray(scl) {
9698
}
9799
highestVal = +si[0];
98100
}
99-
return isValid;
100-
}
101+
return isValid;
102+
}
101103
}
102104

103105
colorscale.isValidScale = function(scl) {
@@ -131,11 +133,22 @@ colorscale.getScale = function(scl, dflt) {
131133
colorscale.hasColorscale = function(trace, containerStr) {
132134
var container = containerStr ?
133135
Plotly.Lib.nestedProperty(trace, containerStr).get() || {} :
134-
trace;
136+
trace,
137+
color = container.color,
138+
isArrayWithOneNumber = false;
139+
140+
if(Array.isArray(color)) {
141+
for(var i = 0; i < color.length; i++) {
142+
if(isNumeric(color[i])) {
143+
isArrayWithOneNumber = true;
144+
break;
145+
}
146+
}
147+
}
135148

136149
return (
137150
(typeof container==='object' && container!==null) && (
138-
Array.isArray(container.color) ||
151+
isArrayWithOneNumber ||
139152
container.showscale===true ||
140153
(isNumeric(container.cmin) && isNumeric(container.cmax)) ||
141154
colorscale.isValidScale(container.colorscale) ||
@@ -234,3 +247,27 @@ colorscale.calc = function(trace, vals, containerStr, cLetter) {
234247
container[cLetter + 'max'] = max;
235248
container.colorscale = scl;
236249
};
250+
251+
colorscale.makeScaleFunction = function(scl, cmin, cmax) {
252+
var N = scl.length,
253+
domain = new Array(N),
254+
range = new Array(N),
255+
si;
256+
257+
for(var i = 0; i < N; i++) {
258+
si = scl[i];
259+
domain[i] = cmin + si[0] * (cmax - cmin);
260+
range[i] = si[1];
261+
}
262+
263+
var sclFunc = d3.scale.linear()
264+
.domain(domain)
265+
.interpolate(d3.interpolateRgb)
266+
.range(range);
267+
268+
return function(v) {
269+
if(isNumeric(v)) return sclFunc(v);
270+
else if(tinycolor(v).isValid()) return v;
271+
else return Plotly.Color.defaultLine;
272+
};
273+
};

shelly/plotlyjs/static/plotlyjs/src/drawing.js

+10-18
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ drawing.dashLine = function(s, dash, lineWidth) {
9595
'stroke-dasharray': dash,
9696
'stroke-width': lineWidth + 'px'
9797
});
98-
}
98+
};
9999

100100
drawing.fillGroupStyle = function(s) {
101101
s.style('stroke-width',0)
@@ -568,7 +568,7 @@ var SYMBOLDEFS = {
568568
},
569569
needLine: true,
570570
noDot: true
571-
},
571+
}
572572
};
573573

574574
drawing.symbolNames = [];
@@ -711,18 +711,15 @@ drawing.pointStyle = function(s, trace) {
711711
// have a colorscale for it (ie mscl, mcmin, mcmax) - if we do, translate
712712
// all numeric color values according to that scale
713713
drawing.tryColorscale = function(cont, contIn, prefix) {
714-
var colorArray = Plotly.Lib.nestedProperty(cont, prefix+'color').get(),
715-
scl = Plotly.Lib.nestedProperty(cont, prefix+'colorscale').get(),
716-
auto = Plotly.Lib.nestedProperty(cont, prefix+'cauto').get(),
717-
minProp = Plotly.Lib.nestedProperty(cont, prefix+'cmin'),
718-
maxProp = Plotly.Lib.nestedProperty(cont, prefix+'cmax'),
714+
var colorArray = Plotly.Lib.nestedProperty(cont, prefix + 'color').get(),
715+
scl = Plotly.Lib.nestedProperty(cont, prefix + 'colorscale').get(),
716+
auto = Plotly.Lib.nestedProperty(cont, prefix + 'cauto').get(),
717+
minProp = Plotly.Lib.nestedProperty(cont, prefix + 'cmin'),
718+
maxProp = Plotly.Lib.nestedProperty(cont, prefix + 'cmax'),
719719
min = minProp.get(),
720720
max = maxProp.get();
721721

722722
if(scl && Array.isArray(colorArray)) {
723-
if(typeof scl === 'string') scl = Plotly.Color.scales[scl];
724-
if(!scl) scl = Plotly.Color.defaultScale;
725-
726723
if(auto || !isNumeric(min) || !isNumeric(max)) {
727724
min = Infinity;
728725
max = -Infinity;
@@ -738,15 +735,10 @@ drawing.tryColorscale = function(cont, contIn, prefix) {
738735
}
739736
minProp.set(min);
740737
maxProp.set(max);
741-
Plotly.Lib.nestedProperty(contIn, prefix+'cmin').set(min);
742-
Plotly.Lib.nestedProperty(contIn, prefix+'cmax').set(max);
738+
Plotly.Lib.nestedProperty(contIn, prefix + 'cmin').set(min);
739+
Plotly.Lib.nestedProperty(contIn, prefix + 'cmax').set(max);
743740
}
744-
745-
var sclfunc = d3.scale.linear()
746-
.domain(scl.map(function(si){ return min + si[0]*(max-min); }))
747-
.interpolate(d3.interpolateRgb)
748-
.range(scl.map(function(si){ return si[1]; }));
749-
return function(v){ return isNumeric(v) ? sclfunc(v) : v; };
741+
return Plotly.Colorscale.makeScaleFunction(scl, min, max);
750742
}
751743
else return Plotly.Lib.identity;
752744
};

0 commit comments

Comments
 (0)