diff --git a/src/traces/bar/plot.js b/src/traces/bar/plot.js index efa169fc631..cd8d04c9f90 100644 --- a/src/traces/bar/plot.js +++ b/src/traces/bar/plot.js @@ -631,10 +631,11 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) { if(!texttemplate) return ''; var isWaterfall = (trace.type === 'waterfall'); var isFunnel = (trace.type === 'funnel'); + var isHorizontal = trace.orientation === 'h'; var pLetter, pAxis; var vLetter, vAxis; - if(trace.orientation === 'h') { + if(isHorizontal) { pLetter = 'y'; pAxis = ya; vLetter = 'x'; @@ -669,6 +670,11 @@ 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(isWaterfall) { obj.delta = +cdi.rawS || cdi.s; obj.deltaLabel = formatNumber(obj.delta); diff --git a/src/traces/histogram/calc.js b/src/traces/histogram/calc.js index 18e34c6c6ee..5a649692012 100644 --- a/src/traces/histogram/calc.js +++ b/src/traces/histogram/calc.js @@ -15,8 +15,9 @@ var getBinSpanLabelRound = require('./bin_label_vals'); function calc(gd, trace) { var pos = []; var size = []; - var pa = Axes.getFromId(gd, trace.orientation === 'h' ? trace.yaxis : trace.xaxis); - var mainData = trace.orientation === 'h' ? 'y' : 'x'; + var isHorizontal = trace.orientation === 'h'; + var pa = Axes.getFromId(gd, isHorizontal ? trace.yaxis : trace.xaxis); + var mainData = isHorizontal ? 'y' : 'x'; var counterData = {x: 'y', y: 'x'}[mainData]; var calendar = trace[mainData + 'calendar']; var cumulativeSpec = trace.cumulative; diff --git a/test/image/baselines/bar-marker-line-colorscales.png b/test/image/baselines/bar-marker-line-colorscales.png index 3a900a819c6..6d2a21252bf 100644 Binary files a/test/image/baselines/bar-marker-line-colorscales.png and b/test/image/baselines/bar-marker-line-colorscales.png differ diff --git a/test/image/baselines/bar_marker_array.png b/test/image/baselines/bar_marker_array.png index f290fc1f591..6bd20bcaa0c 100644 Binary files a/test/image/baselines/bar_marker_array.png and b/test/image/baselines/bar_marker_array.png differ diff --git a/test/image/baselines/date_histogram.png b/test/image/baselines/date_histogram.png index c9b86627a2a..284e61ad3a9 100644 Binary files a/test/image/baselines/date_histogram.png and b/test/image/baselines/date_histogram.png differ diff --git a/test/image/mocks/bar-marker-line-colorscales.json b/test/image/mocks/bar-marker-line-colorscales.json index b87045afaf2..e81b6d0da90 100644 --- a/test/image/mocks/bar-marker-line-colorscales.json +++ b/test/image/mocks/bar-marker-line-colorscales.json @@ -1,6 +1,7 @@ { "data": [ { + "texttemplate": "%{x}", "marker": { "color": [ 0, diff --git a/test/image/mocks/bar_marker_array.json b/test/image/mocks/bar_marker_array.json index 904d1054a0e..357728cef58 100644 --- a/test/image/mocks/bar_marker_array.json +++ b/test/image/mocks/bar_marker_array.json @@ -1,6 +1,8 @@ { "data": [ { + "texttemplate": "%{y:(}", + "textfont": { "size": 32 }, "x": [ 1, 2, diff --git a/test/image/mocks/date_histogram.json b/test/image/mocks/date_histogram.json index a42dec76323..8f36836f54c 100644 --- a/test/image/mocks/date_histogram.json +++ b/test/image/mocks/date_histogram.json @@ -1,6 +1,7 @@ { "data": [ { + "texttemplate": "%{y:.1f}

%{x}", "x": [ "2012-01-01 00:00:00", "2012-02-01 00:00:00", diff --git a/test/image/mocks/histogram_colorscale.json b/test/image/mocks/histogram_colorscale.json index e991ebe5626..e07eab4bbc0 100644 --- a/test/image/mocks/histogram_colorscale.json +++ b/test/image/mocks/histogram_colorscale.json @@ -13,7 +13,7 @@ "cmax": 5 }, "x": [ 0, 1, 1, 2, 2, 2, 3, 3, 4 ], - "texttemplate": "%{value}", + "texttemplate": "%{y}", "textposition": "inside", "textfont": { "size": 64