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

Double recalculation of coordSysGeometry when both the sectionContext and geometry change #81

Closed
luucvanderzee opened this issue Aug 12, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@luucvanderzee
Copy link
Collaborator

luucvanderzee commented Aug 12, 2019

To reproduce:

<script>
  import { scaleLinear } from 'd3-scale'
  import { Graphic, Section, PointLayer } from '../../../../src/'
  import DataContainer from '@snlab/florence-datacontainer'

  let data = new DataContainer({ a: new Array(10).fill(0).map((_, i) => Math.random() * i) })
  let scaleX = scaleLinear().domain(data.domain('a'))
  let scaleY = scaleLinear().domain(data.domain('a'))

  function updateData () {
    data = new DataContainer({ a: new Array(10).fill(0).map((_, i) => Math.random() * i) })
    scaleX = scaleLinear().domain(data.domain('a'))
    scaleY = scaleLinear().domain(data.domain('a'))
  }
</script>

<div>
  <button on:click={updateData}>Update</button>
</div>

<div>

  <Graphic width={500} height={500}>
		
    <Section
      x1={50} x2={450}
      y1={50} y2={450}
      {scaleX}
      {scaleY}
    >

      <PointLayer
        x={data.column('a')}
        y={data.column('a')}
      />
		
    </Section>

  </Graphic>

</div>

and then put a console.log into the PointLayer's updateCoordSysGeometryObject:

function updateCoordSysGeometryObject () {
    console.log('updating...')

then try updating the data. You will see this:

Screenshot from 2019-08-12 15-27-53

Now try commenting out the part in updateData where you reassign the scaleX and scaleY. The result:

Screenshot from 2019-08-12 15-28-59

If you now uncomment the scaleX and scaleY reassignment again, and actually log the $sectionContext and the positioningAesthetics, you will see that during the first update the positioningAesthetics are still the old ones, but that the $sectionContext already has the new values, even though the assignment in the updateData function happens the other way around. Why is this happening? Really strange.

@luucvanderzee luucvanderzee added the bug Something isn't working label Aug 12, 2019
@luucvanderzee
Copy link
Collaborator Author

This was fixed in #112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant