Comments (12)
You can add your own, custom fields to the items and use that as identifier, for example a field id
. Would that help?
from chap-links-library.
Do you mean get items using getData()
, iterate through them, find the item with corresponding id
and pass its index to deleteItem()
? This is the variant, but performance is rather low for timelines with many items (linear for number of items).
By the way, how can I add custom field? Just pass it in addItem()
is not working, as I understand...
from chap-links-library.
The Timeline internally stores the items as an array, and not as a map with key/values. That is quite unhandy when you want to manipulate the items by id. It will be much easier, safer, and faster when you could address the items by id rather than their row index. Right now the Timeline is really lacking good support for the type of operations that you need. The Timeline was originally created compatible with Google's Visualizations, which use a static DataTable, but I see the Timeline moving away from that more and more, into the direction of dynamic JSON data and a key/value based solution.
Using addItem
with custom fields will indeed not work (unknown fields are neglected), and when the items are manipulated by the user, all unknown fields are removed when writing the changes to the original data table. I hadn't thought of that. I will change this on short term, it is relatively easy to adjust and gives you more freedom. Actually, thinking about it, it may be relatively easy to add support for addressing items by id too. Maybe I can even implement that on the fly...
To add/update/delete changed items in the data table, I'm afraid you will have to iterate over the Array. This is very inefficient compared to using a map, but on the other hand, if there are not too much changes at a time, it may not be an issue in practice.
from chap-links-library.
Thanks in advance!
from chap-links-library.
Here is my reply too. Yes, it's difficult to track indexes because of dynamic changes in data. But on the other hand it's not difficult too much, I could manage this task.
I can recommend a very small and fast JS lib "keyval" to manage key / value pairs https://github.com/scaraveos/keyval.js I have a positive experience with this script.
from chap-links-library.
I saw that you might be adding id to the events, how is progress on this just wondering thanks
from chap-links-library.
Working with Timeline a lot I can not see why we really need IDs.
from chap-links-library.
My reason is dynamic content - I constantly add/remove items to timeline from many places of my application. In this situation it is difficult to maintain actual items indexes (+ selection indexes). Without it, I can't work (select/delete/change) with the given item efficiently (even if I have a reference to it).
More generally, there are no simple way to reference an item. In current implementation, you should iterate through all of them and estimate the index before each operation.
from chap-links-library.
Yes, but if you have a model, the events are backed by, it is not difficult and efficient to get index. Create a model for events before passing into Timeline. You can use everything what you want. I already mentioned "keyval" for JS model. I self use java.lang.List in Java.
from chap-links-library.
I can't "get index" only once after insert/delete event to timeline, I have to modify it after operations with other events! And I have to guess/copy algorithm of update from timeline library. Something like "if I delete the event, decrease indexes of all the events with indexes bigger the index of the deleted event". This is internal timeline logic, I don't want to duplicate it (what if timeline will reorder array of events to optimize drawing?).
You can use everything what you want. I already mentioned "keyval" for JS model. I self use java.lang.List in Java.
It is not a problem to store this information, it is a problem to update it! And my opinion is that the best solution is not to update it at all (== use immutable IDs).
from chap-links-library.
I saw that you might be adding id to the events, how is progress on this just wondering thanks
@onelegnd
yes, we're making good progress with a new key-value based approach. There is not yet any documentation for it but you can have an early look at the code. Everything is rewritten from scratch and stuff will be moved to a new github project soon.
Update: the new version has been moved to a new project, vis.
from chap-links-library.
oops accidentally closed the issue...
anyway, the new version I was talking about has been moved to a new project, vis. It is in early stage, far from complete and still undocumented.
from chap-links-library.
Related Issues (20)
- chap links timeline customisation HOT 3
- Start and group after double click HOT 7
- Timeline - Wrong item top position with empty group HOT 3
- Network - How can I fire an event on node/link selection HOT 1
- Timeline - Set custom time with click HOT 2
- Can't scroll vertically when on mobile HOT 1
- (timeline) fix top and group axis left to scroll down with touch - Question HOT 12
- zoomin and zoomout feature not working in chaps link library timeline slider HOT 1
- On executing draw/redraw the slider not rendering after first time calling the draw method of chaps link library timeline. HOT 1
- 1 month offset in timeline HOT 2
- Destroy method for timeline
- Drag and Drop from external events
- Time limit
- Input textbox not working.
- Timeline "isSelected" and "unselectItem" don't work with clusters
- Can't load graphs while running GWT projects, but it runs with JS version
- graph3d.js enhancements HOT 1
- Stacking not always working
- B.C. Dates possible?
- Keep -dump output pristine
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chap-links-library.