diff --git a/src/traces/bar/plot.js b/src/traces/bar/plot.js index cd8d04c9f90..9866bd57156 100644 --- a/src/traces/bar/plot.js +++ b/src/traces/bar/plot.js @@ -629,6 +629,7 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) { var trace = cd[0].trace; var texttemplate = Lib.castOption(trace, index, 'texttemplate'); if(!texttemplate) return ''; + var isHistogram = (trace.type === 'histogram'); var isWaterfall = (trace.type === 'waterfall'); var isFunnel = (trace.type === 'funnel'); var isHorizontal = trace.orientation === 'h'; @@ -670,10 +671,10 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) { var pt = {}; appendArrayPointValue(pt, trace, cdi.i); - if(pt.x === undefined) pt.x = isHorizontal ? obj.value : obj.label; - if(pt.y === undefined) pt.y = isHorizontal ? obj.label : obj.value; - if(pt.xLabel === undefined) pt.xLabel = isHorizontal ? obj.valueLabel : obj.labelLabel; - if(pt.yLabel === undefined) pt.yLabel = isHorizontal ? obj.labelLabel : obj.valueLabel; + if(isHistogram || pt.x === undefined) pt.x = isHorizontal ? obj.value : obj.label; + if(isHistogram || pt.y === undefined) pt.y = isHorizontal ? obj.label : obj.value; + if(isHistogram || pt.xLabel === undefined) pt.xLabel = isHorizontal ? obj.valueLabel : obj.labelLabel; + if(isHistogram || pt.yLabel === undefined) pt.yLabel = isHorizontal ? obj.labelLabel : obj.valueLabel; if(isWaterfall) { obj.delta = +cdi.rawS || cdi.s; diff --git a/test/image/baselines/hist_summed.png b/test/image/baselines/hist_summed.png index 3020f02b0fc..84791981d46 100644 Binary files a/test/image/baselines/hist_summed.png and b/test/image/baselines/hist_summed.png differ diff --git a/test/image/mocks/hist_summed.json b/test/image/mocks/hist_summed.json index ab18eae5539..73b52bc2fba 100644 --- a/test/image/mocks/hist_summed.json +++ b/test/image/mocks/hist_summed.json @@ -16,7 +16,7 @@ "Oranges", "Bananas" ], - "texttemplate": "%{value}
%{label}", + "texttemplate": "%{y:.1f}
%{x}", "type": "histogram" } ],