Skip to content

Commit

Permalink
Merge branch 'master' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
netil committed Sep 13, 2023
2 parents 522c35a + 20fc229 commit 7941e93
Show file tree
Hide file tree
Showing 10 changed files with 397 additions and 250 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ jongwooo <[email protected]>
Jørn Andre Sundt <[email protected]>
Erik Hopp <[email protected]>
Do Yoon Kim <[email protected]>
RobinDeeCee <[email protected]>
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"d3-zoom": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.22.15",
"@babel/core": "^7.22.17",
"@babel/eslint-parser": "^7.22.15",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
Expand All @@ -126,8 +126,8 @@
"@types/d3": "^7.4.0",
"@types/mocha": "^10.0.1",
"@types/sinon": "^10.0.16",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"babel-helper-modules": "^6.0.0",
"babel-loader": "^9.1.3",
"babel-plugin-add-module-exports": "^1.0.4",
Expand All @@ -143,7 +143,7 @@
"chai": "^4.3.8",
"clean-webpack-plugin": "^4.0.0",
"cloc": "^2.11.0",
"core-js": "^3.32.1",
"core-js": "^3.32.2",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"css-loader": "^6.8.1",
Expand All @@ -154,10 +154,10 @@
"d3-polygon": "^3.0.1",
"docdash": "^2.0.2",
"dtslint": "^4.2.1",
"eslint": "^8.48.0",
"eslint": "^8.49.0",
"eslint-config-naver": "^2.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsdoc": "^46.5.1",
"eslint-plugin-jsdoc": "^46.6.0",
"eslint-webpack-plugin": "^4.0.1",
"exports-loader": "^4.0.0",
"hammer-simulator": "0.0.1",
Expand All @@ -181,7 +181,7 @@
"mocha": "^10.2.0",
"node-sass": "^9.0.0",
"regenerator-runtime": "^0.14.0",
"rollup": "^3.28.1",
"rollup": "^3.29.1",
"rollup-plugin-delete": "^2.0.0",
"sass-loader": "^13.3.2",
"semantic-release": "^21.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/ChartInternal/internals/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ export default {
const [min, max] = zoomDomain;

if (isInverted ? domain[0] >= min : domain[0] <= min) {
domain[0] = min;
domain[1] = +domain[1] + (min - domain[0]);
domain[0] = min;
}

if (isInverted ? domain[1] <= max : domain[1] >= max) {
Expand Down
13 changes: 12 additions & 1 deletion src/Plugin/tableview/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,18 @@ export default class Options {
* @example
* legendToggleUpdate: false
*/
updateOnToggle: true
updateOnToggle: true,

/**
* Set how null value to be shown.
* @name showNulls
* @memberof plugin-tableview
* @type {string}
* @default "-"
* @example
* nullString: "N/A"
*/
nullString: "-"
};
}
}
5 changes: 3 additions & 2 deletions src/Plugin/tableview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import {isNumber, tplProcess} from "../../module/util";
* class: "my-class-name",
* style: true,
* title: "My Data List",
* updateOnToggle: false
* updateOnToggle: false,
* nullString: "N/A"
* }),
* ]
* });
Expand Down Expand Up @@ -134,7 +135,7 @@ export default class TableView extends Plugin {
v.map((d, i) => tplProcess(i ? tpl.tbody : tpl.tbodyHeader, {
value: i === 0 ?
config.categoryFormat.bind(this)(d) :
(isNumber(d) ? d.toLocaleString() : "")
(isNumber(d) ? d.toLocaleString() : config.nullString)
})).join("")
}</tr>`;
});
Expand Down
32 changes: 32 additions & 0 deletions test/internals/domain-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,36 @@ describe("DOMAIN", function() {
expect(y2.domain()).to.be.deep.equal(domain);
});
});

describe("trimXDomain", () => {
before(() => {
args = {
data: {
columns: [
["sample", 30, 200, 100, 400, 150, 250, 150, 200, 170, 240, 350, 150, 100, 400, 150],
],
type: "line",
},
zoom: {
enabled: true,
},
}
});

it("test pan left gets trimmed", () => {
const domain = chart.internal.scale.x.domain();
const trimmed = chart.internal.trimXDomain(domain.map((x: number) => x - 10));

expect(trimmed[0]).to.approximately(domain[0], 0.1);
expect(trimmed[1]).to.approximately(domain[1], 0.1);
});

it("test pan right gets trimmed", () => {
const domain = chart.internal.scale.x.domain();
const trimmed = chart.internal.trimXDomain(domain.map((x: number) => x + 5));

expect(trimmed[0]).to.approximately(domain[0], 0.1);
expect(trimmed[1]).to.approximately(domain[1], 0.1);
});
});
});
62 changes: 62 additions & 0 deletions test/plugin/tableview/tableview-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,66 @@ describe("PLUGIN: TABLE-VIEW", () => {
expect(document.querySelector(`#${defaultStyle.id}`)).to.be.null;
});
});

