Skip to content

Commit

Permalink
fix(type): filter nullish data
Browse files Browse the repository at this point in the history
Filter nullish data to exclude from rendering

Fix #2020
  • Loading branch information
netil committed Mar 30, 2021
1 parent 48e4f56 commit 857bbca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/ChartInternal/internals/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2017 ~ present NAVER Corp.
* billboard.js project is licensed under the MIT license
*/
import {isString, isArray} from "../../module/util";
import {isArray, isNumber, isString} from "../../module/util";
import {TYPE, TYPE_BY_CATEGORY} from "../../config/const";

export default {
Expand Down Expand Up @@ -236,7 +236,7 @@ export default {
this.isScatterType(d) ||
this.isBubbleType(d) ||
this.isCandlestickType(d) ||
this.isRadarType(d) ? d.values : [];
this.isRadarType(d) ? d.values.filter(v => isNumber(v.value) || Boolean(v.value)) : [];
},

barLineBubbleData(d) {
Expand Down
8 changes: 4 additions & 4 deletions test/internals/data-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("DATA", () => {
delta = {x: delta, y: delta};
}

return function(d, i) {
return function(d, i) {
const node = d3Select(this);

expect(+node.attr(`${prefix}x`)).to.be.closeTo(x[i], delta.x);
Expand Down Expand Up @@ -90,7 +90,7 @@ describe("DATA", () => {

it("should draw correctly", () => {
const expectedCx = {443: [98, 294, 490], 995: [98, 294, 490]};
const expectedCy = {443: [194, 351, 36], 995: [391, 430, 351]};
const expectedCy = {443: [194, 351, 36], 995: [391, 0, 351]};
const main = chart.$.main;

main.selectAll(`.${CLASS.circles}-443 .${CLASS.circle}`)
Expand Down Expand Up @@ -153,10 +153,10 @@ describe("DATA", () => {
const expectedCx = [98, 294, 490];
const expectedCy = {
443: [181, 326, 36],
995: [362, 398, 326],
995: [362, 0, 326],
112: [354, 347, 340],
223: [391, 383, 376],
334: [376, 398, 362],
334: [376, 0, 362],
556: [326, 253, 181],
"778.889": [347, 376, 340]
};
Expand Down

0 comments on commit 857bbca

Please sign in to comment.