Code Monkey home page Code Monkey logo

Comments (9)

anvaka avatar anvaka commented on July 28, 2024

It really boils down to what part of API you want to change. I intentionally made some part of the library private, to protect developers from errors.

Can you give a particular example of what you wanted to extend and was not able to?

from vivagraphjs.

antonkulaga avatar antonkulaga commented on July 28, 2024

to protect developers from errors.

This "protection" "throws away the baby together with a water", in my opinion.
Wherever I look in vivagraph I see those huge unreadable return objects that are a huge source of pain and possible errors.
Currently I am extending WebgImageNodeProgram I simply want to add few tiny features there but I cannot do because there is a mess there with several completely unreachable classes.
Why do not you simply do something like:

class WebgImageNodeProgram extends AbstractNodeProgram
  constructor: ()->
    @atlas = new ImageAtlas()
  #some other setup code

So developers will simply do

  constructor: ()->
    super 
  #some new code

???

The same for many other classes I have to work with. And sometimes your private methods simply do not work. For instance I am trying to establish better control for node and edges updates because I want to stream graphs with websockets and do realtime two-way syncronization. And I get "non implemented" errors for update notifications that are hidden somewhere in the "private section".

As a conclusion I have to rewrite whole vivagraph classes in normal OOP way (with subclasses, inheritance and so on) in my projects =(((

from vivagraphjs.

anvaka avatar anvaka commented on July 28, 2024

Think about return object as public API, which is accessible to external code. There are many ways of extending behavior of a library and I usually prefer delegation over inheritance.

Though I must admit WebGL based stuff has really rudimentary support right now. I was thinking it could be a better idea to have a satellite package to handle webgl rendering.

from vivagraphjs.

anvaka avatar anvaka commented on July 28, 2024

Here is how to implement custom nodes in WebGL: https://github.com/anvaka/VivaGraphJS/blob/master/demos/other/webglCustomNode.html

In case of prototypical inheritance shaders code becomes visible to all clients - which I don't really want to do.

I'm agree with you it could be done better. If you want to refactor this part - please feel free to submit the pull request. Though as I said, it might be a better idea to make a satellite library or make API flexible enough to use other rendering libraries like three.js or two.js

from vivagraphjs.

antonkulaga avatar antonkulaga commented on July 28, 2024

. If you want to refactor this part - please feel free to submit the pull request.

It is not hard for me to contribute because I will anyway do some graph code in my project. The problem is that I write in completely different style than you: I prefer to use coffeescript, I use a lot of small classes and am not obsessed with "privacy".
Regarding three.js I actually plan to use in the future. The reason why I am trying to use current webgl code because I am prototyping some features and want to get things working faster.

from vivagraphjs.

xdiscovery avatar xdiscovery commented on July 28, 2024

Hi,
what about wrap Vivagraph in angularjs directive?
Not addressing anton kulaga points but it would made viva extremely extensible.

I've obtained real nice results with viva as stand alone graph loaded as onload() events, I'd like it now to use it as directive to load dinamically some graphs withinin div objects.

Any help in doing this?
(starting to learn angularjs now..)
http://briantford.com/blog/angular-d3.html

if someone angularjs-trained could help in figure out how to wrap it so that ot inject graph dynamically, it'd be amazingly useful (and I'd be real grateful).

from vivagraphjs.

anvaka avatar anvaka commented on July 28, 2024

@xdiscovery Nice idea. I've been using angular myself recently, and want to port some parts of yasiv.com to angular. Will share the code for angular directive.

from vivagraphjs.

anvaka avatar anvaka commented on July 28, 2024

Closing this issue. I'm not planning to expose private state to world. If there is lack of extensibility points I'd be happy to address those via delegation.

from vivagraphjs.

gg4u avatar gg4u commented on July 28, 2024

hi @anvaka,

could you show an example for using vivagraph with angular?
I wrote a web-app with vivagraph, hammerjs and jquery.
Angular is not really straight forward for me, I am learning with a dive course about angular-cli:
https://www.udemy.com/learn-angular-from-scratch/learn/v4/t/lecture/6976310?start=0

and I would be happy to wrap the whole piece of code within a "graph" view.

It would be nice if you or someone savvy with angular could show an example to fit with above tutorial.

from vivagraphjs.

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.