describe("nullString option", () => {
before(() => {
args = {
data: {
x: "x",
columns: [
["x", "2023", "2024", "2025", "2026"],
["data1", 1230, null, null, 1238],
["data2", 500, 120, 100, null]
],
},
axis: {
x: {
type: "category"
}
},
plugins: [
new TableView({
title: "My Yearly Data List",
categoryTitle: "Year",
style: true
})
]
};
});

it("check default nullString value: '-'", () => {
const tr = document.querySelectorAll(".bb-tableview tr");

[].slice.call(tr).forEach(v => {
const x = v.querySelector("th").textContent;

if (/202(4|5|6)/.test(x)) {
expect(v.querySelectorAll("td")[x === "2026" ? 1 : 0].textContent).to.be.equal("-");
}
});
});

it("set options: nullString='N/A'", () => {
args.plugins = [
new TableView({
title: "My Yearly Data List",
categoryTitle: "Year",
style: true,
nullString: "N/A"
})
];
});

it("when nullString value is specified: 'N/A'", () => {
const tr = document.querySelectorAll(".bb-tableview tr");

[].slice.call(tr).forEach(v => {
const x = v.querySelector("th").textContent;

if (/202(4|5|6)/.test(x)) {
expect(v.querySelectorAll("td")[x === "2026" ? 1 : 0].textContent).to.be.equal("N/A");
}
});
});
});
});
39 changes: 39 additions & 0 deletions test/shape/point-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/* eslint-disable */
/* global describe, beforeEach, it, expect */
import {expect} from "chai";
import {window} from "../../src/module/browser"
import util from "../assets/util";
import {$CIRCLE} from "../../src/config/classes";

Expand Down Expand Up @@ -142,6 +143,44 @@ describe("SHAPE POINT", () => {
it("custom point's position for null data shoudn't be set as NaN", () => {
expect(chart.$.circles.filter(":last-child").attr("y")).to.not.equal("NaN");
});

it("set optiosn", () => {
args = {
data: {
columns: [
["data1", 30, 200, 100, 400, -150, 250],
["data 2", 50, 20, 10, 40, 15, 25],
["data3", -150, 120, 110, 140, 115, 125]
],
selection: {
enabled: true
}
},
point: {
pattern: [
"<polygon points='2.5 0 0 5 5 5'></polygon>"
]
}
};
});

it("", done => {
const target = {
id: "data3",
index: 2
};

// when
chart.select(target.id, [target.index], true);
chart.hide(target.id);

setTimeout(() => {
const point = chart.$.circles.filter(d => d.id === target.id && d.index == target.index).node();

expect(point.parentNode.style.opacity).to.be.equal("0");
done();
}, 300);
});
});

describe("point transition", () => {
Expand Down
5 changes: 5 additions & 0 deletions types/plugin/tableview/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ export interface TableViewOptions {
* Update tableview from data visibility update(ex. legend toggle).
*/
updateOnToggle?: boolean;

/**
* Set how null value to be shown.
*/
nullString?: string;
}
Loading

0 comments on commit 7941e93

Please sign in to comment.