Skip to content

Commit 8d0a5eb

Browse files
Merge branch 'master' into label_automargin
2 parents d89f23e + 18dac1f commit 8d0a5eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1655
-740
lines changed

.circleci/config.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
version: 2.0
2+
3+
# Inspired by:
4+
# https://github.com/CircleCI-Public/circleci-demo-workflows/blob/workspace-forwarding/.circleci/config.yml
5+
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
6+
7+
jobs:
8+
build:
9+
docker:
10+
- image: circleci/node:6.10.3
11+
working_directory: ~/plotly.js
12+
steps:
13+
- checkout
14+
- restore_cache:
15+
keys:
16+
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package.json" }}
17+
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-master-{{ checksum "package.json" }}
18+
- run:
19+
name: Install dependencies
20+
command: |
21+
npm install
22+
npm dedupe
23+
npm prune
24+
npm install
25+
- run:
26+
name: List dependency versions
27+
command: |
28+
echo "npm: $(npm --version)"
29+
echo "node: $(node --version)"
30+
npm ls || true
31+
- run:
32+
name: Pretest
33+
command: |
34+
npm run pretest
35+
npm run cibuild
36+
- save_cache:
37+
paths:
38+
- node_modules
39+
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package.json" }}
40+
- persist_to_workspace:
41+
root: .
42+
paths:
43+
- node_modules
44+
- build
45+
- dist
46+
47+
test-jasmine:
48+
docker:
49+
# need '-browsers' version to test in real (xvfb-wrapped) browsers
50+
- image: circleci/node:6.10.3-browsers
51+
working_directory: ~/plotly.js
52+
steps:
53+
- checkout
54+
- attach_workspace:
55+
at: ~/plotly.js
56+
- run:
57+
name: Set timezone to Alaska time (arbitrary timezone to test date logic)
58+
command: |
59+
sudo cp /usr/share/zoneinfo/America/Anchorage /etc/localtime
60+
- run:
61+
name: Run jasmine tests
62+
command: ./.circleci/test.sh jasmine
63+
64+
test-image:
65+
docker:
66+
- image: plotly/testbed:latest
67+
working_directory: /var/www/streambed/image_server/plotly.js/
68+
steps:
69+
- checkout
70+
- attach_workspace:
71+
at: /var/www/streambed/image_server/plotly.js/
72+
- run:
73+
name: Run and setup container
74+
command: |
75+
supervisord &
76+
npm run docker -- setup
77+
- run:
78+
name: Run image tests
79+
command: ./.circleci/test.sh image
80+
- store_artifacts:
81+
path: build
82+
83+
test-syntax:
84+
docker:
85+
- image: circleci/node:6.10.3
86+
working_directory: ~/plotly.js
87+
steps:
88+
- checkout
89+
- attach_workspace:
90+
at: ~/plotly.js
91+
- run:
92+
name: Run syntax tests
93+
command: ./.circleci/test.sh syntax
94+
95+
workflows:
96+
version: 2
97+
build-and-test:
98+
jobs:
99+
- build
100+
- test-jasmine:
101+
requires:
102+
- build
103+
- test-image:
104+
requires:
105+
- build
106+
- test-syntax:
107+
requires:
108+
- build

tasks/ci_test.sh renamed to .circleci/test.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
#!/bin/bash
22

3+
# override CircleCi's default run settings
4+
set +e
5+
set +o pipefail
6+
37
EXIT_STATE=0
48

5-
case $CIRCLE_NODE_INDEX in
9+
case $1 in
10+
11+
jasmine)
12+
npm run test-jasmine || EXIT_STATE=$?
13+
npm run test-bundle || EXIT_STATE=$?
14+
exit $EXIT_STATE
15+
;;
616

7-
0)
17+
image)
818
npm run test-image || EXIT_STATE=$?
19+
npm run test-export || EXIT_STATE=$?
920
npm run test-image-gl2d || EXIT_STATE=$?
10-
npm run test-bundle || EXIT_STATE=$?
11-
npm run lint || EXIT_STATE=$?
1221
exit $EXIT_STATE
1322
;;
1423

15-
1)
16-
npm run test-jasmine || EXIT_STATE=$?
17-
npm run test-export || EXIT_STATE=$?
18-
npm run test-syntax || EXIT_STATE=$?
24+
syntax)
25+
npm run lint || EXIT_STATE=$?
26+
npm run test-syntax || EXIT_STATE=$?
1927
exit $EXIT_STATE
2028
;;
2129

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ npm-debug.log*
99
*.sublime*
1010

