Skip to content

Commit 05dc1bf

Browse files
committed
Merge remote-tracking branch 'origin/master' into finalist-cluster-scattermapbox
2 parents 050c3bc + 437f70e commit 05dc1bf

Some content is hidden

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

41 files changed

+558
-418
lines changed

.circleci/download_google_fonts.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ def download(repo, family, types) :
1010
req = requests.get(url, allow_redirects=True)
1111
open(dirOut + name, 'wb').write(req.content)
1212

13-
download(
14-
'https://github.com/eliheuer/dosis-vf/blob/master/fonts/static-fonts/',
15-
'Dosis',
16-
[
17-
'-Regular',
18-
'-Bold'
19-
]
20-
)
21-
2213
download(
2314
'https://github.com/googlefonts/noto-fonts/blob/main/hinted/ttf/NotoSansMono/',
2415
'NotoSansMono',

CONTRIBUTING.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,33 @@ We use the following [labels](https://github.com/plotly/plotly.js/labels) to tra
8484
[`package-lock.json`](https://docs.npmjs.com/files/package-lock.json) file is
8585
used and updated correctly.
8686

87-
#### Step 1: Clone the plotly.js repo and install its dependencies
87+
#### Step 1: Fork the plotly.js repository, clone your fork and step into it
8888

8989
```bash
90-
git clone https://github.com/plotly/plotly.js.git
90+
git clone --depth 1 git@github.com:<your-GitHub-username>/plotly.js.git
9191
cd plotly.js
92+
```
93+
94+
#### Step 2: Switch to a dev branch
95+
96+
```bash
97+
# please do not use master or main for your dev branch
98+
git checkout dev-branch-name
99+
```
100+
101+
#### Step 3: Install dependencies
102+
103+
```bash
92104
npm install
93105
```
94106

95-
#### Step 2: Setup test environment
107+
#### Step 4: Setup test environment
96108

97109
```bash
98110
npm run pretest
99111
```
100112

101-
#### Step 3: Start the test dashboard
113+
#### Step 5: Start the test dashboard
102114

103115
```bash
104116
npm start
@@ -110,7 +122,7 @@ This command bundles up the source files with source maps using
110122
dev plotly.js bundle update every time a source file is saved) and opens up a
111123
tab in your browser.
112124

113-
#### Step 4: Open up the console and start developing
125+
#### Step 6: Open up the console and start developing
114126

115127
A typical workflow is to make some modifications to the source, update the
116128
test dashboard, inspect and debug the changes, then repeat. The test dashboard
@@ -138,13 +150,13 @@ Three additional helpers exist that are refreshed every second:
138150
There is also a search bar in the top right of the dashboard. This fuzzy-searches
139151
image mocks based on their file name and trace type.
140152

141-
#### Step 5: Regenerate plot-schema in "test" folder then review & commit potential changes
153+
#### Step 7: Regenerate plot-schema in "test" folder then review & commit potential changes
142154

143155
```bash
144156
npm run schema
145157
```
146158

147-
#### Step 6: Review & commit potential changes made to test/plot-schema.json
159+
#### Step 8: Review & commit potential changes made to test/plot-schema.json
148160

149161
> If you are editing attribute descriptions or implementing a new feature this file located in the test folder records the proposed changes to the API. Note that there is another plot-schema.json file located in the dist folder, which should only be updated by the maintainers at release time.
150162

draftlogs/5615_add.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add new formatting options by replacing `d3.format` method with more recent `d3-format` module [[#5615](https://github.com/plotly/plotly.js/pull/5615)]

draftlogs/5673_change.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Relax the valType of `constraintrange` in `parcoords` trace [[#5673](https://github.com/plotly/plotly.js/pull/5673)]
2+

draftlogs/5771_fix.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Allow clickable legend group titles when group has no pie-like traces [[#5771](https://github.com/plotly/plotly.js/pull/5771)]
2+

draftlogs/5791_change.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Adjust CONTRIBUTING document on how to clone plotly.js and submit pull requests from your fork [[#5791](https://github.com/plotly/plotly.js/pull/5791)]

draftlogs/5813_change.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Sort object key values in schema [[#5813](https://github.com/plotly/plotly.js/pull/5813)]

package-lock.json

Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
]
6767
},
6868
"dependencies": {
69-
"@plotly/d3": "3.7.0",
69+
"@plotly/d3": "3.8.0",
7070
"@plotly/d3-sankey": "0.7.2",
7171
"@plotly/d3-sankey-circular": "0.33.1",
7272
"@plotly/point-cluster": "^3.1.9",
@@ -82,10 +82,12 @@
8282
"convex-hull": "^1.0.3",
8383
"country-regex": "^1.1.0",
8484
"d3-force": "^1.2.1",
85+
"d3-format": "^1.4.5",
8586
"d3-geo": "^1.12.1",
8687
"d3-geo-projection": "^2.9.0",
8788
"d3-hierarchy": "^1.1.9",
8889
"d3-interpolate": "^1.4.0",
90+
"d3-time": "^1.1.0",
8991
"d3-time-format": "^2.2.3",
9092
"delaunay-triangulate": "^1.1.6",
9193
"fast-isnumeric": "^1.1.4",

src/components/calendars/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var ONEDAY = constants.ONEDAY;
1010

1111
var attributes = {
1212
valType: 'enumerated',
13-
values: Object.keys(calendars.calendars),
13+
values: Lib.sortObjectKeys(calendars.calendars),
1414
editType: 'calc',
1515
dflt: 'gregorian'
1616
};

src/components/colorscale/attributes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
var colorbarAttrs = require('../colorbar/attributes');
44
var counterRegex = require('../../lib/regex').counter;
5+
var sortObjectKeys = require('../../lib/sort_object_keys');
56

67
var palettes = require('./scales.js').scales;
7-
var paletteStr = Object.keys(palettes);
8+
var paletteStr = sortObjectKeys(palettes);
89

910
function code(s) {
1011
return '`' + s + '`';

src/components/drawing/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use strict';
22

33
var d3 = require('@plotly/d3');
4+
var Lib = require('../../lib');
5+
var numberFormat = Lib.numberFormat;
46
var isNumeric = require('fast-isnumeric');
57
var tinycolor = require('tinycolor2');
68

79
var Registry = require('../../registry');
810
var Color = require('../color');
911
var Colorscale = require('../colorscale');
10-
var Lib = require('../../lib');
1112
var strTranslate = Lib.strTranslate;
1213
var svgTextUtils = require('../../lib/svg_text_utils');
1314

@@ -275,7 +276,7 @@ function makePointPath(symbolNumber, r) {
275276

276277
var HORZGRADIENT = {x1: 1, x2: 0, y1: 0, y2: 0};
277278
var VERTGRADIENT = {x1: 0, x2: 0, y1: 1, y2: 0};
278-
var stopFormatter = d3.format('~.1f');
279+
var stopFormatter = numberFormat('~f');
279280
var gradientInfo = {
280281
radial: {node: 'radialGradient'},
281282
radialreversed: {node: 'radialGradient', reversed: true},

src/components/legend/get_legend_data.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ module.exports = function getLegendData(calcdata, opts) {
118118
legendData[i].forEach(function(a, k) { a._preSort = k; });
119119
legendData[i].sort(orderFn2);
120120

121-
var firstItem = legendData[i][0];
121+
var firstItemTrace = legendData[i][0].trace;
122122

123123
var groupTitle = null;
124124
// get group title text
@@ -134,12 +134,23 @@ module.exports = function getLegendData(calcdata, opts) {
134134
if(reversed) legendData[i].reverse();
135135

136136
if(groupTitle) {
137+
var hasPieLike = false;
138+
for(j = 0; j < legendData[i].length; j++) {
139+
if(Registry.traceIs(legendData[i][j].trace, 'pie-like')) {
140+
hasPieLike = true;
141+
break;
142+
}
143+
}
144+
137145
// set group title text
138146
legendData[i].unshift({
139147
i: -1,
140148
groupTitle: groupTitle,
149+
noClick: hasPieLike,
141150
trace: {
142-
showlegend: firstItem.trace.showlegend
151+
showlegend: firstItemTrace.showlegend,
152+
legendgroup: firstItemTrace.legendgroup,
153+
visible: firstItemTrace.visible
143154
}
144155
});
145156
}

src/components/legend/handle_click.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = function handleClick(g, gd, numClicks) {
3232
[];
3333

3434
var legendItem = g.data()[0][0];
35-
if(legendItem.groupTitle) return; // no click on group legends for now
35+
if(legendItem.groupTitle && legendItem.noClick) return;
3636

3737
var fullData = gd._fullData;
3838
var fullTrace = legendItem.trace;

src/components/rangeselector/get_update_object.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
var d3 = require('@plotly/d3');
3+
var d3Time = require('d3-time');
4+
var titleCase = require('../../lib').titleCase;
45

56
module.exports = function getUpdateObject(axisLayout, buttonLayout) {
67
var axName = axisLayout._name;
@@ -22,18 +23,21 @@ function getXRange(axisLayout, buttonLayout) {
2223
var currentRange = axisLayout.range;
2324
var base = new Date(axisLayout.r2l(currentRange[1]));
2425
var step = buttonLayout.step;
26+
27+
var utcStep = d3Time['utc' + titleCase(step)];
28+
2529
var count = buttonLayout.count;
2630
var range0;
2731

2832
switch(buttonLayout.stepmode) {
2933
case 'backward':
30-
range0 = axisLayout.l2r(+d3.time[step].utc.offset(base, -count));
34+
range0 = axisLayout.l2r(+utcStep.offset(base, -count));
3135
break;
3236

3337
case 'todate':
34-
var base2 = d3.time[step].utc.offset(base, -count);
38+
var base2 = utcStep.offset(base, -count);
3539

36-
range0 = axisLayout.l2r(+d3.time[step].utc.ceil(base2));
40+
range0 = axisLayout.l2r(+utcStep.ceil(base2));
3741
break;
3842
}
3943

src/constants/docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

33
module.exports = {
4-
FORMAT_LINK: 'https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_format',
4+
FORMAT_LINK: 'https://github.com/d3/d3-format/tree/v1.4.5#d3-format',
55
DATE_FORMAT_LINK: 'https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format'
66
};

src/lib/index.js

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,56 @@
22

33
var d3 = require('@plotly/d3');
44
var utcFormat = require('d3-time-format').utcFormat;
5+
var d3Format = require('d3-format').format;
56
var isNumeric = require('fast-isnumeric');
67

78
var numConstants = require('../constants/numerical');
89
var MAX_SAFE = numConstants.FP_SAFE;
910
var MIN_SAFE = -MAX_SAFE;
1011
var BADNUM = numConstants.BADNUM;
1112

12-
var lib = module.exports = {
13-
_numberFormat: d3.format // simply to test d3.format before switching to d3-format
13+
var lib = module.exports = {};
14+
15+
lib.adjustFormat = function adjustFormat(formatStr) {
16+
if(
17+
!formatStr ||
18+
/^\d[.]\df/.test(formatStr) ||
19+
/[.]\d%/.test(formatStr)
20+
) return formatStr;
21+
22+
if(formatStr === '0.f') return '~f';
23+
if(/^\d%/.test(formatStr)) return '~%';
24+
if(/^\ds/.test(formatStr)) return '~s';
25+
26+
// try adding tilde to the start of format in order to trim
27+
if(!(/^[~,.0$]/.test(formatStr)) && /[&fps]/.test(formatStr)) return '~' + formatStr;
28+
29+
return formatStr;
30+
};
31+
32+
var seenBadFormats = {};
33+
lib.warnBadFormat = function(f) {
34+
var key = String(f);
35+
if(!seenBadFormats[key]) {
36+
seenBadFormats[key] = 1;
37+
lib.warn('encountered bad format: "' + key + '"');
38+
}
39+
};
40+
41+
lib.noFormat = function(value) {
42+
return String(value);
43+
};
44+
45+
lib.numberFormat = function(formatStr) {
46+
var fn;
47+
try {
48+
fn = d3Format(lib.adjustFormat(formatStr));
49+
} catch(e) {
50+
lib.warnBadFormat(formatStr);
51+
return lib.noFormat;
52+
}
53+
54+
return fn;
1455
};
1556

1657
lib.nestedProperty = require('./nested_property');
@@ -67,6 +108,8 @@ lib.roundUp = searchModule.roundUp;
67108
lib.sort = searchModule.sort;
68109
lib.findIndexOfMin = searchModule.findIndexOfMin;
69110

111+
lib.sortObjectKeys = require('./sort_object_keys');
112+
70113
var statsModule = require('./stats');
71114
lib.aggNums = statsModule.aggNums;
72115
lib.len = statsModule.len;
@@ -1120,7 +1163,7 @@ function templateFormatString(string, labels, d3locale) {
11201163
if(format) {
11211164
var fmt;
11221165
if(format[0] === ':') {
1123-
fmt = d3locale ? d3locale.numberFormat : d3.format;
1166+
fmt = d3locale ? d3locale.numberFormat : lib.numberFormat;
11241167
value = fmt(format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''))(value);
11251168
}
11261169

src/lib/sort_object_keys.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = function sortObjectKeys(obj) {
4+
return Object.keys(obj).sort();
5+
};

src/plots/cartesian/dragbox.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'use strict';
22

33
var d3 = require('@plotly/d3');
4+
var Lib = require('../../lib');
5+
var numberFormat = Lib.numberFormat;
46
var tinycolor = require('tinycolor2');
57
var supportsPassive = require('has-passive-events');
68

79
var Registry = require('../../registry');
8-
var Lib = require('../../lib');
910
var strTranslate = Lib.strTranslate;
1011
var svgTextUtils = require('../../lib/svg_text_utils');
1112
var Color = require('../../components/color');
@@ -1029,11 +1030,11 @@ function getEndText(ax, end) {
10291030
return initialVal;
10301031
} else if(ax.type === 'log') {
10311032
dig = Math.ceil(Math.max(0, -Math.log(diff) / Math.LN10)) + 3;
1032-
return d3.format('.' + dig + 'g')(Math.pow(10, initialVal));
1033+
return numberFormat('.' + dig + 'g')(Math.pow(10, initialVal));
10331034
} else { // linear numeric (or category... but just show numbers here)
10341035
dig = Math.floor(Math.log(Math.abs(initialVal)) / Math.LN10) -
10351036
Math.floor(Math.log(diff) / Math.LN10) + 4;
1036-
return d3.format('.' + String(dig) + 'g')(initialVal);
1037+
return numberFormat('.' + String(dig) + 'g')(initialVal);
10371038
}
10381039
}
10391040

0 commit comments

Comments
 (0)