Giter VIP home page Giter VIP logo

intervaltree's Introduction

Interval Tree Visualization

The demo is hosted at https://lucunji.github.io/IntervalTree/public/

Features

Most basic functionalities of this applet are made to be similar to those in the existing KD-Tree Demo but with some improvements:

  • My demo is compatible with different browser dimensions. So it is also playable on smartphones.

  • The implementation is faster with a large number of objects. Compared to the old KD-Tree implement, which takes about several seconds to respond with 100 points, my implementation responds almost instantaneously with 100 line segments.

  • The line segments and points are fixed (not draggable) in building or query mode. So users will not accidentally move it out of place.

  • While building and querying, the line segments and median lines are color-coded with the same color as the tree nodes, so users can have a better sense of the tree's structure.

  • The Finish Subtree button moves the current node to the parent node, instead of the parent's right child node. This design makes the simulation more fine-grained and easier to understand.

  • When clicking on Start Query before finishing building the tree, my demo will proceed after completing the interval tree, instead of proceeding with an unfinished tree.

  • The user can choose to sort the line segments vertically according to the horizontal position of either endpoint.

  • This demo is written in Typescript. Typescript is a superset of Javascript: it can do everything people used to do with Javascript. In addition, Typescript introduces a stronger typing capability, so we can write code with fewer errors, and use OOP design patterns easier. Most popular libraries are supporting Typescript, and it is becoming a popular choice.

Dependencies and References

The functionalities of this demo are made to be similar to the KD-Tree demo, and I also used the same JSXGraph library. But all the code is written on my own with references to the official documents of the libraries.

The libraries used in this project are mainly

  • JSXGraph: drawing line segments and interval trees.
  • Bootstrap 4: making a fancy UI compatible with different dimensions of screens. I do not choose Bootstrap 5 for better compatibility with earlier browsers.
  • typescript: allowing me to program using Typescript, a language more powerful than Javascript
  • webpack: bundles all code into a single file, so I only need to load a single script file in HTML.

Possible Future Improvements

  • As an improvement, the demo can also show the pseudocode and highlight the currently running line of code.

  • Currently, I only use the Listener design pattern to manage the communication between different components (e.g. buttons, drawing area, and segment tree). This alone does not make the code loosely coupled enough (so things are entangled together). I can use more design patterns, such as MVC and Visitor, to make the code more scalable and maintainable.

  • This project is kind of a proof-of-concept in the sense that it helps me to get familiar with using Typescript, webpack and JSXGraph together. If this design is proved to be favorable, we can improve it and then rewrite other demos in the same style for fewer errors and more compatible.

intervaltree's People

Contributors

lucunji avatar

Watchers

 avatar

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.