Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(size): Correct height increase during resize #223

Merged
merged 2 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dist: trusty # needs Ubuntu Trusty
sudo: false # no need for virtualization.
before_install:
- npm install -g npm@5
- yarn global add greenkeeper-lockfile@1
- npm install -g greenkeeper-lockfile@1
install:
- npm install
addons:
Expand Down
33 changes: 31 additions & 2 deletions spec/bb-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
/* eslint-disable */
import {bb} from "../src/core";
import util from "./assets/util";

describe("Interface & initialization", () => {
it("Check for billboard.js object", () => {
Expand All @@ -13,7 +14,7 @@ describe("Interface & initialization", () => {
});

it("Check for initialization", () => {
const chart = bb.generate({
const chart = util.generate({
data: {
columns: [
["data1", 30]
Expand All @@ -29,7 +30,7 @@ describe("Interface & initialization", () => {
it("should resize correctly in flex container", done => {
// set flex container
document.body.innerHTML = '<div style="display:flex"><div style="display:block;flex-basis:0;flex-grow:1;flex-shrink:1"><div id="flex-container"></div></div></div>';
const chart = bb.generate({
const chart = util.generate({
bindto: "#flex-container",
data: {
columns: [
Expand All @@ -55,6 +56,34 @@ describe("Interface & initialization", () => {
}, 100);
});

it("height shouldn't be increased on resize event", done => {
const body = document.body;
body.innerHTML = '<div id="chartResize"></div>';

const chart = bb.generate({
bindto: "#chartResize",
data: {
columns: [
["data1", 30, 200, 100, 400],
["data2", 500, 800, 500, 2000]
]
}
});
const chartHeight = +chart.internal.svg.attr("height");

body.style.width = `${+body.style.width.replace("px", "") - 100}px`;
chart.internal.resizeFunction();

setTimeout(() => {
expect(+chart.internal.svg.attr("height")).to.be.equal(chartHeight);

// reset the body
body.removeAttribute("style");
body.innerHTML = "";
done();
}, 500);
});

it("instantiate with different classname on wrapper element", () => {
const bindtoClassName = "billboard-js";
const chart = bb.generate({
Expand Down
6 changes: 2 additions & 4 deletions src/internals/ChartInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ export default class ChartInternal {
// -- Basic Elements --

$$.svg = $$.selectChart.append("svg")
.style("overflow", "hidden");
.style("overflow", "hidden")
.style("display", "block");

if (config.interaction_enabled && $$.inputType) {
const isTouch = $$.inputType === "touch";
Expand Down Expand Up @@ -1036,9 +1037,6 @@ export default class ChartInternal {
.attr("width", $$.width)
.attr("height", $$.height);

// MEMO: parent div"s height will be bigger than svg when <!DOCTYPE html>
$$.selectChart.style("max-height", `${$$.currentHeight}px`);

$$.brush && $$.brush.scale($$.subX, brushHeight);
}

Expand Down