Skip to content

Bug: graphType doesn't update correctly #329

Closed
@ii888ii

Description

@ii888ii
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<script src="https://unpkg.com/function-plot/dist/function-plot.js"></script>
</head>

<body>
Does nothing:
<button id=upd>update existing fn</button>
<br>
Doesn't remove old polyline plot:
<button id=redefine>redefine data</button>
  
<div id=plot></div>
<script>
  
let obj = {
  target: plot,
  grid: true,
  data: [
    { fn: 'x' }
  ]
}
  
functionPlot(obj)

upd.addEventListener('click', evt => {
  obj.data[0].nSamples = 10
  obj.data[0].graphType = 'scatter'
  console.log(obj)
  functionPlot(obj)
})

redefine.addEventListener('click', evt => {
  obj.data = [{
    fn: 'x', nSamples: 10, graphType: 'scatter'
  }]
  console.log(obj)
  functionPlot(obj)
})

</script>
</body>

</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions