Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9984e90

Browse filesBrowse files
authored
Merge pull request plotly#6070 from plotly/histogram-format-x-y-texttemplate
Correct formatted x/y `texttempate` for `histogram` trace
2 parents 19efc29 + 1a4637c commit 9984e90
Copy full SHA for 9984e90

File tree

Expand file treeCollapse file tree

3 files changed

+6
-5
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+6
-5
lines changed

‎src/traces/bar/plot.js

Copy file name to clipboardExpand all lines: src/traces/bar/plot.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) {
629629
var trace = cd[0].trace;
630630
var texttemplate = Lib.castOption(trace, index, 'texttemplate');
631631
if(!texttemplate) return '';
632+
var isHistogram = (trace.type === 'histogram');
632633
var isWaterfall = (trace.type === 'waterfall');
633634
var isFunnel = (trace.type === 'funnel');
634635
var isHorizontal = trace.orientation === 'h';
@@ -670,10 +671,10 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) {
670671
var pt = {};
671672
appendArrayPointValue(pt, trace, cdi.i);
672673

673-
if(pt.x === undefined) pt.x = isHorizontal ? obj.value : obj.label;
674-
if(pt.y === undefined) pt.y = isHorizontal ? obj.label : obj.value;
675-
if(pt.xLabel === undefined) pt.xLabel = isHorizontal ? obj.valueLabel : obj.labelLabel;
676-
if(pt.yLabel === undefined) pt.yLabel = isHorizontal ? obj.labelLabel : obj.valueLabel;
674+
if(isHistogram || pt.x === undefined) pt.x = isHorizontal ? obj.value : obj.label;
675+
if(isHistogram || pt.y === undefined) pt.y = isHorizontal ? obj.label : obj.value;
676+
if(isHistogram || pt.xLabel === undefined) pt.xLabel = isHorizontal ? obj.valueLabel : obj.labelLabel;
677+
if(isHistogram || pt.yLabel === undefined) pt.yLabel = isHorizontal ? obj.labelLabel : obj.valueLabel;
677678

678679
if(isWaterfall) {
679680
obj.delta = +cdi.rawS || cdi.s;

‎test/image/baselines/hist_summed.png

Copy file name to clipboard
660 Bytes
Loading

‎test/image/mocks/hist_summed.json

Copy file name to clipboardExpand all lines: test/image/mocks/hist_summed.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"Oranges",
1717
"Bananas"
1818
],
19-
"texttemplate": "%{value}<br>%{label}",
19+
"texttemplate": "%{y:.1f}<br>%{x}",
2020
"type": "histogram"
2121
}
2222
],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.