Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChartCanvasNode and the need to call update. #45

Open
pixelzoom opened this issue Sep 21, 2021 · 8 comments
Open

ChartCanvasNode and the need to call update. #45

pixelzoom opened this issue Sep 21, 2021 · 8 comments
Assignees
Labels

Comments

@pixelzoom
Copy link
Contributor

pixelzoom commented Sep 21, 2021

For #47 and phetsims/fourier-making-waves#165 ...

@jonathanolson added this REVIEW comment to Foruier's SumChartNode.js:

    const sumPlot = new CanvasLinePlot( ... );
...
    const chartCanvasNode = new ChartCanvasNode( ..., [ sumPlot ], ... );
...
    // Display the data set.
    //REVIEW: This seems to be a common pattern with Data set Properties, any way to factor it out?
    sumDataSetProperty.lazyLink( dataSet => {
      sumPlot.setDataSet( dataSet );
      chartCanvasNode.update();
    } );

This is a problem that @samreid and I wrestled with previously in bamboo. ChartCanvasNode renders 1 or more CanvasLinePlot instances. CanvasLinePlot does not know about ChartCanvasNode. So when you make changes to a CanvasLinePlot , you are currently responsible for calling ChartCanvasNode.update.

This is well-documented in CanvasLinePlot, for example:

  /**
   * Sets dataSet. You are responsible for calling update on the associated ChartCanvasNode(s).
   * @param {Vector2[]} dataSet
   * @public
   */
  setDataSet( dataSet ) {

Despite the documentation, this is still a pain point - easy to forget, and (as @jonathanolson pointed out in the REVIEW comment) a common pattern that results in duplicated code.

But I should also point out... In terms of performance, there are also benefits here. In Fourier, I have a ChartCanvasNode that is rendering 97 CanvasLinePlot instances. I can update all 97 plots, then call update. If ChartCanvasNode updated each time one of its plots was updated, then I'd have big problems in Fourier. So perhaps having to call update is OK for something like this where performance is critical.

I don't plan to address this for Fourier because of the need to move forward. But let's discuss this again, adding @jonathanolson to the discussion.

@jonathanolson
Copy link
Contributor

CanvasLinePlot does not know about ChartCanvasNode

That seems like something that could change, but I'm curious if it would affect performance.

@pixelzoom pixelzoom added the dev:enhancement New feature or request label Sep 22, 2021
@pixelzoom
Copy link
Contributor Author

I unsuccessfully tried to address this in sim specific code, see phetsims/fourier-making-waves#174.

@pixelzoom
Copy link
Contributor Author

I said above:

But I should also point out... In terms of performance, there are also benefits here. ... having to call update is OK for something like this where performance is critical.

@jonathanolson pointed out that update is currently just invalidatePaint, which simply flags the Canvas as needing to be redrawn. So there should be no significant penalty for calling update many times.

@pixelzoom
Copy link
Contributor Author

Unassigning because I doubt that we'll see progress on this for awhile. Let me know when you'd like to discuss.

@pixelzoom pixelzoom removed their assignment Sep 28, 2021
@samreid
Copy link
Member

samreid commented Oct 4, 2021

Perhaps the best way forward for this issue is to schedule a 15-minute mini dev subteam.

@pixelzoom
Copy link
Contributor Author

Unassigning until we muster a subgroup meeting, which seems unlikely in the near future.

@pixelzoom pixelzoom removed their assignment Nov 9, 2021
@samreid
Copy link
Member

samreid commented Nov 9, 2021

Do the assignees indicate the dev group subteam? I also want to unassign myself since I don't want to see this in my assigned issues until our subgroup meeting. But leaving myself as an assignee helps indicate that I'm part of the subgroup when it's time.

@samreid
Copy link
Member

samreid commented Feb 2, 2022

Unassigning since I am not scheduled any time for this part of bamboo in the current quarter. This issue will not be lost since I am the responsible dev for the repo.

@samreid samreid removed their assignment Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants