Skip to content

Commit 11a75d9

Browse files
committed
centralized fn Lib.beginCap to work with new d3 methods
1 parent a425925 commit 11a75d9

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/components/rangeselector/get_update_object.js

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

33
var d3Time = require('d3-time');
4+
var beginCap = require('../../lib').beginCap;
45

56
module.exports = function getUpdateObject(axisLayout, buttonLayout) {
67
var axName = axisLayout._name;
@@ -23,10 +24,7 @@ function getXRange(axisLayout, buttonLayout) {
2324
var base = new Date(axisLayout.r2l(currentRange[1]));
2425
var step = buttonLayout.step;
2526

26-
var utcStep = d3Time['utc' +
27-
// Capitalized step e.g. month -> Month
28-
(step.charAt(0).toUpperCase() + step.slice(1))
29-
];
27+
var utcStep = d3Time['utc' + beginCap(step)];
3028

3129
var count = buttonLayout.count;
3230
var range0;

src/lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,10 @@ lib.bigFont = function(size) {
13471347
return Math.round(1.2 * size);
13481348
};
13491349

1350+
lib.beginCap = function(str) {
1351+
return str.charAt(0).toUpperCase() + str.slice(1);
1352+
};
1353+
13501354
var firefoxVersion = lib.getFirefoxVersion();
13511355
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1684973
13521356
var isProblematicFirefox = firefoxVersion !== null && firefoxVersion < 86;

src/plots/geo/geo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ function getProjection(geoLayout) {
643643

644644
var projName = constants.projNames[projType];
645645
// uppercase the first letter and add geo to the start of method name
646-
projName = 'geo' + projName.charAt(0).toUpperCase() + projName.slice(1);
646+
projName = 'geo' + Lib.beginCap(projName);
647647
var projFn = geo[projName] || geoProjection[projName];
648648
var projection = projFn();
649649

0 commit comments

Comments
 (0)