Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Timeline: data item 'align' has no impact #4134

Open
pajryan opened this issue Sep 21, 2018 · 7 comments
Open

Timeline: data item 'align' has no impact #4134

pajryan opened this issue Sep 21, 2018 · 7 comments

Comments

@pajryan
Copy link

pajryan commented Sep 21, 2018

JS fiddle here

From the docs, it looks like I should be able align one particular item separately from the rest:

let data = new vis.DataSet([
  {id: 1, content: 'thing 1', start: '2018-01-01'},
  {id: 2, content: 'thing 2', start: '2018-03-01', align: 'left'},   // I expect this item to be left aligned...
  {id: 3, content: 'thing 3', start: '2018-05-01'}
])
let options = {
  align: 'center' // ... while remaining items are centered
}

But the align:left in the data seems to have no effect. I'd expect the 2nd item to be aligned on it's left edge. (Applying align: left in the global options works)

(thanks for the great tool)

@jgorene
Copy link

jgorene commented Sep 23, 2018

Hello,
Probably has no effect because the default type is "box"... try to change one with "range" type... it works well ;)

@pajryan
Copy link
Author

pajryan commented Sep 24, 2018

Thanks.

I see that it does work for range (in so much as it aligns the text inside the range div).
But my timeline items are points-in-time (not ranges), so forcing them to ranges doesn't really work.

It feels like I should be able to independently align boxes (both according to the docs and the fact that global alignment works properly.)

@pajryan
Copy link
Author

pajryan commented Sep 24, 2018

I'll see if I can put together a PR. But looks like the solution is this line in BoxItem:

var align = this.options.align;

align only looks to the global options.

That line needs to be changed to

var align = this.data.align === undefined ? this.options.align : this.data.align;

That's the pattern used in Range and adopts the alignment from the data.

Changing this locally resolves the issue.

@jgorene
Copy link

jgorene commented Sep 25, 2018

Ok, great;) maybe take a look also to timeline-plus a new fork maintain by @yotamberk

@yotamberk
Copy link
Contributor

This has been fixed and applied in timeline-plus
here: yotamberk/timeline-plus@1df3237
And can be found in v2.1.9 https://www.npmjs.com/package/timeline-plus

@r3b311i0n
Copy link

@yotamberk I tried the latest (v2.2.2) of timeline-plus and I'm still getting this bug.

@yotamberk
Copy link
Contributor

@r3b311i0n please open an issue in my fork and I will check out the problem

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants