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

Allow for alignment of data in columns to be controlled #15

Closed
tdwright opened this Issue Nov 29, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@tdwright
Owner

tdwright commented Nov 29, 2017

An obvious example would be for numbers with decimal places:

+--------+--------+
| Apple  | Orange |
+--------+--------+
|  12.50 | ABC    |
| 123.21 | AB     |
+--------+--------+
@Royhoey

This comment has been minimized.

Show comment
Hide comment
@Royhoey

Royhoey Jan 27, 2018

Contributor

Hey! Can I try this one? :)

My approach would be to create a new class Alignment with a ProcessString function, similar to LongStringBehaviour. This could then be a property on the Column class so you can configure the alignment for each column.

Contributor

Royhoey commented Jan 27, 2018

Hey! Can I try this one? :)

My approach would be to create a new class Alignment with a ProcessString function, similar to LongStringBehaviour. This could then be a property on the Column class so you can configure the alignment for each column.

@Royhoey

This comment has been minimized.

Show comment
Hide comment
@Royhoey

Royhoey Jan 27, 2018

Contributor

Which options are there for alignment? Just left and right or center as well? What would a center alignment look like if the column max width is an odd number?

Contributor

Royhoey commented Jan 27, 2018

Which options are there for alignment? Just left and right or center as well? What would a center alignment look like if the column max width is an odd number?

@tdwright

This comment has been minimized.

Show comment
Hide comment
@tdwright

tdwright Jan 27, 2018

Owner

Hi @Royhoey!

You are (of course) very welcome to take this one on. Thanks for sticking your hand up!

I think having centre alignment would be worthwhile, but I don't think the most important thing is for it to be 100% perfectly centred. For odd numbered widths, it might just be an arbitrary decision as to which way round the asymmetry goes.

The other way to handle this, I guess, would be to force all centre-aligned columns to have an even numbered width. Let's do it the straightforward way first and see how it looks. If it looks janky to have a slight asymmetry, we can always go down this route in the future.

In terms of how to implement this, your approach sounds like it could work, but at present the implicit/default left-align takes place in the DataLine() method of OutputBuilder.cs. You could consider making a "left pad" and "right pad" property on the column class perhaps? Then where would you do the calculation that takes the alignment into account? Hmmm....

Owner

tdwright commented Jan 27, 2018

Hi @Royhoey!

You are (of course) very welcome to take this one on. Thanks for sticking your hand up!

I think having centre alignment would be worthwhile, but I don't think the most important thing is for it to be 100% perfectly centred. For odd numbered widths, it might just be an arbitrary decision as to which way round the asymmetry goes.

The other way to handle this, I guess, would be to force all centre-aligned columns to have an even numbered width. Let's do it the straightforward way first and see how it looks. If it looks janky to have a slight asymmetry, we can always go down this route in the future.

In terms of how to implement this, your approach sounds like it could work, but at present the implicit/default left-align takes place in the DataLine() method of OutputBuilder.cs. You could consider making a "left pad" and "right pad" property on the column class perhaps? Then where would you do the calculation that takes the alignment into account? Hmmm....

@Royhoey

This comment has been minimized.

Show comment
Hide comment
@Royhoey

Royhoey Jan 27, 2018

Contributor

@tdwright Alright I will give it a go then!

As far as the centre alignment goes, I'll just play around with it to see how it looks.
Yeah I was thinking that the aligning should take place in the DataLine method... let me see what works best.

Contributor

Royhoey commented Jan 27, 2018

@tdwright Alright I will give it a go then!

As far as the centre alignment goes, I'll just play around with it to see how it looks.
Yeah I was thinking that the aligning should take place in the DataLine method... let me see what works best.

@tdwright

This comment has been minimized.

Show comment
Hide comment
@tdwright

tdwright Jan 27, 2018

Owner

Awesome. Look forward to seeing a PR soon! 😀

Owner

tdwright commented Jan 27, 2018

Awesome. Look forward to seeing a PR soon! 😀

tdwright added a commit that referenced this issue Jan 30, 2018

Merge pull request #32 from Royhoey/royhoey/add-alignment
Issue #15 - Allow for alignment of data in columns to be controlled

@tdwright tdwright closed this Jan 31, 2018

@tdwright tdwright removed the in progress label Jan 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment