Skip to content

Commit b96f912

Browse files
committed
add textposition attr
1 parent 4346b04 commit b96f912

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

_posts/plotly_js/basic/bar/2015-08-07-barchart-direct-labels.html

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
x: xValue,
1717
y: yValue,
1818
type: 'bar',
19-
text: ['27% market share', '24% market share', '19% market share'],
19+
text: yValue,
20+
textposition: 'auto',
21+
hoverinfo: 'none',
2022
marker: {
2123
color: 'rgb(158,202,225)',
2224
opacity: 0.6,
@@ -27,25 +29,10 @@
2729
}
2830
};
2931

30-
var annotationContent = [];
32+
var data = [trace1];
3133

32-
data = [trace1];
33-
34-
layout = {
35-
title: 'January 2013 Sales Report',
36-
annotations: annotationContent
34+
var layout = {
35+
title: 'January 2013 Sales Report'
3736
};
3837

39-
for( var i = 0 ; i < xValue.length ; i++ ){
40-
var result = {
41-
x: xValue[i],
42-
y: yValue[i],
43-
text: yValue[i],
44-
xanchor: 'center',
45-
yanchor: 'bottom',
46-
showarrow: false
47-
};
48-
annotationContent.push(result);
49-
}
50-
5138
Plotly.newPlot('myDiv', data, layout);

0 commit comments

Comments
 (0)