Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e63582

Browse files
authored
Merge pull request #1659 from plotly/insidetextorientation
insidetextorientation attribute in pie and sunburst
2 parents 82ba003 + 1f4a05d commit 0e63582

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Control text orientation inside Pie slices
3+
language: plotly_js
4+
suite: pie
5+
order: 5
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
The [insidetextorientation](https://plot.ly/javascript/reference/#pie-insidetextorientation) attribute controls the orientation of the texts inside slices. With 'auto' the texts may automatically be rotated to fit with the maximum size inside the slice. The other three options 'horizontal', 'radial', and 'tangential' forces text to be horizontal, radial, and tangential.
10+
---
11+
var data = [{
12+
type: "pie",
13+
values: [2, 3, 4, 4],
14+
labels: ["Wages", "Operating expenses", "Cost of sales", "Insurance"],
15+
textinfo: "label+percent",
16+
insidetextorientation: "radial"
17+
}]
18+
var layout = [{
19+
height: 700,
20+
width: 700
21+
}]
22+
23+
Plotly.newPlot('myDiv', data, layout)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Control text orientation inside Sunburst slices
3+
language: plotly_js
4+
suite: sunburst
5+
order: 6
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
The [insidetextorientation](https://plot.ly/javascript/reference/#sunburst-insidetextorientation) attribute controls the orientation of the texts inside chart sectors. When set to 'auto' the texts may automatically be rotated to fit with the maximum size inside a sector. The other three options 'horizontal', 'radial', and 'tangential' first try to orient text at the 3:00, 6:00, 9:00, and 12:00 hours. If there is no enough room, then the text would be positioned in the middle of the arc.
10+
---
11+
Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/coffee-flavors.csv', function(err, rows){
12+
function unpack(rows, key) {
13+
return rows.map(function(row) {return row[key]})
14+
}
15+
16+
var data = [{
17+
type: "sunburst",
18+
maxdepth: 2,
19+
ids: unpack(rows, 'ids'),
20+
labels: unpack(rows, 'labels'),
21+
parents: unpack(rows, 'parents'),
22+
textposition: 'inside',
23+
insidetextorientation: 'radial'
24+
}]
25+
26+
var layout = {margin: {l: 0, r: 0, b: 0, t:0}}
27+
28+
Plotly.newPlot('myDiv', data, layout)
29+
})

0 commit comments

Comments
 (0)