1111
.*
12+
!.circleci
1213
!.gitignore
1314
!.npmignore
1415
!.eslintrc

circle.yml

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

lib/locales/fr.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ module.exports = {
8484
],
8585
date: '%d/%m/%Y',
8686
decimal: ',',
87-
thousands: ' '
87+
thousands: ' ',
88+
year: '%Y',
89+
month: '%b %Y',
90+
dayMonth: '%-d %b',
91+
dayMonthYear: '%-d %b %Y'
8892
}
8993
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"start-image_viewer": "node devtools/image_viewer/server.js",
4545
"start": "npm run start-test_dashboard",
4646
"baseline": "node tasks/baseline.js",
47-
"preversion": "npm-link-check && npm dedupe",
47+
"preversion": "npm-link-check && npm dedupe && npm ls --prod",
4848
"version": "npm run build && git add -A dist src build",
4949
"postversion": "node -e \"console.log('Version bumped and committed. If ok, run: git push && git push --tags')\""
5050
},

src/components/legend/helpers.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99

1010
'use strict';
1111

12-
var Registry = require('../../registry');
13-
14-
1512
exports.legendGetsTrace = function legendGetsTrace(trace) {
16-
return trace.visible && Registry.traceIs(trace, 'showLegend');
13+
// traceIs(trace, 'showLegend') is not sufficient anymore, due to contour(carpet)?
14+
// which are legend-eligible only if type: constraint. Otherwise, showlegend gets deleted.
15+
16+
// Note that we explicitly include showlegend: false, so a trace that *could* be
17+
// in the legend but is not shown still counts toward the two traces you need to
18+
// ensure the legend is shown by default, because this can still help disambiguate.
19+
return trace.visible && (trace.showlegend !== undefined);
1720
};
1821

