Skip to content

Commit a32f76f

Browse files
committed
run custom labelformat contours through Axes.tickText
... to get some formatting additions like the correct minus sign
1 parent e7f38c0 commit a32f76f

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

Diff for: src/traces/contour/plot.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -394,21 +394,21 @@ exports.labelFormatter = function(gd, cd0) {
394394
var trace = cd0.trace;
395395
var contours = trace.contours;
396396

397+
var formatAxis = {
398+
type: 'linear',
399+
_id: 'ycontour',
400+
showexponent: 'all',
401+
exponentformat: 'B'
402+
};
403+
397404
if(contours.labelformat) {
398-
return fullLayout._d3locale.numberFormat(contours.labelformat);
405+
formatAxis.tickformat = contours.labelformat;
406+
setConvert(formatAxis, fullLayout);
399407
} else {
400-
var formatAxis;
401408
var cOpts = Colorscale.extractOpts(trace);
402409
if(cOpts && cOpts.colorbar && cOpts.colorbar._axis) {
403410
formatAxis = cOpts.colorbar._axis;
404411
} else {
405-
formatAxis = {
406-
type: 'linear',
407-
_id: 'ycontour',
408-
showexponent: 'all',
409-
exponentformat: 'B'
410-
};
411-
412412
if(contours.type === 'constraint') {
413413
var value = contours.value;
414414
if(Array.isArray(value)) {
@@ -429,10 +429,9 @@ exports.labelFormatter = function(gd, cd0) {
429429
formatAxis._tmin = null;
430430
formatAxis._tmax = null;
431431
}
432-
return function(v) {
433-
return Axes.tickText(formatAxis, v).text;
434-
};
435432
}
433+
434+
return function(v) { return Axes.tickText(formatAxis, v).text; };
436435
};
437436

438437
exports.calcTextOpts = function(level, contourFormat, dummyText, gd) {

Diff for: test/image/baselines/contour_edge_cases.png

-53 Bytes
Loading

0 commit comments

Comments
 (0)