File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -586,8 +586,12 @@ function onSiteDependenciesLoaded() {
586
586
/**
587
587
* ### Update
588
588
*
589
- * To update a graphic one needs to call `functionPlot` on the same target
590
- * element with *any* object that is configured properly
589
+ * To update a graph call `functionPlot` on the same target
590
+ * element with *any* object that is configured properly.
591
+ *
592
+ * If you want to update properties of a datum (of an element of `data`),
593
+ * make sure to **recreate the entire object** instead of changing properties
594
+ * from it.
591
595
*
592
596
* @additionalDOM
593
597
*
@@ -609,6 +613,7 @@ function onSiteDependenciesLoaded() {
609
613
xLine : true ,
610
614
yLine : true
611
615
}
616
+ // Replace the entire object instead of changing properties from it!
612
617
options . data [ 0 ] = {
613
618
fn : 'x * x' ,
614
619
derivative : {
@@ -621,9 +626,8 @@ function onSiteDependenciesLoaded() {
621
626
// update the function to be y = x
622
627
delete options . title
623
628
delete options . tip
624
- options . data [ 0 ] = {
625
- fn : 'x'
626
- }
629
+ // Replace the entire object instead of changing properties from it!
630
+ options . data [ 0 ] = { fn : 'x' }
627
631
}
628
632
functionPlot ( options )
629
633
} )
Original file line number Diff line number Diff line change 401
401
a.addLink(b, c)
402
402
b.addLink(a, c)
403
403
c.addLink(a, b)</ code > </ pre > </ div > </ div > < div class ="col-md-6 center-block demos "> < span class ="graph " id ="linked-a-multiple "> </ span > < span class ="graph " id ="linked-b-multiple "> </ span > < span class ="graph " id ="linked-c-multiple "> </ span > </ div > </ div > </ div > </ div > < div class ="example "> < div class ="container "> < div class ="row "> < div class ="col-md-6 "> < div class ="comment "> < h3 > Update</ h3 >
404
- < p > To update a graphic one needs to call < code > functionPlot</ code > on the same target
405
- element with < em > any</ em > object that is configured properly</ p > </ div > < div class ="code "> < pre > < code class ="javascript "> const options = {
404
+ < p > To update a graph call < code > functionPlot</ code > on the same target
405
+ element with < em > any</ em > object that is configured properly.</ p >
406
+ < p > If you want to update properties of a datum (of an element of < code > data</ code > ),
407
+ make sure to < strong > recreate the entire object</ strong > instead of changing properties
408
+ from it.</ p > </ div > < div class ="code "> < pre > < code class ="javascript "> const options = {
406
409
target: '#quadratic-update',
407
410
data: [
408
411
{
418
421
xLine: true,
419
422
yLine: true
420
423
}
424
+ // Replace the entire object instead of changing properties from it!
421
425
options.data[0] = {
422
426
fn: 'x * x',
423
427
derivative: {
430
434
// update the function to be y = x
431
435
delete options.title
432
436
delete options.tip
433
- options.data[0] = {
434
- fn: 'x'
435
- }
437
+ // Replace the entire object instead of changing properties from it!
438
+ options.data[0] = { fn: 'x' }
436
439
}
437
440
functionPlot(options)
438
441
})
You can’t perform that action at this time.
0 commit comments