Skip to content

Commit 3577365

Browse files
committed
Fix bug associated with dynamic cArray and dataArray props for MultiDataRect/Track Plots
1 parent 05f2b44 commit 3577365

File tree

3 files changed

+74
-14
lines changed

3 files changed

+74
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vueplotlib",
3-
"version": "1.11.0",
3+
"version": "1.11.1",
44
"private": false,
55
"scripts": {
66
"serve": "vue-cli-service serve --open ./examples-src/index.js",

src/components/plots/MultiDataRectPlot.vue

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<td>{{ this.tooltipInfo.z }}</td>
3737
</tr>
3838
<tr>
39-
<th>{{ this._cScales[this.tooltipInfo.i].name }}</th>
39+
<th>{{ this.tooltipInfo.cName }}</th>
4040
<td>{{ this.tooltipInfo.c }}</td>
4141
</tr>
4242
</table>
@@ -134,7 +134,7 @@ export default {
134134
tooltipInfo: {
135135
z: '',
136136
c: '',
137-
i: 0,
137+
cName: '',
138138
},
139139
highlightYScale: null,
140140
highlightY: null,
@@ -147,8 +147,6 @@ export default {
147147
uuid += 1;
148148
},
149149
created() {
150-
console.assert(this.dataArray.length === this.cArray.length);
151-
152150
// Set data
153151
this._dataContainers = this.dataArray.map((dataKey) => {
154152
const dataContainer = this.getData(dataKey);
@@ -203,14 +201,46 @@ export default {
203201
watch: {
204202
o() {
205203
this.drawPlot();
204+
},
205+
dataArray() {
206+
this._dataContainers.forEach((dataContainer) => {
207+
dataContainer.onUpdate(this.uuid, null);
208+
});
209+
210+
this._dataContainers = this.dataArray.map((dataKey) => {
211+
const dataContainer = this.getData(dataKey);
212+
console.assert(dataContainer instanceof DataContainer);
213+
return dataContainer;
214+
});
215+
216+
this._dataContainers.forEach((dataContainer) => {
217+
dataContainer.onUpdate(this.uuid, this.drawPlot);
218+
});
219+
220+
this.drawPlot();
221+
},
222+
cArray() {
223+
this._cScales.forEach((cScale) => {
224+
cScale.onUpdate(this.uuid, null);
225+
});
226+
227+
this._cScales = this.cArray.map((cKey) => {
228+
const cScale = this.getScale(cKey);
229+
console.assert(cScale instanceof AbstractScale);
230+
return cScale;
231+
});
232+
233+
this._cScales.forEach((cScale) => {
234+
cScale.onUpdate(this.uuid, this.drawPlot);
235+
});
206236
}
207237
},
208238
methods: {
209239
tooltip(mouseX, mouseY, z, c, i) {
210240
// Set values
211-
this.tooltipInfo.i = i;
212241
this.tooltipInfo.z = this._zScale.toHuman(z);
213242
this.tooltipInfo.c = this._cScales[i].toHuman(c);
243+
this.tooltipInfo.cName = this._cScales[i].name
214244
215245
// Set position
216246
if(!this.disableTooltip) {
@@ -240,7 +270,7 @@ export default {
240270
drawPlot(d3Node) {
241271
const vm = this;
242272
243-
if(vm._dataContainers.reduce((a, h) => (a || h.isLoading), false) || vm._cScales.reduce((a, h) => (a || h.isLoading), false) || vm._zScale.isLoading) {
273+
if(vm._dataContainers.length !== vm._cScales.length || vm._dataContainers.reduce((a, h) => (a || h.isLoading), false) || vm._cScales.reduce((a, h) => (a || h.isLoading), false) || vm._zScale.isLoading) {
244274
return;
245275
}
246276

src/components/plots/MultiDataTrackPlot.vue

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<td>{{ this.tooltipInfo.x }}</td>
6464
</tr>
6565
<tr>
66-
<th>{{ this._cScales[this.tooltipInfo.i].name }}</th>
66+
<th>{{ this.tooltipInfo.cName }}</th>
6767
<td>{{ this.tooltipInfo.c }}</td>
6868
</tr>
6969
</table>
@@ -137,8 +137,8 @@ export default {
137137
return {
138138
tooltipInfo: {
139139
x: '',
140-
i: 0,
141-
c: ''
140+
c: '',
141+
cName: '',
142142
},
143143
highlightX1: null,
144144
highlightX2: null,
@@ -155,8 +155,6 @@ export default {
155155
uuid += 1;
156156
},
157157
created() {
158-
console.assert(this.dataArray.length === this.cArray.length);
159-
160158
// Set data
161159
this._dataContainers = this.dataArray.map((dataKey) => {
162160
const dataContainer = this.getData(dataKey);
@@ -213,14 +211,46 @@ export default {
213211
},
214212
barMarginY() {
215213
this.drawPlot();
214+
},
215+
dataArray() {
216+
this._dataContainers.forEach((dataContainer) => {
217+
dataContainer.onUpdate(this.uuid, null);
218+
});
219+
220+
this._dataContainers = this.dataArray.map((dataKey) => {
221+
const dataContainer = this.getData(dataKey);
222+
console.assert(dataContainer instanceof DataContainer);
223+
return dataContainer;
224+
});
225+
226+
this._dataContainers.forEach((dataContainer) => {
227+
dataContainer.onUpdate(this.uuid, this.drawPlot);
228+
});
229+
230+
this.drawPlot();
231+
},
232+
cArray() {
233+
this._cScales.forEach((cScale) => {
234+
cScale.onUpdate(this.uuid, null);
235+
});
236+
237+
this._cScales = this.cArray.map((cKey) => {
238+
const cScale = this.getScale(cKey);
239+
console.assert(cScale instanceof AbstractScale);
240+
return cScale;
241+
});
242+
243+
this._cScales.forEach((cScale) => {
244+
cScale.onUpdate(this.uuid, this.drawPlot);
245+
});
216246
}
217247
},
218248
methods: {
219249
tooltip(mouseX, mouseY, x, i, c) {
220250
// Set values
221-
this.tooltipInfo.i = i;
222251
this.tooltipInfo.x = this._xScale.toHuman(x);
223252
this.tooltipInfo.c = this._cScales[i].toHuman(c);
253+
this.tooltipInfo.cName = this._cScales[i].name;
224254
225255
// Set position
226256
this.tooltipPosition.left = mouseX;
@@ -260,7 +290,7 @@ export default {
260290
drawPlot(d3Node) {
261291
const vm = this;
262292
263-
if(vm._dataContainers.reduce((a, h) => (a || h.isLoading), false) || vm._cScales.reduce((a, h) => (a || h.isLoading), false) || vm._xScale.isLoading) {
293+
if(vm._dataContainers.length !== vm._cScales.length || vm._dataContainers.reduce((a, h) => (a || h.isLoading), false) || vm._cScales.reduce((a, h) => (a || h.isLoading), false) || vm._xScale.isLoading) {
264294
return;
265295
}
266296

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy