* @private
(resetNewElements)
| 960 | * @private |
| 961 | */ |
| 962 | _resyncElements(resetNewElements) { |
| 963 | const data = this._data; |
| 964 | const elements = this._cachedMeta.data; |
| 965 | |
| 966 | // Apply changes detected through array listeners |
| 967 | for (const [method, arg1, arg2] of this._syncList) { |
| 968 | this[method](arg1, arg2); |
| 969 | } |
| 970 | this._syncList = []; |
| 971 | |
| 972 | const numMeta = elements.length; |
| 973 | const numData = data.length; |
| 974 | const count = Math.min(numData, numMeta); |
| 975 | |
| 976 | if (count) { |
| 977 | // TODO: It is not optimal to always parse the old data |
| 978 | // This is done because we are not detecting direct assignments: |
| 979 | // chart.data.datasets[0].data[5] = 10; |
| 980 | // chart.data.datasets[0].data[5].y = 10; |
| 981 | this.parse(0, count); |
| 982 | } |
| 983 | |
| 984 | if (numData > numMeta) { |
| 985 | this._insertElements(numMeta, numData - numMeta, resetNewElements); |
| 986 | } else if (numData < numMeta) { |
| 987 | this._removeElements(numData, numMeta - numData); |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | /** |
| 992 | * @private |
no test coverage detected