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

Skip to content

insidetextorientation attribute in pie and sunburst #1659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2020

Conversation

Mahdis-z
Copy link
Contributor

No description provided.

@Mahdis-z Mahdis-z requested a review from archmoj January 14, 2020 20:05
Copy link

@archmoj archmoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mahdis-z thanks very much for the PR and beautiful examples.
Please find my comments below:

---
Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/coffee-flavors.csv', function(err, rows){
function unpack(rows, key) {
return rows.map(function(row) {return row[key]});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semicolons are optional at the end of a javascript statement.
They are used in some lines here and are not used in other lines.

ids: unpack(rows, 'ids'),
labels: unpack(rows, 'labels'),
parents: unpack(rows, 'parents'),
insidetextorientation: 'radial'}];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering it might be easier to read if this is formatted like this:

var data = [{
      type: "sunburst",
      maxdepth: 2,
      ids: unpack(rows, 'ids'),
      labels: unpack(rows, 'labels'),
      parents: unpack(rows, 'parents'),
      insidetextorientation: 'radial'
}];


var layout = {margin: {l: 0, r: 0, b: 0, t:0}};

Plotly.newPlot('myDiv', data, layout)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line as well as some lines above may require indentation.

type: "pie",
values: [2, 3, 4, 4],
labels: ["Wages", "Operating expenses", "Cost of sales", "Insurance"],
textinfo: "label+percent",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add

textposition: "inside",

here to ensure all the text fits inside.

Copy link
Contributor

@jdamiba jdamiba Jan 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Mahdis, this PR is looking really good. I just have a suggestion, which also applies to the sunburst doc in this PR.

I think that text could more explicitly describe these options.

Perhaps something like:

The insidetextorientation attribute controls the orientation of the text inside chart sectors. When set to 'auto', text may be oriented in any direction in order to be as big as possible in the middle of a sector. The 'horizontal' option orients text to be parallel with the bottom of the chart, and will make text smaller in order to achieve that goal. The 'radial' option orients text along the radius of the sector. The 'tangential' option orients text perpendicular to the radius of the sector.

What do you think?

Along with Mojtaba's comments, this looks ready to merge!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if you were to imagine your chart as a clock face, the 'horizontal', 'radial', and 'tangential' options first try to orient text at the the 3:00, 6:00, 9:00, and 12:00 hours. If that is not possible due to space constraints, then they position the text in the middle of the arc. On the other hand the auto option always shrinks text to fit in the middle of the arc.

@archmoj
Copy link

archmoj commented Jan 27, 2020

Nicely done.
💃

@Mahdis-z Mahdis-z merged commit 0e63582 into source-design-merge Jan 27, 2020
@Mahdis-z Mahdis-z deleted the insidetextorientation branch January 27, 2020 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants