klay-js icon indicating copy to clipboard operation
klay-js copied to clipboard

workerScript should be able to be set globally

Open forresto opened this issue 10 years ago • 3 comments

We set the workerScript location in klay.init:

     this.autolayouter = klay.init({
       onSuccess: this.applyAutolayout.bind(this),
       workerScript: "../bower_components/klay-js/klay-worker.js"
    });

But there should be a way to do it globally. So

window.KLAY_CONFIG = { workerScript: "./bower_components/klay-js/klay-worker.js" }

and

  if ("KLAY_CONFIG" in window && "workerScript" in window.KLAY_CONFIG) {
    workerScript = window.KLAY_CONFIG.workerScript;
  } else if ("workerScript" in params) {
    workerScript = params.workerScript;
  } else {
    workerScript = "klay-worker.js";
  }    

This was an issue in noflo/visualize b/c we're using the-graph as a bower dependency, klay.init needs to happen in the-graph custom element, and the worker script path is different b/c it is hosted here: http://noflojs.org/visualize/

forresto avatar Jun 03 '14 08:06 forresto

(Changed to KLAY_CONFIG to mirror GSS's config.)

forresto avatar Jun 03 '14 08:06 forresto

klay-wroker.js still is problem. Will you fix it?

kelegorm avatar Nov 28 '14 16:11 kelegorm

Hi, I improved the the underlying library code which you can find in another repository. Maybe that helps you. If not, let me know.

See https://github.com/OpenKieler/klayjs

uruuru avatar Nov 28 '14 17:11 uruuru