ParasolJS / parasol-es

ES6 module for interactive visualization of multi-objective optimization problems
https://parasoljs.github.io/
MIT License
26 stars 5 forks source link

Render/update axes for methods that change number of dimensions #10

Closed wraseman closed 6 years ago

wraseman commented 6 years ago

I could be mistaken, but it seems that we only need to render/update axes when the number of dimensions are changed. For example, I found that calling Parasol.cluster() did not require render() or updateAxes() but Parasol.aggregateScores() did.

This is low priority, I know we have a lot of other things to go through. I just figured it would be cleaner if the user didn't have to call render() and updateAxes() all the time. I also realized I don't quite understand when it is necessary.

joshhjacobson commented 6 years ago

I think I see what you're saying, but can you post a code example for each case just to be sure?

wraseman commented 6 years ago

First off, we do have a ton to do still! So again, let's put this on the back burner for now. But yeah, hopefully this example clarifies things a bit.

Say we want to use the Parasol.aggregateScores() method right now, we would do something like this:

var ps = Parasol(data)('.parcoords')
            .aggregateScores({ weights: weights });

// update charts
ps.charts.forEach(
    (pc) => {
      pc
        .render()
        .updateAxes(0)
    }

Or using the new global implementation of Parcoords methods...

var ps = Parasol(data)('.parcoords')
        .aggregateScores({ weights: weights });
        .render()
        .updateAxes(0)
    }

It seems to me that only certain methods (e.g., Parasol.clustering(hidden=false), Parasol.aggregateScores(), Parasol.hideAxes(), Parasol.showAxes()) require .render() and .updatesAxes(), so shouldn't we just automatically call those rendering/update methods every time we call a method that changes the number of axes that are shown? That would be done in the JavaScript source code for the API. That way the user could just do this:

var ps = Parasol(data)('.parcoords')
        .aggregateScores({ weights: weights });  // rendering and updating axes done within method
    }
joshhjacobson commented 6 years ago

What you have for the final result is already the way it's setup. In scoring.html we have,

var ps = Parasol(data)('.parcoords')
            .aggregateScores({ weights: weights });

  // update charts
  ps.charts.forEach(
    (pc) => {
      pc
        .hideAxis(['name'])
        .reorderable()
        .render()
        .updateAxes(0)
    }
  )

but note that if you were to comment out the entire "update charts" section, it would still work. The purpose of that section is to remove the name axis (requires updateAxes) and make the charts reorderable (requires render).

The same should be true for all features that edit the number of axes/dimensions, but I'll double check.

wraseman commented 6 years ago

I see, thanks for clarifying