Skip to content

Commit

Permalink
fix(data): Fix nullish data filtering for grouped data
Browse files Browse the repository at this point in the history
Do not exclude nullish data to determine axis' max value
for grouped data.

Ref naver#2096
  • Loading branch information
netil committed May 25, 2021
1 parent 9801594 commit a3650a3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ChartInternal/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,12 @@ export default {
const data: any[] = [];

t.values
.filter(v => isValue(v.value))
.filter(({value}) => isValue(value) || value === null)
.forEach(v => {
let {value} = v;

// exclude 'volume' value to correct mis domain calculation
if ($$.isCandlestickType(v)) {
if (value !== null && $$.isCandlestickType(v)) {
value = isArray(value) ? value.slice(0, 4) : [value.open, value.high, value.low, value.close];
}

Expand Down
31 changes: 31 additions & 0 deletions test/internals/axis-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2666,6 +2666,37 @@ describe("AXIS", function() {

expect(bb.generate(args)).to.not.throw;
});

it("set options", () => {
args = {
data: {
x: "x",
columns: [
["x", "1180", "980", "915"],
["1180", 74.07, null, null],
["980", null, 43.75, null],
["915", null, null, 42.47]
],
type: "bar",
groups: [
["1180", "980", "915"]
]
},
axis: {
x: {
type: "category"
}
}
};
});

it("y Axis max value should be scaled properly", () => {
const {internal} = chart;
const {max} = internal.getMinMaxValue();

expect(internal.scale.y.domain()[1]).to.be.closeTo(max, 10);
expect(+internal.$el.axis.y.select(".tick:nth-child(10) tspan").text()).to.be.closeTo(max, 10);
});
});

describe("x Axis tick width size", () => {
Expand Down

0 comments on commit a3650a3

Please sign in to comment.