diff --git a/src/ChartInternal/Axis/Axis.ts b/src/ChartInternal/Axis/Axis.ts index 5aa7a6292..65abd9fe8 100644 --- a/src/ChartInternal/Axis/Axis.ts +++ b/src/ChartInternal/Axis/Axis.ts @@ -779,7 +779,7 @@ class Axis { $$.getXDomainMax($$.data.targets) + 1 + right ]); - tickOffset = Math.ceil((scale(1) - scale(0)) / 2); + tickOffset = (scale(1) - scale(0)) / 2; } return maxOverflow + tickOffset; diff --git a/src/ChartInternal/Axis/AxisRenderer.ts b/src/ChartInternal/Axis/AxisRenderer.ts index 5c4c4efac..5f6ea1aff 100644 --- a/src/ChartInternal/Axis/AxisRenderer.ts +++ b/src/ChartInternal/Axis/AxisRenderer.ts @@ -93,7 +93,7 @@ export default class AxisRenderer { $g = g; this.__chart__ = scale1; - config.tickOffset = params.isCategory ? Math.ceil((scale1(1) - scale1(0)) / 2) : 0; + config.tickOffset = params.isCategory ? (scale1(1) - scale1(0)) / 2 : 0; // update selection - data join const path = g.selectAll(".domain").data([0]); @@ -407,12 +407,10 @@ export default class AxisRenderer { tickWidth = isLeftRight ? 95 : ( params.isCategory ? ( - Math.ceil( - params.isInverted ? - scale(ticks[0]) - scale(ticks[1]) : - scale(ticks[1]) - scale(ticks[0]) - ) - 12 - ) : + params.isInverted ? + scale(ticks[0]) - scale(ticks[1]) : + scale(ticks[1]) - scale(ticks[0]) + ) - 12 : 110 ); } diff --git a/src/ChartInternal/Axis/AxisRendererHelper.ts b/src/ChartInternal/Axis/AxisRendererHelper.ts index 33b698e59..9a957cad5 100644 --- a/src/ChartInternal/Axis/AxisRendererHelper.ts +++ b/src/ChartInternal/Axis/AxisRendererHelper.ts @@ -80,7 +80,7 @@ export default class AxisRendererHelper { selection.attr("transform", d => { const x = scale(d); - return isValue(d) ? fn(Math.ceil(x)) : null; + return isValue(d) ? fn(x) : null; }); }; } diff --git a/src/ChartInternal/internals/grid.ts b/src/ChartInternal/internals/grid.ts index daa766e5d..3d5354f1d 100644 --- a/src/ChartInternal/internals/grid.ts +++ b/src/ChartInternal/internals/grid.ts @@ -45,7 +45,7 @@ function smoothLines(el, type: string): void { const g = d3Select(this); ["x1", "x2", "y1", "y2"] - .forEach(v => g.attr(v, Math.ceil(+g.attr(v)))); + .forEach(v => g.attr(v, +g.attr(v))); }); } } @@ -138,7 +138,7 @@ export default { const $$ = this; const {axis, config, scale, state, $el: {grid, main}} = $$; const isRotated = config.axis_rotated; - const pos = d => Math.ceil(scale.y(d)); + const pos = d => scale.y(d); const gridValues = axis.y.getGeneratedTicks(config.grid_y_ticks) || $$.scale.y.ticks(config.grid_y_ticks); diff --git a/src/ChartInternal/internals/scale.ts b/src/ChartInternal/internals/scale.ts index 7b6ee97e7..3361106e1 100644 --- a/src/ChartInternal/internals/scale.ts +++ b/src/ChartInternal/internals/scale.ts @@ -103,14 +103,11 @@ export default { /** * Get scaled value * @param {object} d Data object - * @param {boolean} raw Get the raw value * @returns {number} * @private */ - const scale = function(d: IDataRow, raw?: boolean): number { - const v = scaleValue(d) + offset(); - - return raw ? v : Math.ceil(v); + const scale = function(d: IDataRow): number { + return scaleValue(d) + offset(); }; // copy original scale methods @@ -258,7 +255,7 @@ export default { value = config.axis_x_categories.indexOf(value); } - return Math.ceil(fn(value)); + return fn(value); }, yv(d: IGridData): number { @@ -266,7 +263,7 @@ export default { const {scale: {y, y2}} = $$; const yScale = d.axis && d.axis === "y2" ? y2 : y; - return Math.ceil(yScale($$.getBaseValue(d))); + return yScale($$.getBaseValue(d)); }, subxx(d: IDataRow): number | null { diff --git a/src/Plugin/stanford/Elements.ts b/src/Plugin/stanford/Elements.ts index 240ff89b4..f3e0e9333 100644 --- a/src/Plugin/stanford/Elements.ts +++ b/src/Plugin/stanford/Elements.ts @@ -163,7 +163,7 @@ export default class Elements { value = config.axis_x_categories.indexOf(d.value); } - return Math.ceil($$.scale.x(value)); + return $$.scale.x(value); } yvCustom(d, xyValue): number { @@ -171,6 +171,6 @@ export default class Elements { const yScale = d.axis && d.axis === "y2" ? $$.scale.y2 : $$.scale.y; const value = xyValue ? d[xyValue] : $$.getBaseValue(d); - return Math.ceil(yScale(value)); + return yScale(value); } } diff --git a/test/api/axis-spec.ts b/test/api/axis-spec.ts index 458ca00dc..927636da4 100644 --- a/test/api/axis-spec.ts +++ b/test/api/axis-spec.ts @@ -11,7 +11,7 @@ import {$AXIS} from "../../src/config/classes"; describe("API axis", function() { let chart; let main; - const rx = /translate\((\d+),.*/; + const rx = /translate\(([^,]*),.*/; beforeAll(() => { return new Promise(resolve => { @@ -115,7 +115,7 @@ describe("API axis", function() { setTimeout(() => { let tspan; - + // check for x max value expect(xTickValue).to.be.below(+xAxisTick.getAttribute("transform").replace(rx, "$1")); diff --git a/test/api/chart-spec.ts b/test/api/chart-spec.ts index c50632e7d..4aa604ea4 100644 --- a/test/api/chart-spec.ts +++ b/test/api/chart-spec.ts @@ -62,7 +62,7 @@ describe("API chart", () => { expect(chart.groups()[0].length).to.be.equal(chart.data().length); // check for the bars were stacked - expect(util.getBBox(path).width).to.be.equal(barWidth * 2); + expect(util.getBBox(path).width).to.be.closeTo(barWidth * 2, 1); }); }); diff --git a/test/api/export-spec.ts b/test/api/export-spec.ts index 2f6a683d4..9e391ea7f 100644 --- a/test/api/export-spec.ts +++ b/test/api/export-spec.ts @@ -201,15 +201,15 @@ describe("API export", () => { // pattern for local: preserveFontStyle=true [ - "i2iAoIcLvwVDzzAQUBmuodjmOmu+NeryqrOrq4jsyozKyLzy99vftNVcb343ou", - "JXSOKRvoLXeaeBnwyQ3q5TJIDtEMpaehdeQBLArBlL9P1Ni", - "iDzpkxgBoCd9qkExwC4O8qSCPVk3lyWshNuFqQAdJNm6rb+GVkH2CdOcenYIgj5Cy" + "UwUQECoIlWYZu6qgABsKvys3LDFCAAGmYQNocKRKQAATAiIVlMehQgAKbHluxJ", + "bAOgeAH1QlUcTZOjJOFPV7zN3zDlq/tQUvMb1kYAjNcQLZROAGxBtNTf0oIXkACY", + "CZAACZAACZAABSCfARIgARIgARIgARLIMQIUgDkWcHaXBEiABEiABEiABCgA" ], // pattern for webdriverio [ "nSetJ0vvOG1XcoZ8BQEeD3w9CCB6BGIkmCiAIze", - "BhTIwMPCQiOxewt4m8Xj8HxSAQVGnnXoQ0J7YGzDD", + "5Ku10DhdnT36vaRow3ZSgXoFLMsSYJMwL9XnRanBgYGBojufZVlvBCChjpwQMZJcsj", "ANwDC7nf6iqhRcXno2cQP2wnXM4qpFnSLACzpHlfYysmAV1jezaWxGgmFrai6bp9Y6Ryp2AaM" ], @@ -229,9 +229,9 @@ describe("API export", () => { // pattern for CI: preserveFontStyle=true [ - "Y2qtWP1Xg3AYmsmlBQxSAnANJJZDP5y8H8Jkp4isBWDubzS4fbcPjIamzgX", - "Y9JUCsM6Jy+ZOENCezn8CehhUI917sy0C0BI05itQPV9yQz9yAiidIIEEE6AA", - "aWV7xEDDrkhf0fgX/bLgG8I6wWjMTYt7S5hUPATMJ8LVBquISlXg0MLWYtfrmGzn" + "MMcesnMiKAsgzhwTak0AtArgzgC+WwHEfALtR6FRltwPYGMDxAHYHYAA8B", + "2HTkHLCWAg4nrEehzQNDS997GQgCNORiBbCPDmWN4MpEACVRGoFYBrKz35t", + "gFcBOMOf8rUAftrP9AcCOMkvvxfA8hxSvQJglx51zgZwRQUAMMg5PQTg21nm" ] ]; diff --git a/test/api/flow-spec.ts b/test/api/flow-spec.ts index a3955c0d4..8a5378304 100644 --- a/test/api/flow-spec.ts +++ b/test/api/flow-spec.ts @@ -263,7 +263,7 @@ describe("API flow", () => { const tick = this.internal.$el.axis.x.select(".tick"); expect(tick.text()).to.be.equal("17/01/11"); - expect(tick.attr("transform")).to.be.equal("translate(6,0)"); + expect(+tick.attr("transform").match(/\(([^,]+)/)[1]).to.be.closeTo(6, 1); done(1); } @@ -450,12 +450,15 @@ describe("API flow", () => { done() { this.$.main.selectAll(`.${$LINE.chartLine} path`).each(function(d, i) { const rect = this.getBoundingClientRect(); + const pos = [rect.width, rect.x]; const expected = { data1: [588, 46.5], data2: [294, 340.5] }; - expect([rect.width, rect.x]).to.be.deep.equal(expected[d.id]); + expected[d.id].forEach((v, i) => { + expect(v).to.be.closeTo(pos[i], 1); + }); }); done(1); diff --git a/test/api/grid-spec.ts b/test/api/grid-spec.ts index 7f10c0539..db3c20b30 100644 --- a/test/api/grid-spec.ts +++ b/test/api/grid-spec.ts @@ -50,7 +50,7 @@ describe("API grid", function() { grids.each(function (d, i) { const y = +d3Select(this).select("line").attr("y1"); const text = d3Select(this).select("text").text(); - const expectedY = Math.round(chart.internal.scale.y(expectedGrids[i].value)); + const expectedY = chart.internal.scale.y(expectedGrids[i].value); const expectedText = expectedGrids[i].text; expect(y).to.be.equal(expectedY); @@ -98,7 +98,7 @@ describe("API grid", function() { grids.each(function(d, i) { const x = +d3Select(this).select("line").attr("x1"); const text = d3Select(this).select("text").text(); - const expectedX = Math.round(chart.internal.scale.x(expectedGrids[i].value)); + const expectedX = chart.internal.scale.x(expectedGrids[i].value); const expectedText = expectedGrids[i].text; expect(x).to.be.equal(expectedX); @@ -229,7 +229,7 @@ describe("API grid", function() { const line = chart.internal.$el.gridLines.x.select("line"); - expect(+line.attr("x1")).to.be.equal(298); + expect(+line.attr("x1")).to.be.equal(299.5); expect(+line.attr("y2")).to.be.equal(426); }); }); diff --git a/test/api/region-spec.ts b/test/api/region-spec.ts index 5c4eb85a2..d3771efb5 100644 --- a/test/api/region-spec.ts +++ b/test/api/region-spec.ts @@ -242,7 +242,7 @@ describe("API regions", function() { const rect = chart.internal.$el.region.list.select("rect").node().getBoundingClientRect(); - expect(rect.width).to.be.equal(300); + expect(rect.width).to.be.equal(299.5); expect(rect.height).to.be.equal(426); }); }); diff --git a/test/api/subchart-spec.ts b/test/api/subchart-spec.ts index d44156f4e..b26d3bf36 100644 --- a/test/api/subchart-spec.ts +++ b/test/api/subchart-spec.ts @@ -117,7 +117,7 @@ describe("API subchart", () => { const currentPath = this.internal.$el.subchart.line.attr("d"); expect(currentPath).to.be.not.equal(path); - expect(currentPath).to.be.equal("M6,38.694L300,55.083L594,5.917"); + expect(currentPath).to.be.equal("M5.873,38.694L299.5,55.083L593.127,5.917"); done(1); } }); diff --git a/test/assets/util.ts b/test/assets/util.ts index 6b02adeae..635117a13 100644 --- a/test/assets/util.ts +++ b/test/assets/util.ts @@ -125,8 +125,10 @@ function sandbox(obj: string | HTMLDivElement, prop?): HTMLDivElement { // test should executed from 'coverage:ci' command const isCI = process.env.NODE_ENV === "CI"; +const ceil = v => Math.ceil(v); export default { + ceil, destroyAll, doDrag, fireEvent, diff --git a/test/interactions/zoom-spec.ts b/test/interactions/zoom-spec.ts index f91f7f161..205b2d84f 100644 --- a/test/interactions/zoom-spec.ts +++ b/test/interactions/zoom-spec.ts @@ -392,7 +392,7 @@ describe("ZOOM", function() { const getX = selector => chart.$.main.select(selector).node().getBoundingClientRect().x; // when zoom in - chart.zoom([1,3]); + chart.zoom([1,3.5]); setTimeout(() => { expect( diff --git a/test/internals/axis-spec.ts b/test/internals/axis-spec.ts index 08ed4436b..83d00cb86 100644 --- a/test/internals/axis-spec.ts +++ b/test/internals/axis-spec.ts @@ -74,7 +74,7 @@ describe("AXIS", function() { chart.$.main.selectAll(`.${$AXIS.axisX} .tick`).each(function(d, i) { expect( - util.parseNum(this.getAttribute("transform").split(",")[0]) + util.ceil(util.parseNum(this.getAttribute("transform").split(",")[0])) ).to.be.equal(expectedXPos[i]); }); }); @@ -889,7 +889,7 @@ describe("AXIS", function() { const text = d3Select(this); expect(text.attr("x")).to.be.equal(expectedX); - expect(text.attr("y")).to.be.equal(expectedY); + expect(util.ceil(text.attr("y"))).to.be.equal(+expectedY); }); if (i > 0) { // i === 0 should be checked in next test @@ -943,7 +943,7 @@ describe("AXIS", function() { const ticksText = chart.$.main.select(`.${$AXIS.axisX}`).selectAll("g.tick text"); ticksText.each(function() { - expect(+this.getAttribute("y")).to.be.equal(37); + expect(util.ceil(+this.getAttribute("y"))).to.be.equal(37); }); }); }); @@ -2185,8 +2185,9 @@ describe("AXIS", function() { chart.internal.state.eventReceiver.coords.forEach((d, idx) => { const tick = d3Select(ticks[idx]); + const y = +tick.attr("transform").match(/,([^)]*)/)[1]; - expect(tick.attr("transform")).to.be.equal(`translate(0,${d.y})`); + expect(y).to.closeTo(d.y, 1); }); }); @@ -3200,8 +3201,10 @@ describe("AXIS", function() { it("check if x axis min/max is not fitten.", () => { const currWidth = chart.internal.state.current.width; - chart.$.main.selectAll(`.${$AXIS.axisX} .tick`).each(function(d, i) { - const xPos = +util.parseNum(this.getAttribute("transform")) / 10; + chart.internal.$el.axis.x.selectAll(".tick").each(function(d, i) { + const xPos = +util.parseNum(this.getAttribute("transform")); + + console.log(xPos, this.getAttribute("transform")) if (i === 0) { // check min expect(xPos).to.be.below(0); @@ -3468,7 +3471,7 @@ describe("AXIS", function() { it("check the tick interval to be calculated based on the scale & ticks value", () => { // tick's inteval shouldn't be based on the assumption of ticks having same interval - expect(chart.internal.axis.x.tickInterval()).to.be.equal(22); + expect(util.ceil(chart.internal.axis.x.tickInterval())).to.be.equal(23); // bar widht's value should be set based on the scaled tick interval expect(chart.$.bar.bars.node().getBoundingClientRect().width).to.be.closeTo(6, 1); diff --git a/test/internals/axis-x-spec.ts b/test/internals/axis-x-spec.ts index a88bfd34a..a2a2f99c9 100644 --- a/test/internals/axis-x-spec.ts +++ b/test/internals/axis-x-spec.ts @@ -216,7 +216,7 @@ describe("X AXIS", function() { const {zoom} = chart.internal.scale; - expect(lines.attr("d")).to.be.equal("M1794,390.583L1196,227.858L597,323.579L-1,36.417L-599,275.718"); + expect(lines.attr("d")).to.be.equal("M1797,390.583L1198,227.858L599,323.579L0,36.417L-599,275.718"); expect(zoom(2) - zoom(3)).to.be.closeTo(600, 5); diff --git a/test/internals/data-spec.ts b/test/internals/data-spec.ts index 7e823719e..7cbd0f1da 100644 --- a/test/internals/data-spec.ts +++ b/test/internals/data-spec.ts @@ -4,7 +4,7 @@ */ /* eslint-disable */ /* global describe, beforeEach, it, expect */ -import {beforeEach, beforeAll, afterAll, describe, expect, it} from "vitest"; +import {beforeEach, beforeAll, afterEach, afterAll, describe, expect, it} from "vitest"; import {select as d3Select} from "d3-selection"; import sinon from "sinon"; import util from "../assets/util"; @@ -89,7 +89,7 @@ describe("DATA", () => { }); it("should draw correctly", () => { - const expectedCx = {443: [98, 296, 492], 995: [98, 296, 492]}; + const expectedCx = {443: [98, 294.5, 490], 995: [98, 294.5, 490]}; const expectedCy = {443: [194, 351, 36], 995: [391, 0, 351]}; const main = chart.$.main; @@ -150,7 +150,7 @@ describe("DATA", () => { it("should draw nested JSON correctly", () => { const main = chart.$.main; - const expectedCx = [98, 296, 492]; + const expectedCx = [98, 294.5, 490]; const expectedCy = { 443: [181, 326, 36], 995: [362, 0, 326], @@ -623,7 +623,7 @@ describe("DATA", () => { }); it("line path should rendered correctly.", () => { - expect(chart.$.line.lines.attr("d")).to.be.equal("M594,390.583L6,36.417L300,390.583"); + expect(chart.$.line.lines.attr("d")).to.be.equal("M593.127,390.583L5.873,36.417L299.5,390.583"); }); it("check for tooltip show", () => { diff --git a/test/internals/grid-spec.ts b/test/internals/grid-spec.ts index dfff9b256..ad29c3b87 100644 --- a/test/internals/grid-spec.ts +++ b/test/internals/grid-spec.ts @@ -165,10 +165,10 @@ describe("GRID", function() { expect(ygrids.selectAll(`.${$GRID.ygrid}`).size()).to.be.equal(3); chart.$.main.select(`.${$AXIS.axisY}`).selectAll(".tick").each(function(d, i) { - let y: any = d3Select(this).attr("transform").match(/\d+\)/); + let y: any = d3Select(this).attr("transform").match(/,([^)]+)\)$/); if (y.length >= 1) { - y = parseInt(y[0]); + y = parseInt(y[1]); } if (expectedYs[i]) { @@ -200,7 +200,7 @@ describe("GRID", function() { }); it("y grid showed with nice intervals?", () => { - const yPos = [426, 320, 214, 108, 1]; + const yPos = [426, 319.75, 213.5, 107.25, 1]; chart.$.grid.y.each(function(d, i) { expect(+this.getAttribute("y1")).to.be.equal(yPos[i]); @@ -584,7 +584,7 @@ describe("GRID", function() { lines.each(function(d, i) { const y1 = +d3Select(this).select("line").attr("y1"); - expect(y1).to.be.equal(expectedY1s[i]); + expect(y1).to.be.closeTo(expectedY1s[i], 1); }); done(1); }, 300); @@ -761,7 +761,7 @@ describe("GRID", function() { const checkFocusGridPosition = expectedPositions => { chart.$.grid.main.selectAll("line").each(function(d, i) { ["x1", "y1", "x2", "y2"].forEach(v => { - expect(+this.getAttribute(v)).to.be.equal(expectedPositions[i][v]); + expect(+this.getAttribute(v)).to.be.closeTo(expectedPositions[i][v], 1); }); }); } diff --git a/test/internals/text-spec.ts b/test/internals/text-spec.ts index a13a0b39a..56d119204 100644 --- a/test/internals/text-spec.ts +++ b/test/internals/text-spec.ts @@ -1266,10 +1266,10 @@ describe("TEXT", () => { chart = util.generate(args); const tickNodes = chart.$.svg.select(`.${$AXIS.axisY}`).selectAll("g.tick"); - const translateValues = [402, 367, 331, 296, 260, 225, 189, 154, 118, 83, 47, 12]; + const translateValues = [401, 366, 331, 295, 260, 225, 189, 154, 118, 83, 47, 12]; tickNodes.each(function(d, i) { - expect(util.parseNum(this.getAttribute("transform"))).to.be.closeTo(translateValues[i], 1); + expect(util.parseNum(this.getAttribute("transform"))).to.be.closeTo(translateValues[i], 2); }); chart.destroy(); diff --git a/test/plugin/sparkline/sparkline-spec.ts b/test/plugin/sparkline/sparkline-spec.ts index 9af5f9dac..426a5cb01 100644 --- a/test/plugin/sparkline/sparkline-spec.ts +++ b/test/plugin/sparkline/sparkline-spec.ts @@ -279,7 +279,7 @@ describe("PLUGIN: SPARKLINE", () => { chart.$.circles.each(function(d) { expect(d.x).to.be.equal(testX); - expect(+this.getAttribute("cx")).to.be.equal(90); + expect(+this.getAttribute("cx")).to.be.closeTo(90, 1); }); }); }); diff --git a/test/shape/area-range-spec.ts b/test/shape/area-range-spec.ts index 0c5cf9970..af141e267 100644 --- a/test/shape/area-range-spec.ts +++ b/test/shape/area-range-spec.ts @@ -165,9 +165,9 @@ describe("SHAPE AREA-RANGE", () => { it("check all range type path", () => { const expected = [ - "M6,400.242L79.5,400.242L79.5,327.263L226.5,327.263L226.5,322.97L373.5,322.97L373.5,331.556L520.5,331.556L520.5,391.657L594,391.657L594,344.434L520.5,344.434L520.5,254.283L373.5,254.283L373.5,288.626L226.5,288.626L226.5,292.919L79.5,292.919L79.5,365.899L6,365.899Z", - "M6,331.556C6,331.556,104,270.024,153,258.576C202,247.128,251,265.015,300,262.869C349,260.722,398,232.818,447,245.697C496,258.576,594,340.141,594,340.141L594,271.455C594,271.455,496,235.68,447,224.232C398,212.785,349,205.63,300,202.768C251,199.906,202,219.939,153,207.061C104,194.182,6,125.495,6,125.495Z", - "M6,254.283L153,172.717L300,177.01L447,245.697L594,142.667L594,83.424L447,39.636L300,116.909L153,121.202L6,185.596Z" + "M5.873,400.242L79.279,400.242L79.279,327.263L226.093,327.263L226.093,322.97L372.907,322.97L372.907,331.556L519.721,331.556L519.721,391.657L593.127,391.657L593.127,344.434L519.721,344.434L519.721,254.283L372.907,254.283L372.907,288.626L226.093,288.626L226.093,292.919L79.279,292.919L79.279,365.899L5.873,365.899Z", + "M5.873,331.556C5.873,331.556,103.748,270.024,152.686,258.576C201.624,247.128,250.562,265.015,299.5,262.869C348.438,260.722,397.376,232.818,446.314,245.697C495.252,258.576,593.127,340.141,593.127,340.141L593.127,271.455C593.127,271.455,495.252,235.68,446.314,224.232C397.376,212.785,348.438,205.63,299.5,202.768C250.562,199.906,201.624,219.939,152.686,207.061C103.748,194.182,5.873,125.495,5.873,125.495Z", + "M5.873,254.283L152.686,172.717L299.5,177.01L446.314,245.697L593.127,142.667L593.127,83.424L446.314,39.636L299.5,116.909L152.686,121.202L5.873,185.596Z" ]; chart.$.line.areas.each(function(d, i) { @@ -205,8 +205,8 @@ describe("SHAPE AREA-RANGE", () => { it("check range path", () => { const expected = [ - "M6,392.883L65,392.883L65,299.052L182.5,299.052L182.5,293.532L300,293.532L300,304.571L417.5,304.571L417.5,381.844L535,381.844L535,288.013L594,288.013L594,206.325L535,206.325L535,321.13L417.5,321.13L417.5,205.221L300,205.221L300,249.377L182.5,249.377L182.5,254.896L65,254.896L65,348.727L6,348.727Z", - "M6,304.571L65,304.571L65,210.74L182.5,210.74L182.5,216.26L300,216.26L300,194.182L417.5,194.182L417.5,315.61L535,315.61L535,172.104L594,172.104L594,95.935L535,95.935L535,227.299L417.5,227.299L417.5,166.584L300,166.584L300,138.987L182.5,138.987L182.5,144.506L65,144.506L65,39.636L6,39.636Z" + "M5.873,392.883L64.598,392.883L64.598,299.052L182.049,299.052L182.049,293.532L299.5,293.532L299.5,304.571L416.951,304.571L416.951,381.844L534.402,381.844L534.402,288.013L593.127,288.013L593.127,206.325L534.402,206.325L534.402,321.13L416.951,321.13L416.951,205.221L299.5,205.221L299.5,249.377L182.049,249.377L182.049,254.896L64.598,254.896L64.598,348.727L5.873,348.727Z", + "M5.873,304.571L64.598,304.571L64.598,210.74L182.049,210.74L182.049,216.26L299.5,216.26L299.5,194.182L416.951,194.182L416.951,315.61L534.402,315.61L534.402,172.104L593.127,172.104L593.127,95.935L534.402,95.935L534.402,227.299L416.951,227.299L416.951,166.584L299.5,166.584L299.5,138.987L182.049,138.987L182.049,144.506L64.598,144.506L64.598,39.636L5.873,39.636Z" ]; chart.$.line.areas.each(function(d, i) { diff --git a/test/shape/area-spec.ts b/test/shape/area-spec.ts index 493df198b..86d4d7d85 100644 --- a/test/shape/area-spec.ts +++ b/test/shape/area-spec.ts @@ -168,8 +168,8 @@ describe("SHAPE AREA", () => { it("check the correct path generation", () => { checkPath({ - line: "M64.364,-33L64.364,2L64.364,2L64.364,72.5L429.091", - area: "72.5L0,72.5L0,2L0,2L0,-33Z" + line: "M64.364,-34.333L64.364,1L64.364,1L64.364,71.667L429.091,71.667", + area: "L0,142.333L0,71.667L0,71.667L0,1L0,1L0,-34.333Z" }); }); @@ -179,8 +179,8 @@ describe("SHAPE AREA", () => { it("check the correct path generation - step-before", () => { checkPath({ - line: "M64.364,-33L64.364,-33L64.364,-33L64.364,37L429.091", - area: "M64.364,-33L64.364,-33L64.364,-33L64.364,37L429.091" + line: "M64.364,-34.333L64.364,-34.333L64.364,-34.333L64.364,36.333", + area: "M64.364,-34.333L64.364,-34.333L64.364,-34.333L64.364,36.333" }); }); @@ -190,8 +190,8 @@ describe("SHAPE AREA", () => { it("check the correct path generation - step-after", () => { checkPath({ - line: "M64.364,-104L64.364,-33L64.364,-33L64.364", - area: "249L0,179L0,179L0,108L0,108L0,37L0,37L0,-33L0,-33Z" + line: "M64.364,-105L64.364,-34.333L64.364,-34.333L64.364,36.333", + area: "L0,107L0,107L0,36.333L0,36.333L0,-34.333L0,-34.333Z" }); }); }); @@ -232,12 +232,12 @@ describe("SHAPE AREA", () => { it("should be rendering correctly for category type", () => { const expectedPath = { areas: { - data1: "M-99,229.369L0.5,229.369L0.5,229.369L200,229.369L200", - data2: "M-99,39.636L0.5,39.636L0.5,39.636L200" + data1: "M-99.833,229.369L0,229.369L0,229.369L199.667,229.369", + data2: "M-99.833,39.636L0,39.636L0,39.636L199.667,39.636" }, lines: { - data1: 'M-99,229.369L0.5,229.369L0.5,229.369L200,229.369L200', - data2: 'M-99,39.636L0.5,39.636L0.5,39.636L200,39.636L200' + data1: 'M-99.833,229.369L0,229.369L0,229.369L199.667,229.369', + data2: 'M-99.833,39.636L0,39.636L0,39.636L199.667,39.636' } }; @@ -253,12 +253,12 @@ describe("SHAPE AREA", () => { it("should be rendering correctly for timeseries type", () => { const expectedPath = { areas: { - data1: "M6,229.369L300,229.369L300,284.563L594,284.563L594,426L300,426L300,426L6,426Z", - data2: "M6,39.636L300,39.636L300,94.831L594,94.831L594,284.563L300,284.563L300,229.369L6,229.369Z" + data1: "M5.873,229.369L299.5,229.369L299.5,284.563L593.127,284.563L593.127,426L299.5,426L299.5,426L5.873,426Z", + data2: "M5.873,39.636L299.5,39.636L299.5,94.831L593.127,94.831L593.127,284.563L299.5,284.563L299.5,229.369L5.873,229.369Z" }, lines: { - data1: "M6,229.369L300,229.369L300,284.563L594,284.563", - data2: "M6,39.636L300,39.636L300,94.831L594,94.831" + data1: "M5.873,229.369L299.5,229.369L299.5,284.563L593.127,284.563", + data2: "M5.873,39.636L299.5,39.636L299.5,94.831L593.127,94.831" } }; diff --git a/test/shape/bar-spec.ts b/test/shape/bar-spec.ts index d08637e3d..dba2e1717 100644 --- a/test/shape/bar-spec.ts +++ b/test/shape/bar-spec.ts @@ -210,36 +210,37 @@ describe("SHAPE BAR", () => { let i = 0; bars.each(function() { + //console.log(this.getAttribute("d")) expect(this.getAttribute("d").indexOf(expected[i++]) > -1).to.be.true; }); } it("should be stacked correctly: data.order=null", () => { const expected = [ - "M110,446V430.54636550534036", - "M110,430.54636550534036V415.09284444699557", - "M110,415.09284444699557V411.9639464549821", - "M110,411.9639464549821V401.9866088715797", - "M110,401.9866088715797V378.7295439440708", - "M110,378.7295439440708V375.8275446721525", - "M110,375.8275446721525V262.1412093566052", - "M110,262.1412093566052V243.44206206951793", - "M110,243.44206206951793V182.2324629426413", - "M110,182.2324629426413V120.4553010953897", - "M110,120.4553010953897V120.3679778202017", - "M110,120.3679778202017V119.7950019188811", - "M110,119.7950019188811V114.40702765674587", - "M110,114.40702765674587V112.23459631264922", - "M110,112.23459631264922V103.66603680162933", - "M110,103.66603680162933V96.94120535946638", - "M110,96.94120535946638V95.60679953820306", - "M110,95.60679953820306V91.80139458901215", - "M110,91.80139458901215V53.22168007962563", - "M110,53.22168007962563V48.97498177523255", - "M110,48.97498177523255V48.90533528099098", - "M110,48.90533528099098V44.5254094278709", - "M110,44.5254094278709V42.30707040714577", - "M110,42.30707040714577V41.45454545454555" + "M109.80000000000001,446V430.54636550534036", + "M109.80000000000001,430.54636550534036V415.09284444699557", + "M109.80000000000001,415.09284444699557V411.9639464549821", + "M109.80000000000001,411.9639464549821V401.9866088715797", + "M109.80000000000001,401.9866088715797V378.7295439440708", + "M109.80000000000001,378.7295439440708V375.8275446721525", + "M109.80000000000001,375.8275446721525V262.1412093566052", + "M109.80000000000001,262.1412093566052V243.44206206951793", + "M109.80000000000001,243.44206206951793V182.2324629426413", + "M109.80000000000001,182.2324629426413V120.4553010953897", + "M109.80000000000001,120.4553010953897V120.3679778202017", + "M109.80000000000001,120.3679778202017V119.7950019188811", + "M109.80000000000001,119.7950019188811V114.40702765674587", + "M109.80000000000001,114.40702765674587V112.23459631264922", + "M109.80000000000001,112.23459631264922V103.66603680162933", + "M109.80000000000001,103.66603680162933V96.94120535946638", + "M109.80000000000001,96.94120535946638V95.60679953820306", + "M109.80000000000001,95.60679953820306V91.80139458901215", + "M109.80000000000001,91.80139458901215V53.22168007962563", + "M109.80000000000001,53.22168007962563V48.97498177523255", + "M109.80000000000001,48.97498177523255V48.90533528099098", + "M109.80000000000001,48.90533528099098V44.5254094278709", + "M109.80000000000001,44.5254094278709V42.30707040714577", + "M109.80000000000001,42.30707040714577V41.45454545454555" ]; chkecPath(chart.$.bar.bars, expected); @@ -251,30 +252,30 @@ describe("SHAPE BAR", () => { it("should be stacked correctly: data.order='asc'", () => { const expected = [ - "M110,128.79097698634183V113.3373424916822", - "M110,113.3373424916822V97.8838214333374", - "M110,54.793089527912855V51.66419153589936", - "M110,97.8838214333374V87.906483849935", - "M110,170.74718920093795V147.4901242734291", - "M110,51.66419153589936V48.762192263981035", - "M110,446V332.3136646844527", - "M110,147.4901242734291V128.79097698634183", - "M110,270.5365028372011V209.32690371032447", - "M110,332.3136646844527V270.5365028372011", - "M110,41.61151522397512V41.52419194878712", - "M110,42.18449112529572V41.61151522397512", - "M110,72.61309289675216V67.22511863461693", - "M110,46.54385324325591V44.37142189915926", - "M110,87.906483849935V79.33792433891512", - "M110,79.33792433891512V72.61309289675216", - "M110,44.37142189915926V43.03701607789594", - "M110,58.59849447710377V54.793089527912855", - "M110,209.32690371032447V170.74718920093795", - "M110,62.84519278149685V58.59849447710377", - "M110,41.52419194878712V41.45454545454555", - "M110,67.22511863461693V62.84519278149685", - "M110,48.762192263981035V46.54385324325591", - "M110,43.03701607789594V42.18449112529572" + "M109.80000000000001,128.79097698634183V113.3373424916822", + "M109.80000000000001,113.3373424916822V97.8838214333374", + "M109.80000000000001,54.793089527912855V51.66419153589936", + "M109.80000000000001,97.8838214333374V87.906483849935", + "M109.80000000000001,170.74718920093795V147.4901242734291", + "M109.80000000000001,51.66419153589936V48.762192263981035", + "M109.80000000000001,446V332.3136646844527", + "M109.80000000000001,147.4901242734291V128.79097698634183", + "M109.80000000000001,270.5365028372011V209.32690371032447", + "M109.80000000000001,332.3136646844527V270.5365028372011", + "M109.80000000000001,41.61151522397512V41.52419194878712", + "M109.80000000000001,42.18449112529572V41.61151522397512", + "M109.80000000000001,72.61309289675216V67.22511863461693", + "M109.80000000000001,46.54385324325591V44.37142189915926", + "M109.80000000000001,87.906483849935V79.33792433891512", + "M109.80000000000001,79.33792433891512V72.61309289675216", + "M109.80000000000001,44.37142189915926V43.03701607789594", + "M109.80000000000001,58.59849447710377V54.793089527912855", + "M109.80000000000001,209.32690371032447V170.74718920093795", + "M109.80000000000001,62.84519278149685V58.59849447710377", + "M109.80000000000001,41.52419194878712V41.45454545454555", + "M109.80000000000001,67.22511863461693V62.84519278149685", + "M109.80000000000001,48.762192263981035V46.54385324325591", + "M109.80000000000001,43.03701607789594V42.18449112529572", ]; chkecPath(chart.$.bar.bars, expected); @@ -286,30 +287,30 @@ describe("SHAPE BAR", () => { it("should be stacked correctly: data.order='desc'", () => { const expected = [ - "M110,374.11720296286336V358.6635684682037", - "M110,389.57072402120815V374.11720296286336", - "M110,435.7903539186462V432.6614559266327", - "M110,399.54806160461055V389.57072402120815", - "M110,339.96442118111645V316.7073562536076", - "M110,438.6923531905645V435.7903539186462", - "M110,155.14088077009285V41.45454545454555", - "M110,358.6635684682037V339.96442118111645", - "M110,278.1276417442211V216.91804261734444", - "M110,216.91804261734444V155.14088077009285", - "M110,445.93035350575843V445.84303023057043", - "M110,445.84303023057043V445.27005432924983", - "M110,420.2294268199286V414.8414525577934", - "M110,443.0831235553863V440.91069221128964", - "M110,408.11662111563044V399.54806160461055", - "M110,414.8414525577934V408.11662111563044", - "M110,444.4175293766496V443.0831235553863", - "M110,432.6614559266327V428.8560509774418", - "M110,316.7073562536076V278.1276417442211", - "M110,428.8560509774418V424.6093526730487", - "M110,446V445.93035350575843", - "M110,424.6093526730487V420.2294268199286", - "M110,440.91069221128964V438.6923531905645", - "M110,445.27005432924983V444.4175293766496" + "M109.80000000000001,374.11720296286336V358.6635684682037", + "M109.80000000000001,389.57072402120815V374.11720296286336", + "M109.80000000000001,435.7903539186462V432.6614559266327", + "M109.80000000000001,399.54806160461055V389.57072402120815", + "M109.80000000000001,339.96442118111645V316.7073562536076", + "M109.80000000000001,438.6923531905645V435.7903539186462", + "M109.80000000000001,155.14088077009285V41.45454545454555", + "M109.80000000000001,358.6635684682037V339.96442118111645", + "M109.80000000000001,278.1276417442211V216.91804261734444", + "M109.80000000000001,216.91804261734444V155.14088077009285", + "M109.80000000000001,445.93035350575843V445.84303023057043", + "M109.80000000000001,445.84303023057043V445.27005432924983", + "M109.80000000000001,420.2294268199286V414.8414525577934", + "M109.80000000000001,443.0831235553863V440.91069221128964", + "M109.80000000000001,408.11662111563044V399.54806160461055", + "M109.80000000000001,414.8414525577934V408.11662111563044", + "M109.80000000000001,444.4175293766496V443.0831235553863", + "M109.80000000000001,432.6614559266327V428.8560509774418", + "M109.80000000000001,316.7073562536076V278.1276417442211", + "M109.80000000000001,428.8560509774418V424.6093526730487", + "M109.80000000000001,446V445.93035350575843", + "M109.80000000000001,424.6093526730487V420.2294268199286", + "M109.80000000000001,440.91069221128964V438.6923531905645", + "M109.80000000000001,445.27005432924983V444.4175293766496", ]; chkecPath(chart.$.bar.bars, expected); @@ -516,13 +517,13 @@ describe("SHAPE BAR", () => { it("Bars should be positioned correctly", () => { const expectedPath = [ - "M154.73095238095237,426V39.63636363636365 H159.03095238095239 V426z", - "M95.53333333333333,426V232.8181818181818 H99.83333333333333 V426z", - "M195.36666666666665,426V232.8181818181818 H199.66666666666666 V426z", - "M494.8666666666667,426V232.8181818181818 H499.1666666666667 V426z", - "M99.83333333333333,426V39.63636363636365 H104.13333333333333 V426z", - "M199.66666666666666,426V39.63636363636365 H203.96666666666667 V426z", - "M499.1666666666667,426V39.63636363636365 H503.4666666666667 V426z" + "M154.74166666666667,426V39.63636363636365 H159.0202380952381 V426z", + "M95.5547619047619,426V232.8181818181818 H99.83333333333333 V426z", + "M195.38809523809522,426V232.8181818181818 H199.66666666666666 V426z", + "M494.8880952380953,426V232.8181818181818 H499.1666666666667 V426z", + "M99.83333333333333,426V39.63636363636365 H104.11190476190475 V426z", + "M199.66666666666666,426V39.63636363636365 H203.9452380952381 V426z", + "M499.1666666666667,426V39.63636363636365 H503.4452380952381 V426z", ]; chart.$.bar.bars.each(function() { @@ -538,16 +539,16 @@ describe("SHAPE BAR", () => { it("Grouped bars should be positined correctly", () => { const expectedPath = [ - "M152.58095238095237,426V168.4242424242424 H161.18095238095236 V426z", - "M95.53333333333333,426V297.21212121212125 H104.13333333333333 V426z", - "M195.36666666666665,426V297.21212121212125 H203.96666666666664 V426z", - "M494.8666666666667,426V297.21212121212125 H503.4666666666667 V426z", - "M95.53333333333333,297.21212121212125V39.636363636363654 H104.13333333333333 V297.21212121212125z", - "M195.36666666666665,297.21212121212125V39.636363636363654 H203.96666666666664 V297.21212121212125z", - "M494.8666666666667,297.21212121212125V39.636363636363654 H503.4666666666667 V297.21212121212125z" - ]; - - chart.$.bar.bars.each(function() { + "M152.60238095238094,426V168.4242424242424 H161.1595238095238 V426z", + "M95.5547619047619,426V297.21212121212125 H104.11190476190475 V426z", + "M195.38809523809522,426V297.21212121212125 H203.94523809523807 V426z", + "M494.8880952380953,426V297.21212121212125 H503.44523809523815 V426z", + "M95.5547619047619,297.21212121212125V39.636363636363654 H104.11190476190475 V297.21212121212125z", + "M195.38809523809522,297.21212121212125V39.636363636363654 H203.94523809523807 V297.21212121212125z", + "M494.8880952380953,297.21212121212125V39.636363636363654 H503.44523809523815 V297.21212121212125z", + ]; + + chart.$.bar.bars.each(function() { expect(this.getAttribute("d")).to.be.equal(expectedPath.shift()); }); }); @@ -1670,8 +1671,9 @@ describe("SHAPE BAR", () => { }); const expectedPath = [ "M59.900000000000006,297.21212121212125V168.4242424242424 H239.6 V297.21212121212125z", - "M359.4,168.4242424242424V39.63636363636365 H539.0999999999999 V168.4242424242424z" + "M359.4,168.4242424242424V39.63636363636365 H539.0999999999999 V168.4242424242424z", ]; + chart.$.bar.bars.each(function(d, i) { expect(this.getAttribute("d")).to.be.equal(expectedPath[i]); }); @@ -1716,15 +1718,16 @@ describe("SHAPE BAR", () => { } }); const expectedPathMap = { - data1: [ - "M59.05,213.5V124.95833333333331 H147.25 V213.5z", - "M353.55,124.95833333333331V36.41666666666668 H441.75 V124.95833333333331z" + "data1": [ + "M58.900000000000006,213.5V124.95833333333331 H147.25 V213.5z", + "M353.4,124.95833333333331V36.41666666666668 H441.75 V124.95833333333331z", ], - data2: [ - "M147.25,390.5833333333333V213.5 H235.45 V390.5833333333333z", - "M441.75,346.3125V328.6041666666667 H529.95 V346.3125z" + "data2": [ + "M147.25,390.5833333333333V213.5 H235.6 V390.5833333333333z", + "M441.75,346.3125V328.6041666666667 H530.1 V346.3125z", ], - }; + }; + chart.$.bar.bars.each(function(d, i) { expect(this.getAttribute("d")).to.be.equal(expectedPathMap[d.id][i]); }); @@ -1741,19 +1744,20 @@ describe("SHAPE BAR", () => { } }); const expectedPathMap = { - data1: [ - "M29.525,302.04166666666663V213.5 H73.625 V302.04166666666663z", - "M176.775,302.04166666666663V124.95833333333331 H220.875 V302.04166666666663z", - "M324.025,213.5V124.95833333333331 H368.125 V213.5z", - "M471.275,124.95833333333331V36.41666666666668 H515.375 V124.95833333333331z" + "data1": [ + "M29.450000000000003,302.04166666666663V213.5 H73.625 V302.04166666666663z", + "M176.7,302.04166666666663V124.95833333333331 H220.875 V302.04166666666663z", + "M323.95,213.5V124.95833333333331 H368.125 V213.5z", + "M471.2,124.95833333333331V36.41666666666668 H515.375 V124.95833333333331z", ], - data2: [ - "M73.625,302.04166666666663V390.5833333333333 H117.725 V302.04166666666663z", - "M220.875,302.04166666666663V346.3125 H264.975 V302.04166666666663z", - "M368.125,390.5833333333333V213.5 H412.225 V390.5833333333333z", - "M515.375,346.3125V328.6041666666667 H559.475 V346.3125z" + "data2": [ + "M73.625,302.04166666666663V390.5833333333333 H117.8 V302.04166666666663z", + "M220.875,302.04166666666663V346.3125 H265.05 V302.04166666666663z", + "M368.125,390.5833333333333V213.5 H412.3 V390.5833333333333z", + "M515.375,346.3125V328.6041666666667 H559.55 V346.3125z", ], }; + chart.$.bar.bars.each(function(d, i) { expect(this.getAttribute("d")).to.be.equal(expectedPathMap[d.id][i]); }); @@ -1771,19 +1775,20 @@ describe("SHAPE BAR", () => { } }); const expectedPathMap = { - data1: [ - "M29.525,302.04166666666663V213.5 H117.725 V302.04166666666663z", - "M176.775,302.04166666666663V124.95833333333331 H264.975 V302.04166666666663z", - "M324.025,213.5V124.95833333333331 H412.22499999999997 V213.5z", - "M471.275,124.95833333333331V36.41666666666668 H559.475 V124.95833333333331z" - ], - data2: [ - "M29.525,302.04166666666663V390.5833333333333 H117.725 V302.04166666666663z", - "M176.775,302.04166666666663V346.3125 H264.975 V302.04166666666663z", - "M324.025,390.5833333333333V257.77083333333337 H412.22499999999997 V390.5833333333333z", - "M471.275,346.3125V328.6041666666667 H559.475 V346.3125z" - ], + "data1": [ + "M29.450000000000003,302.04166666666663V213.5 H117.8 V302.04166666666663z", + "M176.7,302.04166666666663V124.95833333333331 H265.04999999999995 V302.04166666666663z", + "M323.95,213.5V124.95833333333331 H412.29999999999995 V213.5z", + "M471.2,124.95833333333331V36.41666666666668 H559.55 V124.95833333333331z", + ], + "data2": [ + "M29.450000000000003,302.04166666666663V390.5833333333333 H117.8 V302.04166666666663z", + "M176.7,302.04166666666663V346.3125 H265.04999999999995 V302.04166666666663z", + "M323.95,390.5833333333333V257.77083333333337 H412.29999999999995 V390.5833333333333z", + "M471.2,346.3125V328.6041666666667 H559.55 V346.3125z", + ], }; + chart.$.bar.bars.each(function(d, i) { expect(this.getAttribute("d")).to.be.equal(expectedPathMap[d.id][i]); }); diff --git a/test/shape/bubble-spec.ts b/test/shape/bubble-spec.ts index d9a73e46e..4087d4d56 100644 --- a/test/shape/bubble-spec.ts +++ b/test/shape/bubble-spec.ts @@ -146,7 +146,7 @@ describe("SHAPE BUBBLE", () => { chart = util.generate(args); const tickNodes = chart.$.svg.select(`.${$AXIS.axisY}`).selectAll("g.tick"); - const translateValues = [390, 345, 300, 255, 209, 164, 119, 74, 29]; + const translateValues = [389, 344, 299, 254, 209, 164, 119, 74, 29]; tickNodes.each(function(d, i) { expect(util.parseNum(this.getAttribute("transform"))).to.be.closeTo(translateValues[i], 1); diff --git a/test/shape/candlestick-spec.ts b/test/shape/candlestick-spec.ts index e0a525de4..f534cee6a 100644 --- a/test/shape/candlestick-spec.ts +++ b/test/shape/candlestick-spec.ts @@ -47,8 +47,8 @@ describe("SHAPE CANDLESTICK", () => { it("check for basic rendering", () => { const expectedPath = [ - /^M60,217\.\d+V33\d\.\d+ H240 V217\.\d+z$/, - /^M359\.5,33\d\.\d+V132\.\d+ H539\.5 V33\d\.\d+z$/ + /^M59\.\d+,217\.\d+V33\d\.\d+ H239\.\d+ V217\.\d+z$/, + /^M359\.4,33\d\.\d+V132\.\d+ H539\.\d+/ ]; const expectedLinePos = [ @@ -255,7 +255,7 @@ describe("SHAPE CANDLESTICK", () => { data1: { path: { 0: /^M97\.\d+,217\.\d+V33[67]\.\d+ H149\.\d+ V217\.\d+z$/, - 1: /^M247,33[67]\.\d+V132\.\d+ H299\.5 V33[67]\.\d+z/ + 1: /^M247\.\d+,33[67]\.\d+V132\.\d+ H299\.5 V33[67]\.\d+z/ }, line: { 0: { @@ -270,8 +270,8 @@ describe("SHAPE CANDLESTICK", () => { }, data2: { path: { - 0: /^M149.75,202\.\d+V9[45]\.\d+ H202.25 V202\.\d+z$/, - 2: /^M449.25,217\.\d+V33[67]\.\d+ H501.75 V217\.\d+z$/ + 0: /^M149.75,202\.\d+V9[45]\.\d+ H202\.\d+ V202\.\d+z$/, + 2: /^M449.25,217\.\d+V33[67]\.\d+ H501\.\d+ V217\.\d+z$/ }, line: { 0: { @@ -316,8 +316,8 @@ describe("SHAPE CANDLESTICK", () => { }); const expectedLine = { - data3: /^M150,8\d\.\d+L300,217\.\d+L450,26[89]\.\d+$/, - data4: /^M150,8\d\.\d+L225,8\d\.\d+L225,21\d\.\d+L37\d,21\d\.\d+L37\d,26\d\.\d+L45\d,26[89]\.\d+$/ + data3: /^M149.75,8[01]\.\d+L299.5,217\.\d+/, + data4: /^M149.75,8[01]\.\d+L224/ }; chart.$.line.lines.each(function(d, i) { diff --git a/test/shape/line-spec.ts b/test/shape/line-spec.ts index f827c6755..63c4d125f 100644 --- a/test/shape/line-spec.ts +++ b/test/shape/line-spec.ts @@ -312,8 +312,8 @@ describe("SHAPE LINE", () => { it("should be generated correctly", () => { const path = { - column1: "M-41,202.432L1,202.432L1,202.432L127.5,202.432L127.5,202.432L254,202.432L254,191.365L422,191.365L422,351.846L590,351.846L590,351.846L632,351.846", - column2: "M-41,36.417L1,36.417L1,36.417L127.5,36.417L127.5,147.094L254,147.094L254,136.026L380,136.026L380,124.958L506,124.958L506,390.583L590,390.583L590,390.583L632,390.583" + column1: "M-42.071,202.432L0,202.432L0,202.432L126.214,202.432L126.214,202.432L252.429,202.432L252.429,191.365L420.714,191.365L420.714,351.846L589,351.846L589,351.846L631.071,351.846", + column2: "M-42.071,36.417L0,36.417L0,36.417L126.214,36.417L126.214,147.094L252.429,147.094L252.429,136.026L378.643,136.026L378.643,124.958L504.857,124.958L504.857,390.583L589,390.583L589,390.583L631.071,390.583" } chart.$.line.lines.each(function(d) { @@ -323,6 +323,8 @@ describe("SHAPE LINE", () => { }); describe("line options", () => { + const rx = /,([^)]+)\)/; + beforeAll(() => { args = { data: { @@ -369,19 +371,13 @@ describe("SHAPE LINE", () => { const tickElements = tickNodes.nodes(); const translateValues = [ - "translate(0,391)", - "translate(0,347)", - "translate(0,303)", - "translate(0,258)", - "translate(0,214)", - "translate(0,170)", - "translate(0,125)", - "translate(0,81)", - "translate(0,37)" + 391, 347, 303, 258, 214, 170, 125, 81, 37 ]; tickNodes.each((data, index) => { - expect(d3Select(tickElements[index]).attr("transform")).to.be.equal(translateValues[index]); + const transform = tickElements[index].getAttribute("transform"); + + expect(+transform.match(rx)[1]).to.be.closeTo(translateValues[index], 1); }); }); @@ -393,19 +389,13 @@ describe("SHAPE LINE", () => { const tickElements = tickNodes.nodes(); const translateValues = [ - "translate(0,426)", - "translate(0,378)", - "translate(0,330)", - "translate(0,282)", - "translate(0,233)", - "translate(0,185)", - "translate(0,137)", - "translate(0,88)", - "translate(0,40)" + 426, 378, 330, 282, 233, 185, 137, 88, 40 ]; - tickNodes.each((d, index) => { - expect(d3Select(tickElements[index]).attr("transform")).to.be.equal(translateValues[index]); + tickNodes.each((data, index) => { + const transform = tickElements[index].getAttribute("transform"); + + expect(+transform.match(rx)[1]).to.be.closeTo(translateValues[index], 1); }); }); }); diff --git a/test/shape/point-spec.ts b/test/shape/point-spec.ts index 2dc174628..eb8b1dbfc 100644 --- a/test/shape/point-spec.ts +++ b/test/shape/point-spec.ts @@ -374,7 +374,7 @@ describe("SHAPE POINT", () => { setTimeout(resolve, 300); }).then(() => { return new Promise((resolve, reject) => { - checkHover($el, values, 1, 5); + checkHover($el, values, 1, 3); setTimeout(resolve, 300); });