Giter Club home page Giter Club logo

Comments (12)

josdejong avatar josdejong commented on June 24, 2024

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.

aparshin avatar aparshin commented on June 24, 2024

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.

josdejong avatar josdejong commented on June 24, 2024

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.

aparshin avatar aparshin commented on June 24, 2024

Thanks in advance!

from chap-links-library.

ova2 avatar ova2 commented on June 24, 2024

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.

 avatar commented on June 24, 2024

I saw that you might be adding id to the events, how is progress on this just wondering thanks

from chap-links-library.

ova2 avatar ova2 commented on June 24, 2024

Working with Timeline a lot I can not see why we really need IDs.

from chap-links-library.

aparshin avatar aparshin commented on June 24, 2024

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.

ova2 avatar ova2 commented on June 24, 2024

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.

aparshin avatar aparshin commented on June 24, 2024

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.

josdejong avatar josdejong commented on June 24, 2024

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.

josdejong avatar josdejong commented on June 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.