Skip to content

Commit

Permalink
fix(radar): Fix incorrect rendering (#738)
Browse files Browse the repository at this point in the history
Add type check for ratio value to not erroneously use radar.size.ratio
value.

Fix #735
Close #738
  • Loading branch information
netil committed Jan 18, 2019
1 parent ca53f35 commit f8915e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions spec/shape/shape.radar-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@ describe("SHAPE RADAR", () => {
x: "x",
columns: [
["x", "Design", "Price", "Brand"],
["data1", 30, 200, 100]
["data1", 230, 0, 100]
],
type: "radar"
},
radar: {}
};
});

it("check for shape rendering", done => {
const radar = chart.$.main.select(`.${CLASS.chartRadars}`);
const expectedPoints = "233,30.290000000000003 233,233 309.32696069614934,277.06739130434784";

setTimeout(() => {
expect(radar.select(".bb-shapes polygon").attr("points")).to.be.equal(expectedPoints);

done();
}, 200)
});

it("Should render level, axes and data edges", () => {
const radar = chart.internal.main.select(`.${CLASS.chartRadars}`);
const radar = chart.$.main.select(`.${CLASS.chartRadars}`);
const data = chart.data();
const dataLen = data[0].values.length;

Expand Down Expand Up @@ -63,7 +74,7 @@ describe("SHAPE RADAR", () => {
});

it("check for axis options", () => {
const radar = chart.internal.main.select(`.${CLASS.chartRadars}`);
const radar = chart.$.main.select(`.${CLASS.chartRadars}`);
const axis = radar.selectAll(`.${CLASS.axis}`);

expect(axis.selectAll("line").empty()).to.be.true;
Expand All @@ -78,7 +89,7 @@ describe("SHAPE RADAR", () => {
});

it("check for level options", () => {
const radar = chart.internal.main.select(`.${CLASS.chartRadars}`);
const radar = chart.$.main.select(`.${CLASS.chartRadars}`);
const levels = radar.select(`.${CLASS.levels}`);
const level = levels.selectAll("polygon");

Expand Down
4 changes: 2 additions & 2 deletions src/shape/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "d3-selection";
import ChartInternal from "../internals/ChartInternal";
import CLASS from "../config/classes";
import {extend, getMinMax, getRange, isDefined, isEmpty, isUndefined, toArray} from "../internals/util";
import {extend, getMinMax, getRange, isDefined, isEmpty, isNumber, isUndefined, toArray} from "../internals/util";

/**
* Get the position value
Expand Down Expand Up @@ -91,7 +91,7 @@ extend(ChartInternal.prototype, {
edge,
index,
isDefined(range) ? range : (type === "x" ? width : height),
ratio || config.radar_size_ratio
isNumber(ratio) ? ratio : config.radar_size_ratio
));

return pos.length === 1 ? pos[0] : pos;
Expand Down

0 comments on commit f8915e2

Please sign in to comment.