Skip to content

Commit 34e4cec

Browse files
committed
Fix bug with unknown values and multidata plots
1 parent 30fa595 commit 34e4cec

File tree

3 files changed

+63
-42
lines changed

3 files changed

+63
-42
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.2",
3+
"version": "1.11.3",
44
"private": false,
55
"scripts": {
66
"serve": "vue-cli-service serve --open ./examples-src/index.js",

src/components/plots/MultiDataRectPlot.vue

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import AbstractScale from './../../scales/AbstractScale.js';
5858
import DataContainer from './../../data/DataContainer.js';
5959
6060
import mixin from './mixin.js';
61+
import ContinuousScale from './../../scales/ContinuousScale.js';
6162
import CategoricalScale from './../../scales/CategoricalScale.js';
6263
6364
let uuid = 0;
@@ -382,32 +383,42 @@ export default {
382383
}
383384
384385
point.forEach((pointValue, i) => {
385-
const col = genColor();
386-
colToNode[col] = { "i": i, "c": point[i][vm.cArray[i]] };
387-
contextHidden.fillStyle = col;
388-
389-
const textValue = this._cScales[i].toHuman(point[i][vm.cArray[i]]);
390-
391-
const rect = two.makeRectangle(
392-
0.5 + rectWidth/2, y(i) + rectHeight/2,
393-
rectWidth, rectHeight - rectMargin
394-
);
395-
contextHidden.fillRect(
396-
0.5, y(i),
397-
rectWidth, rectHeight
398-
);
399-
400-
const text = two.makeText(
401-
textOffsetX + 4, y(i) + (rectHeight/2) + 7,
402-
textWidth, rectHeight, textValue
403-
);
404-
405-
text.textalign = "left";
406-
rect.fill = cScales[i].color(point[i][vm.cArray[i]]);
407-
rect.noStroke();
408-
409-
text.fontsize = vm.textSize;
410-
text.fill = vm.textColor;
386+
const d = point[i][vm.cArray[i]];
387+
if(
388+
AbstractScale.isUnknown(d) ||
389+
(
390+
(cScales[i] instanceof CategoricalScale && cScales[i].domainFiltered.includes(d))
391+
||
392+
(cScales[i] instanceof ContinuousScale && cScales[i].domainFiltered[0] <= d && cScales[i].domainFiltered[1] >= d)
393+
)
394+
) {
395+
const col = genColor();
396+
colToNode[col] = { "i": i, "c": d };
397+
contextHidden.fillStyle = col;
398+
399+
const textValue = this._cScales[i].toHuman(d);
400+
401+
const rect = two.makeRectangle(
402+
0.5 + rectWidth/2, y(i) + rectHeight/2,
403+
rectWidth, rectHeight - rectMargin
404+
);
405+
contextHidden.fillRect(
406+
0.5, y(i),
407+
rectWidth, rectHeight
408+
);
409+
410+
const text = two.makeText(
411+
textOffsetX + 4, y(i) + (rectHeight/2) + 7,
412+
textWidth, rectHeight, textValue
413+
);
414+
415+
text.textalign = "left";
416+
rect.fill = cScales[i].color(d);
417+
rect.noStroke();
418+
419+
text.fontsize = vm.textSize;
420+
text.fill = vm.textColor;
421+
}
411422
});
412423
413424

src/components/plots/MultiDataTrackPlot.vue

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ import AbstractScale from './../../scales/AbstractScale.js';
8585
import DataContainer from './../../data/DataContainer.js';
8686
8787
import mixin from './mixin.js';
88+
import ContinuousScale from './../../scales/ContinuousScale.js';
89+
import CategoricalScale from './../../scales/CategoricalScale.js';
8890
8991
let uuid = 0;
9092
/**
@@ -398,21 +400,29 @@ export default {
398400
399401
vm.dataArray.forEach((dataKey, i) => {
400402
datas[i].forEach((d) => {
401-
402-
const col = genColor();
403-
colToNode[col] = { "x": d[vm.x], "i": i, "c": d[vm.cArray[i]] };
404-
contextHidden.fillStyle = col;
405-
406-
const rect = two.makeRectangle(
407-
x(d[vm.x]) + (barMarginX/2) + (barWidth - barMarginX)/2 + 0.5,
408-
y(i) + (barMarginY/2) + (barHeight - barMarginY)/2,
409-
barWidth - barMarginX,
410-
barHeight - barMarginY
411-
);
412-
rect.fill = cScales[i].color(d[vm.cArray[i]]);
413-
rect.noStroke();
414-
415-
contextHidden.fillRect(x(d[vm.x]) + 0.5, y(i), barWidth, barHeight);
403+
if(
404+
AbstractScale.isUnknown(d[vm.cArray[i]]) ||
405+
(
406+
(cScales[i] instanceof CategoricalScale && cScales[i].domainFiltered.includes(d[vm.cArray[i]]))
407+
||
408+
(cScales[i] instanceof ContinuousScale && cScales[i].domainFiltered[0] <= d[vm.cArray[i]] && cScales[i].domainFiltered[1] >= d[vm.cArray[i]])
409+
)
410+
) {
411+
const col = genColor();
412+
colToNode[col] = { "x": d[vm.x], "i": i, "c": d[vm.cArray[i]] };
413+
contextHidden.fillStyle = col;
414+
415+
const rect = two.makeRectangle(
416+
x(d[vm.x]) + (barMarginX/2) + (barWidth - barMarginX)/2 + 0.5,
417+
y(i) + (barMarginY/2) + (barHeight - barMarginY)/2,
418+
barWidth - barMarginX,
419+
barHeight - barMarginY
420+
);
421+
rect.fill = cScales[i].color(d[vm.cArray[i]]);
422+
rect.noStroke();
423+
424+
contextHidden.fillRect(x(d[vm.x]) + 0.5, y(i), barWidth, barHeight);
425+
}
416426
});
417427
});
418428

0 commit comments

Comments
 (0)