1922
exports.isGrouped = function isGrouped(legendLayout) {

src/components/legend/style.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ module.exports = function style(s, gd) {
6060
.each(stylePoints);
6161

6262
function styleLines(d) {
63-
var trace = d[0].trace,
64-
showFill = trace.visible && trace.fill && trace.fill !== 'none',
65-
showLine = subTypes.hasLines(trace);
66-
67-
if(trace && trace._module && trace._module.name === 'contourcarpet') {
68-
showLine = trace.contours.showlines;
69-
showFill = trace.contours.coloring === 'fill';
63+
var trace = d[0].trace;
64+
var showFill = trace.visible && trace.fill && trace.fill !== 'none';
65+
var showLine = subTypes.hasLines(trace);
66+
var contours = trace.contours;
67+
68+
if(contours && contours.type === 'constraint') {
69+
showLine = contours.showlines;
70+
showFill = contours._operation !== '=';
7071
}
7172

7273
var fill = d3.select(this).select('.legendfill').selectAll('path')

src/constants/filter_ops.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright 2012-2018, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
'use strict';
10+
11+
module.exports = {
12+
COMPARISON_OPS: ['=', '!=', '<', '>=', '>', '<='],
13+
COMPARISON_OPS2: ['=', '<', '>=', '>', '<='],
14+
INTERVAL_OPS: ['[]', '()', '[)', '(]', '][', ')(', '](', ')['],
15+
SET_OPS: ['{}', '}{'],
16+
CONSTRAINT_REDUCTION: {
17+
// for contour constraints, open/closed endpoints are equivalent
18+
'=': '=',
19+
20+
'<': '<',
21+
'<=': '<',
22+
23+
'>': '>',
24+
'>=': '>',
25+
26+
'[]': '[]',
27+
'()': '[]',
28+
'[)': '[]',
29+
'(]': '[]',
30+
31+
'][': '][',
32+
')(': '][',
33+
'](': '][',
34+
')[': ']['
35+
}
36+
};

src/lib/dates.js

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -433,18 +433,6 @@ function formatTime(x, tr) {
433433
return timeStr;
434434
}
435435

436-
// TODO: do these strings need to be localized?
437-
// ie this gives "Dec 13, 2017" but some languages may want eg "13-Dec 2017"
438-
var yearFormatD3 = '%Y';
439-
var monthFormatD3 = '%b %Y';
440-
var dayFormatD3 = '%b %-d';
441-
var yearMonthDayFormatD3 = '%b %-d, %Y';
442-
443-
function yearFormatWorld(cDate) { return cDate.formatDate('yyyy'); }
444-
function monthFormatWorld(cDate) { return cDate.formatDate('M yyyy'); }
445-
function dayFormatWorld(cDate) { return cDate.formatDate('M d'); }
446-
function yearMonthDayFormatWorld(cDate) { return cDate.formatDate('M d, yyyy'); }
447-
448436
/*
449437
* formatDate: turn a date into tick or hover label text.
450438
*
@@ -462,49 +450,21 @@ function yearMonthDayFormatWorld(cDate) { return cDate.formatDate('M d, yyyy');
462450
* the axis may choose to strip things after it when they don't change from
463451
* one tick to the next (as it does with automatic formatting)
464452
*/
465-
exports.formatDate = function(x, fmt, tr, formatter, calendar) {
466-
var headStr,
467-
dateStr;
468-
453+
exports.formatDate = function(x, fmt, tr, formatter, calendar, extraFormat) {
469454
calendar = isWorldCalendar(calendar) && calendar;
470455

471-
if(fmt) return modDateFormat(fmt, x, formatter, calendar);
472-
473-
if(calendar) {
474-
try {
475-
var dateJD = Math.floor((x + 0.05) / ONEDAY) + EPOCHJD,
476-
cDate = Registry.getComponentMethod('calendars', 'getCal')(calendar)
477-
.fromJD(dateJD);
478-
479-
if(tr === 'y') dateStr = yearFormatWorld(cDate);
480-
else if(tr === 'm') dateStr = monthFormatWorld(cDate);
481-
else if(tr === 'd') {
482-
headStr = yearFormatWorld(cDate);
483-
dateStr = dayFormatWorld(cDate);
484-
}
485-
else {
486-
headStr = yearMonthDayFormatWorld(cDate);
487-
dateStr = formatTime(x, tr);
488-
}
489-
}
490-
catch(e) { return 'Invalid'; }
491-
}
492-
else {
493-
var d = new Date(Math.floor(x + 0.05));
494-
495-
if(tr === 'y') dateStr = formatter(yearFormatD3)(d);
496-
else if(tr === 'm') dateStr = formatter(monthFormatD3)(d);
456+
if(!fmt) {
457+
if(tr === 'y') fmt = extraFormat.year;
458+
else if(tr === 'm') fmt = extraFormat.month;
497459
else if(tr === 'd') {
498-
headStr = formatter(yearFormatD3)(d);
499-
dateStr = formatter(dayFormatD3)(d);
460+
fmt = extraFormat.dayMonth + '\n' + extraFormat.year;
500461
}
501462
else {
502-
headStr = formatter(yearMonthDayFormatD3)(d);
503-
dateStr = formatTime(x, tr);
463+
return formatTime(x, tr) + '\n' + modDateFormat(extraFormat.dayMonthYear, x, formatter, calendar);
504464
}
505465
}
506466

507-
return dateStr + (headStr ? '\n' + headStr : '');
467+
return modDateFormat(fmt, x, formatter, calendar);
508468
};
509469

510470
/*

src/locale-en.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ module.exports = {
3232
decimal: '.',
3333
thousands: ',',
3434
grouping: [3],
35-
currency: ['$', '']
35+
currency: ['$', ''],
36+
year: '%Y',
37+
month: '%b %Y',
38+
dayMonth: '%b %-d',
39+
dayMonthYear: '%b %-d, %Y'
3640
}
3741
};

src/plots/cartesian/axes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ function formatDate(ax, out, hover, extraPrecision) {
12931293
else tr = {y: 'm', m: 'd', d: 'M', M: 'S', S: 4}[tr];
12941294
}
12951295

1296-
var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar),
1296+
var dateStr = Lib.formatDate(out.x, fmt, tr, ax._dateFormat, ax.calendar, ax._extraFormat),
12971297
headStr;
12981298

12991299
var splitIndex = dateStr.indexOf('\n');

src/plots/cartesian/set_convert.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ module.exports = function setConvert(ax, fullLayout) {
457457
var locale = fullLayout._d3locale;
458458
if(ax.type === 'date') {
459459
ax._dateFormat = locale ? locale.timeFormat.utc : d3.time.format.utc;
460+
ax._extraFormat = fullLayout._extraFormat;
460461
}
461462
// occasionally we need _numFormat to pass through
462463
// even though it won't be needed by this axis

0 commit comments

Comments
 (0)