From 4b4f7c1f7a57b64cce247040b4aaf08d9109c538 Mon Sep 17 00:00:00 2001 From: manyyuri <327035324@qq.com> Date: Mon, 27 May 2024 21:29:40 +0800 Subject: [PATCH] feat: view --- .eslintcache | 2 +- __tests__/view/view.spec.js | 186 ++++++++++++++++++++++++++++++++++++ src/view/facet.js | 34 +++++++ src/view/flex.js | 23 +++++ src/view/index.js | 1 + src/view/layer.js | 4 + src/view/view.js | 48 ++++++++++ 7 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 __tests__/view/view.spec.js create mode 100644 src/view/facet.js create mode 100644 src/view/flex.js create mode 100644 src/view/index.js create mode 100644 src/view/layer.js create mode 100644 src/view/view.js diff --git a/.eslintcache b/.eslintcache index 44207de..7f2d620 100644 --- a/.eslintcache +++ b/.eslintcache @@ -1 +1 @@ -[{"/Users/junyingli/techLearn/sparrow/.eslintrc.js":"1","/Users/junyingli/techLearn/sparrow/__tests__/index.spec.js":"2","/Users/junyingli/techLearn/sparrow/__tests__/utils.js":"3","/Users/junyingli/techLearn/sparrow/commitlint.config.js":"4","/Users/junyingli/techLearn/sparrow/jest.config.js":"5","/Users/junyingli/techLearn/sparrow/rollup.config.js":"6","/Users/junyingli/techLearn/sparrow/__tests__/renderer/renderer.spec.js":"7","/Users/junyingli/techLearn/sparrow/__tests__/renderer/shape.spec.js":"8","/Users/junyingli/techLearn/sparrow/__tests__/renderer/transform.spec.js":"9","/Users/junyingli/techLearn/sparrow/src/renderer/context.js":"10","/Users/junyingli/techLearn/sparrow/src/renderer/index.js":"11","/Users/junyingli/techLearn/sparrow/src/renderer/renderer.js":"12","/Users/junyingli/techLearn/sparrow/src/renderer/shape.js":"13","/Users/junyingli/techLearn/sparrow/src/renderer/transform.js":"14","/Users/junyingli/techLearn/sparrow/src/renderer/utils.js":"15","/Users/junyingli/techLearn/sparrow/src/scale/identity.js":"16","/Users/junyingli/techLearn/sparrow/src/scale/linear.js":"17","/Users/junyingli/techLearn/sparrow/src/scale/utils.js":"18","/Users/junyingli/techLearn/sparrow/src/scale/time.js":"19","/Users/junyingli/techLearn/sparrow/__tests__/scale/band.spec.js":"20","/Users/junyingli/techLearn/sparrow/__tests__/scale/identity.spec.js":"21","/Users/junyingli/techLearn/sparrow/__tests__/scale/linear.spec.js":"22","/Users/junyingli/techLearn/sparrow/__tests__/scale/log.spec.js":"23","/Users/junyingli/techLearn/sparrow/__tests__/scale/ordinal.spec.js":"24","/Users/junyingli/techLearn/sparrow/__tests__/scale/point.spec.js":"25","/Users/junyingli/techLearn/sparrow/__tests__/scale/quantile.spec.js":"26","/Users/junyingli/techLearn/sparrow/__tests__/scale/quantize.spec.js":"27","/Users/junyingli/techLearn/sparrow/__tests__/scale/threshold.spec.js":"28","/Users/junyingli/techLearn/sparrow/__tests__/scale/time.spec.js":"29","/Users/junyingli/techLearn/sparrow/src/scale/band.js":"30","/Users/junyingli/techLearn/sparrow/src/scale/index.js":"31","/Users/junyingli/techLearn/sparrow/src/scale/log.js":"32","/Users/junyingli/techLearn/sparrow/src/scale/ordinal.js":"33","/Users/junyingli/techLearn/sparrow/src/scale/point.js":"34","/Users/junyingli/techLearn/sparrow/src/scale/quantile.js":"35","/Users/junyingli/techLearn/sparrow/src/scale/quantize.js":"36","/Users/junyingli/techLearn/sparrow/src/scale/threshold.js":"37","/Users/junyingli/techLearn/sparrow/__tests__/coordinate/cartesian.spec.js":"38","/Users/junyingli/techLearn/sparrow/__tests__/coordinate/coordinate.spec.js":"39","/Users/junyingli/techLearn/sparrow/__tests__/coordinate/polar.spec.js":"40","/Users/junyingli/techLearn/sparrow/__tests__/coordinate/transpose.spec.js":"41","/Users/junyingli/techLearn/sparrow/src/coordinate/cartesian.js":"42","/Users/junyingli/techLearn/sparrow/src/coordinate/coordinate.js":"43","/Users/junyingli/techLearn/sparrow/src/coordinate/index.js":"44","/Users/junyingli/techLearn/sparrow/src/coordinate/polar.js":"45","/Users/junyingli/techLearn/sparrow/src/coordinate/transform.js":"46","/Users/junyingli/techLearn/sparrow/src/coordinate/transpose.js":"47","/Users/junyingli/techLearn/sparrow/src/utils/helper.js":"48","/Users/junyingli/techLearn/sparrow/src/utils/index.js":"49","/Users/junyingli/techLearn/sparrow/__tests__/geometry/area.spec.js":"50","/Users/junyingli/techLearn/sparrow/__tests__/geometry/cell.spec.js":"51","/Users/junyingli/techLearn/sparrow/__tests__/geometry/geometry.spec.js":"52","/Users/junyingli/techLearn/sparrow/__tests__/geometry/interval.spec.js":"53","/Users/junyingli/techLearn/sparrow/__tests__/geometry/line.spec.js":"54","/Users/junyingli/techLearn/sparrow/__tests__/geometry/link.spec.js":"55","/Users/junyingli/techLearn/sparrow/__tests__/geometry/path.spec.js":"56","/Users/junyingli/techLearn/sparrow/__tests__/geometry/point.spec.js":"57","/Users/junyingli/techLearn/sparrow/__tests__/geometry/rect.spec.js":"58","/Users/junyingli/techLearn/sparrow/__tests__/geometry/text.spec.js":"59","/Users/junyingli/techLearn/sparrow/__tests__/geometry/utils.js":"60","/Users/junyingli/techLearn/sparrow/src/geometry/area.js":"61","/Users/junyingli/techLearn/sparrow/src/geometry/cell.js":"62","/Users/junyingli/techLearn/sparrow/src/geometry/channel.js":"63","/Users/junyingli/techLearn/sparrow/src/geometry/d.js":"64","/Users/junyingli/techLearn/sparrow/src/geometry/geometry.js":"65","/Users/junyingli/techLearn/sparrow/src/geometry/index.js":"66","/Users/junyingli/techLearn/sparrow/src/geometry/interval.js":"67","/Users/junyingli/techLearn/sparrow/src/geometry/line.js":"68","/Users/junyingli/techLearn/sparrow/src/geometry/link.js":"69","/Users/junyingli/techLearn/sparrow/src/geometry/path.js":"70","/Users/junyingli/techLearn/sparrow/src/geometry/point.js":"71","/Users/junyingli/techLearn/sparrow/src/geometry/primitive.js":"72","/Users/junyingli/techLearn/sparrow/src/geometry/rect.js":"73","/Users/junyingli/techLearn/sparrow/src/geometry/shape.js":"74","/Users/junyingli/techLearn/sparrow/src/geometry/style.js":"75","/Users/junyingli/techLearn/sparrow/src/geometry/text.js":"76","/Users/junyingli/techLearn/sparrow/src/utils/array.js":"77","/Users/junyingli/techLearn/sparrow/src/utils/dom.js":"78","/Users/junyingli/techLearn/sparrow/src/utils/tree.js":"79","/Users/junyingli/techLearn/sparrow/src/utils/vector.js":"80","/Users/junyingli/techLearn/sparrow/__tests__/guide/axisX.spec.js":"81","/Users/junyingli/techLearn/sparrow/__tests__/guide/axisY.spec.js":"82","/Users/junyingli/techLearn/sparrow/__tests__/guide/legend.spec.js":"83","/Users/junyingli/techLearn/sparrow/__tests__/guide/utils.js":"84","/Users/junyingli/techLearn/sparrow/src/guide/axis.js":"85","/Users/junyingli/techLearn/sparrow/src/guide/axisX.js":"86","/Users/junyingli/techLearn/sparrow/src/guide/axisY.js":"87","/Users/junyingli/techLearn/sparrow/src/guide/grid.js":"88","/Users/junyingli/techLearn/sparrow/src/guide/index.js":"89","/Users/junyingli/techLearn/sparrow/src/guide/label.js":"90","/Users/junyingli/techLearn/sparrow/src/guide/legendRamp.js":"91","/Users/junyingli/techLearn/sparrow/src/guide/legendSwatches.js":"92","/Users/junyingli/techLearn/sparrow/src/guide/ticks.js":"93","/Users/junyingli/techLearn/sparrow/src/scale/interpolate.js":"94"},{"size":553,"mtime":1716280044680,"results":"95","hashOfConfig":"96"},{"size":435,"mtime":1714801594557,"results":"97","hashOfConfig":"98"},{"size":414,"mtime":1714808881749,"results":"99","hashOfConfig":"100"},{"size":67,"mtime":1714800551268,"results":"101","hashOfConfig":"98"},{"size":241,"mtime":1714801594557,"results":"102","hashOfConfig":"98"},{"size":586,"mtime":1714801594557,"results":"103","hashOfConfig":"98"},{"size":656,"mtime":1714808881749,"results":"104","hashOfConfig":"100"},{"size":4250,"mtime":1714808881749,"results":"105","hashOfConfig":"100"},{"size":843,"mtime":1714808881749,"results":"106","hashOfConfig":"100"},{"size":533,"mtime":1714808881749,"results":"107","hashOfConfig":"100"},{"size":45,"mtime":1714808881749,"results":"108","hashOfConfig":"100"},{"size":913,"mtime":1714808881749,"results":"109","hashOfConfig":"100"},{"size":2272,"mtime":1716801932298,"results":"110","hashOfConfig":"100"},{"size":825,"mtime":1714808881750,"results":"111","hashOfConfig":"100"},{"size":1166,"mtime":1714808881750,"results":"112","hashOfConfig":"100"},{"size":56,"mtime":1714809449088,"results":"113","hashOfConfig":"100"},{"size":666,"mtime":1716813536659},{"size":2077,"mtime":1714912087516,"results":"114","hashOfConfig":"100"},{"size":452,"mtime":1714912055104,"results":"115","hashOfConfig":"100"},{"size":444,"mtime":1714912055102,"results":"116","hashOfConfig":"100"},{"size":343,"mtime":1714912055102,"results":"117","hashOfConfig":"100"},{"size":2372,"mtime":1714912055102,"results":"118","hashOfConfig":"100"},{"size":1239,"mtime":1714912055102,"results":"119","hashOfConfig":"100"},{"size":612,"mtime":1714912055102,"results":"120","hashOfConfig":"100"},{"size":436,"mtime":1714912055102,"results":"121","hashOfConfig":"100"},{"size":574,"mtime":1714912055103,"results":"122","hashOfConfig":"100"},{"size":479,"mtime":1714912055103,"results":"123","hashOfConfig":"100"},{"size":492,"mtime":1714912055103,"results":"124","hashOfConfig":"100"},{"size":426,"mtime":1714912055103,"results":"125","hashOfConfig":"100"},{"size":319,"mtime":1714912055103},{"size":483,"mtime":1716810659316,"results":"126","hashOfConfig":"96"},{"size":729,"mtime":1714912055103},{"size":249,"mtime":1716811312280,"results":"127","hashOfConfig":"96"},{"size":128,"mtime":1714912055103},{"size":582,"mtime":1714912055104},{"size":334,"mtime":1714912055104},{"size":307,"mtime":1714912055104},{"size":402,"mtime":1716280005672,"results":"128","hashOfConfig":"96"},{"size":309,"mtime":1716280005672,"results":"129","hashOfConfig":"96"},{"size":928,"mtime":1716280005673,"results":"130","hashOfConfig":"96"},{"size":467,"mtime":1716280005673,"results":"131","hashOfConfig":"96"},{"size":297,"mtime":1716280005673},{"size":586,"mtime":1716280005673,"results":"132","hashOfConfig":"96"},{"size":164,"mtime":1716280005673,"results":"133","hashOfConfig":"96"},{"size":770,"mtime":1716280005673},{"size":825,"mtime":1716280005673,"results":"134","hashOfConfig":"96"},{"size":358,"mtime":1716280005673,"results":"135","hashOfConfig":"96"},{"size":1416,"mtime":1716799386916,"results":"136","hashOfConfig":"96"},{"size":124,"mtime":1716799386916,"results":"137","hashOfConfig":"96"},{"size":5541,"mtime":1716798485609},{"size":2165,"mtime":1716798485610},{"size":749,"mtime":1716798485610,"results":"138","hashOfConfig":"96"},{"size":6174,"mtime":1716798485611},{"size":2458,"mtime":1716798485611},{"size":1005,"mtime":1716798485612,"results":"139","hashOfConfig":"96"},{"size":915,"mtime":1716801825288,"results":"140","hashOfConfig":"96"},{"size":2290,"mtime":1716798485612},{"size":1695,"mtime":1716798485612},{"size":1342,"mtime":1716798485613,"results":"141","hashOfConfig":"96"},{"size":1055,"mtime":1716798485613,"results":"142","hashOfConfig":"96"},{"size":884,"mtime":1716798472631},{"size":837,"mtime":1716798472632,"results":"143","hashOfConfig":"96"},{"size":394,"mtime":1716798472633,"results":"144","hashOfConfig":"96"},{"size":890,"mtime":1716798472633,"results":"145","hashOfConfig":"96"},{"size":588,"mtime":1716798472633,"results":"146","hashOfConfig":"96"},{"size":289,"mtime":1716798472633,"results":"147","hashOfConfig":"96"},{"size":1161,"mtime":1716798472634},{"size":746,"mtime":1716798472634,"results":"148","hashOfConfig":"96"},{"size":740,"mtime":1716798472634},{"size":690,"mtime":1716799470321,"results":"149","hashOfConfig":"96"},{"size":768,"mtime":1716798472635,"results":"150","hashOfConfig":"96"},{"size":897,"mtime":1716798472635},{"size":740,"mtime":1716798472635},{"size":2429,"mtime":1716798472635},{"size":280,"mtime":1716798472636,"results":"151","hashOfConfig":"96"},{"size":1059,"mtime":1716798472636},{"size":2414,"mtime":1716799386915,"results":"152","hashOfConfig":"96"},{"size":698,"mtime":1716799386915,"results":"153","hashOfConfig":"96"},{"size":336,"mtime":1716799386916,"results":"154","hashOfConfig":"96"},{"size":897,"mtime":1716799386916,"results":"155","hashOfConfig":"96"},{"size":2879,"mtime":1716810499691},{"size":2833,"mtime":1716810499692},{"size":1863,"mtime":1716813649417,"results":"156","hashOfConfig":"96"},{"size":1027,"mtime":1716810499693},{"size":1406,"mtime":1716810485906},{"size":1018,"mtime":1716810485907},{"size":1002,"mtime":1716810485908},{"size":844,"mtime":1716810485908},{"size":160,"mtime":1716810485908,"results":"157","hashOfConfig":"96"},{"size":1027,"mtime":1716810485909},{"size":1262,"mtime":1716810485909},{"size":930,"mtime":1716810485910},{"size":2154,"mtime":1716810485910},{"size":720,"mtime":1716814226867,"results":"158","hashOfConfig":"96"},{"filePath":"159","messages":"160","suppressedMessages":"161","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1jm62pz",{"filePath":"162","messages":"163","suppressedMessages":"164","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1hkiy78",{"filePath":"165","messages":"166","suppressedMessages":"167","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1l8n0xm",{"filePath":"168","messages":"169","suppressedMessages":"170","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"171","messages":"172","suppressedMessages":"173","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"174","messages":"175","suppressedMessages":"176","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"177","messages":"178","suppressedMessages":"179","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"180","messages":"181","suppressedMessages":"182","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"183","messages":"184","suppressedMessages":"185","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"186","messages":"187","suppressedMessages":"188","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"189","messages":"190","suppressedMessages":"191","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"192","messages":"193","suppressedMessages":"194","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"195","messages":"196","suppressedMessages":"197","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"198","messages":"199","suppressedMessages":"200","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"201","messages":"202","suppressedMessages":"203","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"204","messages":"205","suppressedMessages":"206","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"207","messages":"208","suppressedMessages":"209","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"210","messages":"211","suppressedMessages":"212","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"213","messages":"214","suppressedMessages":"215","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"216","messages":"217","suppressedMessages":"218","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"219","messages":"220","suppressedMessages":"221","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"222","messages":"223","suppressedMessages":"224","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"225","messages":"226","suppressedMessages":"227","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"228","messages":"229","suppressedMessages":"230","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"231","messages":"232","suppressedMessages":"233","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"234","messages":"235","suppressedMessages":"236","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"237","messages":"238","suppressedMessages":"239","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"240","messages":"241","suppressedMessages":"242","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"243","messages":"244","suppressedMessages":"245","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"246","messages":"247","suppressedMessages":"248","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"249","messages":"250","suppressedMessages":"251","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"252","messages":"253","suppressedMessages":"254","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"255","messages":"256","suppressedMessages":"257","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"258","messages":"259","suppressedMessages":"260","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"261","messages":"262","suppressedMessages":"263","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"264","messages":"265","suppressedMessages":"266","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"267","messages":"268","suppressedMessages":"269","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"270","messages":"271","suppressedMessages":"272","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"273","messages":"274","suppressedMessages":"275","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"276","messages":"277","suppressedMessages":"278","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"279","messages":"280","suppressedMessages":"281","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"282","messages":"283","suppressedMessages":"284","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"285","messages":"286","suppressedMessages":"287","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"288","messages":"289","suppressedMessages":"290","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"291","messages":"292","suppressedMessages":"293","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"294","messages":"295","suppressedMessages":"296","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"297","messages":"298","suppressedMessages":"299","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"300","messages":"301","suppressedMessages":"302","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"303","messages":"304","suppressedMessages":"305","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"306","messages":"307","suppressedMessages":"308","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"309","messages":"310","suppressedMessages":"311","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"312","messages":"313","suppressedMessages":"314","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"315","messages":"316","suppressedMessages":"317","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"318","messages":"319","suppressedMessages":"320","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"321","messages":"322","suppressedMessages":"323","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"324","messages":"325","suppressedMessages":"326","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"327","messages":"328","suppressedMessages":"329","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"330","messages":"331","suppressedMessages":"332","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"333","messages":"334","suppressedMessages":"335","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"336","messages":"337","suppressedMessages":"338","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"339","messages":"340","suppressedMessages":"341","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/junyingli/techLearn/sparrow/.eslintrc.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/index.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/utils.js",[],[],"/Users/junyingli/techLearn/sparrow/commitlint.config.js",[],[],"/Users/junyingli/techLearn/sparrow/jest.config.js",[],[],"/Users/junyingli/techLearn/sparrow/rollup.config.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/renderer/renderer.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/renderer/shape.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/renderer/transform.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/context.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/renderer.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/shape.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/transform.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/utils.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/identity.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/utils.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/time.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/band.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/identity.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/linear.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/log.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/ordinal.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/point.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/quantile.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/quantize.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/threshold.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/time.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/ordinal.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/coordinate/cartesian.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/coordinate/coordinate.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/coordinate/polar.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/coordinate/transpose.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/coordinate/coordinate.js",[],[],"/Users/junyingli/techLearn/sparrow/src/coordinate/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/coordinate/transform.js",[],[],"/Users/junyingli/techLearn/sparrow/src/coordinate/transpose.js",[],["342","343"],"/Users/junyingli/techLearn/sparrow/src/utils/helper.js",[],[],"/Users/junyingli/techLearn/sparrow/src/utils/index.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/geometry.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/link.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/path.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/text.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/utils.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/cell.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/channel.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/d.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/geometry.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/line.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/path.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/point.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/style.js",[],[],"/Users/junyingli/techLearn/sparrow/src/utils/array.js",[],["344"],"/Users/junyingli/techLearn/sparrow/src/utils/dom.js",[],[],"/Users/junyingli/techLearn/sparrow/src/utils/tree.js",[],[],"/Users/junyingli/techLearn/sparrow/src/utils/vector.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/guide/legend.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/guide/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/interpolate.js",[],[],{"ruleId":"345","severity":2,"message":"346","line":5,"column":21,"nodeType":"347","messageId":"348","endLine":5,"endColumn":37,"suppressions":"349"},{"ruleId":"345","severity":2,"message":"350","line":5,"column":39,"nodeType":"347","messageId":"348","endLine":5,"endColumn":52,"suppressions":"351"},{"ruleId":"345","severity":2,"message":"352","line":93,"column":30,"nodeType":"347","messageId":"348","endLine":93,"endColumn":38,"suppressions":"353"},"no-unused-vars","'transformOptions' is defined but never used.","Identifier","unusedVar",["354"],"'canvasOptions' is defined but never used.",["355"],"'accessor' is assigned a value but never used.",["356"],{"kind":"357","justification":"358"},{"kind":"357","justification":"358"},{"kind":"357","justification":"358"},"directive",""] \ No newline at end of file +[{"/Users/junyingli/techLearn/sparrow/.eslintrc.js":"1","/Users/junyingli/techLearn/sparrow/__tests__/index.spec.js":"2","/Users/junyingli/techLearn/sparrow/__tests__/utils.js":"3","/Users/junyingli/techLearn/sparrow/commitlint.config.js":"4","/Users/junyingli/techLearn/sparrow/jest.config.js":"5","/Users/junyingli/techLearn/sparrow/rollup.config.js":"6","/Users/junyingli/techLearn/sparrow/__tests__/renderer/renderer.spec.js":"7","/Users/junyingli/techLearn/sparrow/__tests__/renderer/shape.spec.js":"8","/Users/junyingli/techLearn/sparrow/__tests__/renderer/transform.spec.js":"9","/Users/junyingli/techLearn/sparrow/src/renderer/context.js":"10","/Users/junyingli/techLearn/sparrow/src/renderer/index.js":"11","/Users/junyingli/techLearn/sparrow/src/renderer/renderer.js":"12","/Users/junyingli/techLearn/sparrow/src/renderer/shape.js":"13","/Users/junyingli/techLearn/sparrow/src/renderer/transform.js":"14","/Users/junyingli/techLearn/sparrow/src/renderer/utils.js":"15","/Users/junyingli/techLearn/sparrow/src/scale/identity.js":"16","/Users/junyingli/techLearn/sparrow/src/scale/linear.js":"17","/Users/junyingli/techLearn/sparrow/src/scale/utils.js":"18","/Users/junyingli/techLearn/sparrow/src/scale/time.js":"19","/Users/junyingli/techLearn/sparrow/__tests__/scale/band.spec.js":"20","/Users/junyingli/techLearn/sparrow/__tests__/scale/identity.spec.js":"21","/Users/junyingli/techLearn/sparrow/__tests__/scale/linear.spec.js":"22","/Users/junyingli/techLearn/sparrow/__tests__/scale/log.spec.js":"23","/Users/junyingli/techLearn/sparrow/__tests__/scale/ordinal.spec.js":"24","/Users/junyingli/techLearn/sparrow/__tests__/scale/point.spec.js":"25","/Users/junyingli/techLearn/sparrow/__tests__/scale/quantile.spec.js":"26","/Users/junyingli/techLearn/sparrow/__tests__/scale/quantize.spec.js":"27","/Users/junyingli/techLearn/sparrow/__tests__/scale/threshold.spec.js":"28","/Users/junyingli/techLearn/sparrow/__tests__/scale/time.spec.js":"29","/Users/junyingli/techLearn/sparrow/src/scale/band.js":"30","/Users/junyingli/techLearn/sparrow/src/scale/index.js":"31","/Users/junyingli/techLearn/sparrow/src/scale/log.js":"32","/Users/junyingli/techLearn/sparrow/src/scale/ordinal.js":"33","/Users/junyingli/techLearn/sparrow/src/scale/point.js":"34","/Users/junyingli/techLearn/sparrow/src/scale/quantile.js":"35","/Users/junyingli/techLearn/sparrow/src/scale/quantize.js":"36","/Users/junyingli/techLearn/sparrow/src/scale/threshold.js":"37","/Users/junyingli/techLearn/sparrow/__tests__/coordinate/cartesian.spec.js":"38","/Users/junyingli/techLearn/sparrow/__tests__/coordinate/coordinate.spec.js":"39","/Users/junyingli/techLearn/sparrow/__tests__/coordinate/polar.spec.js":"40","/Users/junyingli/techLearn/sparrow/__tests__/coordinate/transpose.spec.js":"41","/Users/junyingli/techLearn/sparrow/src/coordinate/cartesian.js":"42","/Users/junyingli/techLearn/sparrow/src/coordinate/coordinate.js":"43","/Users/junyingli/techLearn/sparrow/src/coordinate/index.js":"44","/Users/junyingli/techLearn/sparrow/src/coordinate/polar.js":"45","/Users/junyingli/techLearn/sparrow/src/coordinate/transform.js":"46","/Users/junyingli/techLearn/sparrow/src/coordinate/transpose.js":"47","/Users/junyingli/techLearn/sparrow/src/utils/helper.js":"48","/Users/junyingli/techLearn/sparrow/src/utils/index.js":"49","/Users/junyingli/techLearn/sparrow/__tests__/geometry/area.spec.js":"50","/Users/junyingli/techLearn/sparrow/__tests__/geometry/cell.spec.js":"51","/Users/junyingli/techLearn/sparrow/__tests__/geometry/geometry.spec.js":"52","/Users/junyingli/techLearn/sparrow/__tests__/geometry/interval.spec.js":"53","/Users/junyingli/techLearn/sparrow/__tests__/geometry/line.spec.js":"54","/Users/junyingli/techLearn/sparrow/__tests__/geometry/link.spec.js":"55","/Users/junyingli/techLearn/sparrow/__tests__/geometry/path.spec.js":"56","/Users/junyingli/techLearn/sparrow/__tests__/geometry/point.spec.js":"57","/Users/junyingli/techLearn/sparrow/__tests__/geometry/rect.spec.js":"58","/Users/junyingli/techLearn/sparrow/__tests__/geometry/text.spec.js":"59","/Users/junyingli/techLearn/sparrow/__tests__/geometry/utils.js":"60","/Users/junyingli/techLearn/sparrow/src/geometry/area.js":"61","/Users/junyingli/techLearn/sparrow/src/geometry/cell.js":"62","/Users/junyingli/techLearn/sparrow/src/geometry/channel.js":"63","/Users/junyingli/techLearn/sparrow/src/geometry/d.js":"64","/Users/junyingli/techLearn/sparrow/src/geometry/geometry.js":"65","/Users/junyingli/techLearn/sparrow/src/geometry/index.js":"66","/Users/junyingli/techLearn/sparrow/src/geometry/interval.js":"67","/Users/junyingli/techLearn/sparrow/src/geometry/line.js":"68","/Users/junyingli/techLearn/sparrow/src/geometry/link.js":"69","/Users/junyingli/techLearn/sparrow/src/geometry/path.js":"70","/Users/junyingli/techLearn/sparrow/src/geometry/point.js":"71","/Users/junyingli/techLearn/sparrow/src/geometry/primitive.js":"72","/Users/junyingli/techLearn/sparrow/src/geometry/rect.js":"73","/Users/junyingli/techLearn/sparrow/src/geometry/shape.js":"74","/Users/junyingli/techLearn/sparrow/src/geometry/style.js":"75","/Users/junyingli/techLearn/sparrow/src/geometry/text.js":"76","/Users/junyingli/techLearn/sparrow/src/utils/array.js":"77","/Users/junyingli/techLearn/sparrow/src/utils/dom.js":"78","/Users/junyingli/techLearn/sparrow/src/utils/tree.js":"79","/Users/junyingli/techLearn/sparrow/src/utils/vector.js":"80","/Users/junyingli/techLearn/sparrow/__tests__/guide/axisX.spec.js":"81","/Users/junyingli/techLearn/sparrow/__tests__/guide/axisY.spec.js":"82","/Users/junyingli/techLearn/sparrow/__tests__/guide/legend.spec.js":"83","/Users/junyingli/techLearn/sparrow/__tests__/guide/utils.js":"84","/Users/junyingli/techLearn/sparrow/src/guide/axis.js":"85","/Users/junyingli/techLearn/sparrow/src/guide/axisX.js":"86","/Users/junyingli/techLearn/sparrow/src/guide/axisY.js":"87","/Users/junyingli/techLearn/sparrow/src/guide/grid.js":"88","/Users/junyingli/techLearn/sparrow/src/guide/index.js":"89","/Users/junyingli/techLearn/sparrow/src/guide/label.js":"90","/Users/junyingli/techLearn/sparrow/src/guide/legendRamp.js":"91","/Users/junyingli/techLearn/sparrow/src/guide/legendSwatches.js":"92","/Users/junyingli/techLearn/sparrow/src/guide/ticks.js":"93","/Users/junyingli/techLearn/sparrow/src/scale/interpolate.js":"94","/Users/junyingli/techLearn/sparrow/__tests__/statistic/bin.spec.js":"95","/Users/junyingli/techLearn/sparrow/__tests__/statistic/normalize.spec.js":"96","/Users/junyingli/techLearn/sparrow/__tests__/statistic/stack.spec.js":"97","/Users/junyingli/techLearn/sparrow/__tests__/statistic/symmetry.spec.js":"98","/Users/junyingli/techLearn/sparrow/src/statistic/bin.js":"99","/Users/junyingli/techLearn/sparrow/src/statistic/index.js":"100","/Users/junyingli/techLearn/sparrow/src/statistic/normalize.js":"101","/Users/junyingli/techLearn/sparrow/src/statistic/stack.js":"102","/Users/junyingli/techLearn/sparrow/src/statistic/symmetry.js":"103"},{"size":553,"mtime":1716280044680,"results":"104","hashOfConfig":"105"},{"size":435,"mtime":1714801594557,"results":"106","hashOfConfig":"107"},{"size":414,"mtime":1714808881749,"results":"108","hashOfConfig":"109"},{"size":67,"mtime":1714800551268,"results":"110","hashOfConfig":"107"},{"size":241,"mtime":1714801594557,"results":"111","hashOfConfig":"107"},{"size":586,"mtime":1714801594557,"results":"112","hashOfConfig":"107"},{"size":656,"mtime":1714808881749,"results":"113","hashOfConfig":"109"},{"size":4250,"mtime":1714808881749,"results":"114","hashOfConfig":"109"},{"size":843,"mtime":1714808881749,"results":"115","hashOfConfig":"109"},{"size":533,"mtime":1714808881749,"results":"116","hashOfConfig":"109"},{"size":45,"mtime":1714808881749,"results":"117","hashOfConfig":"109"},{"size":913,"mtime":1714808881749,"results":"118","hashOfConfig":"109"},{"size":2272,"mtime":1716801932298,"results":"119","hashOfConfig":"109"},{"size":825,"mtime":1714808881750,"results":"120","hashOfConfig":"109"},{"size":1166,"mtime":1714808881750,"results":"121","hashOfConfig":"109"},{"size":56,"mtime":1714809449088,"results":"122","hashOfConfig":"109"},{"size":666,"mtime":1716813536659},{"size":2077,"mtime":1714912087516,"results":"123","hashOfConfig":"109"},{"size":452,"mtime":1714912055104,"results":"124","hashOfConfig":"109"},{"size":444,"mtime":1714912055102,"results":"125","hashOfConfig":"109"},{"size":343,"mtime":1714912055102,"results":"126","hashOfConfig":"109"},{"size":2372,"mtime":1714912055102,"results":"127","hashOfConfig":"109"},{"size":1239,"mtime":1714912055102,"results":"128","hashOfConfig":"109"},{"size":612,"mtime":1714912055102,"results":"129","hashOfConfig":"109"},{"size":436,"mtime":1714912055102,"results":"130","hashOfConfig":"109"},{"size":574,"mtime":1714912055103,"results":"131","hashOfConfig":"109"},{"size":479,"mtime":1714912055103,"results":"132","hashOfConfig":"109"},{"size":492,"mtime":1714912055103,"results":"133","hashOfConfig":"109"},{"size":426,"mtime":1714912055103,"results":"134","hashOfConfig":"109"},{"size":319,"mtime":1714912055103},{"size":483,"mtime":1716810659316,"results":"135","hashOfConfig":"105"},{"size":729,"mtime":1714912055103},{"size":249,"mtime":1716811312280,"results":"136","hashOfConfig":"105"},{"size":128,"mtime":1714912055103},{"size":582,"mtime":1714912055104},{"size":334,"mtime":1714912055104},{"size":307,"mtime":1714912055104},{"size":402,"mtime":1716280005672,"results":"137","hashOfConfig":"105"},{"size":309,"mtime":1716280005672,"results":"138","hashOfConfig":"105"},{"size":928,"mtime":1716280005673,"results":"139","hashOfConfig":"105"},{"size":467,"mtime":1716280005673,"results":"140","hashOfConfig":"105"},{"size":297,"mtime":1716280005673},{"size":586,"mtime":1716280005673,"results":"141","hashOfConfig":"105"},{"size":164,"mtime":1716280005673,"results":"142","hashOfConfig":"105"},{"size":770,"mtime":1716280005673},{"size":825,"mtime":1716280005673,"results":"143","hashOfConfig":"105"},{"size":358,"mtime":1716280005673,"results":"144","hashOfConfig":"105"},{"size":1416,"mtime":1716799386916,"results":"145","hashOfConfig":"105"},{"size":124,"mtime":1716799386916,"results":"146","hashOfConfig":"105"},{"size":5541,"mtime":1716798485609},{"size":2165,"mtime":1716798485610},{"size":749,"mtime":1716798485610,"results":"147","hashOfConfig":"105"},{"size":6174,"mtime":1716798485611},{"size":2458,"mtime":1716798485611},{"size":1005,"mtime":1716798485612,"results":"148","hashOfConfig":"105"},{"size":915,"mtime":1716801825288,"results":"149","hashOfConfig":"105"},{"size":2290,"mtime":1716798485612},{"size":1695,"mtime":1716798485612},{"size":1342,"mtime":1716798485613,"results":"150","hashOfConfig":"105"},{"size":1055,"mtime":1716798485613,"results":"151","hashOfConfig":"105"},{"size":884,"mtime":1716798472631},{"size":837,"mtime":1716798472632,"results":"152","hashOfConfig":"105"},{"size":394,"mtime":1716798472633,"results":"153","hashOfConfig":"105"},{"size":890,"mtime":1716798472633,"results":"154","hashOfConfig":"105"},{"size":588,"mtime":1716798472633,"results":"155","hashOfConfig":"105"},{"size":289,"mtime":1716798472633,"results":"156","hashOfConfig":"105"},{"size":1161,"mtime":1716798472634},{"size":746,"mtime":1716798472634,"results":"157","hashOfConfig":"105"},{"size":740,"mtime":1716798472634},{"size":690,"mtime":1716799470321,"results":"158","hashOfConfig":"105"},{"size":768,"mtime":1716798472635,"results":"159","hashOfConfig":"105"},{"size":897,"mtime":1716798472635},{"size":740,"mtime":1716798472635},{"size":2429,"mtime":1716798472635},{"size":280,"mtime":1716798472636,"results":"160","hashOfConfig":"105"},{"size":1059,"mtime":1716798472636},{"size":2414,"mtime":1716799386915,"results":"161","hashOfConfig":"105"},{"size":698,"mtime":1716799386915,"results":"162","hashOfConfig":"105"},{"size":336,"mtime":1716799386916,"results":"163","hashOfConfig":"105"},{"size":897,"mtime":1716799386916,"results":"164","hashOfConfig":"105"},{"size":2879,"mtime":1716810499691},{"size":2833,"mtime":1716810499692},{"size":1863,"mtime":1716813649417,"results":"165","hashOfConfig":"105"},{"size":1027,"mtime":1716810499693},{"size":1406,"mtime":1716810485906},{"size":1018,"mtime":1716810485907},{"size":1002,"mtime":1716810485908},{"size":844,"mtime":1716810485908},{"size":160,"mtime":1716810485908,"results":"166","hashOfConfig":"105"},{"size":1027,"mtime":1716810485909},{"size":1262,"mtime":1716810485909},{"size":930,"mtime":1716810485910},{"size":2154,"mtime":1716810485910},{"size":720,"mtime":1716814226867,"results":"167","hashOfConfig":"105"},{"size":652,"mtime":1716815590971,"results":"168","hashOfConfig":"105"},{"size":490,"mtime":1716815590971,"results":"169","hashOfConfig":"105"},{"size":430,"mtime":1716815590972,"results":"170","hashOfConfig":"105"},{"size":478,"mtime":1716815590972,"results":"171","hashOfConfig":"105"},{"size":1578,"mtime":1716815571108},{"size":170,"mtime":1716815571108,"results":"172","hashOfConfig":"105"},{"size":784,"mtime":1716815571109,"results":"173","hashOfConfig":"105"},{"size":599,"mtime":1716815571109,"results":"174","hashOfConfig":"105"},{"size":1041,"mtime":1716815571110,"results":"175","hashOfConfig":"105"},{"filePath":"176","messages":"177","suppressedMessages":"178","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1jm62pz",{"filePath":"179","messages":"180","suppressedMessages":"181","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1hkiy78",{"filePath":"182","messages":"183","suppressedMessages":"184","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1l8n0xm",{"filePath":"185","messages":"186","suppressedMessages":"187","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"188","messages":"189","suppressedMessages":"190","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"191","messages":"192","suppressedMessages":"193","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"194","messages":"195","suppressedMessages":"196","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"197","messages":"198","suppressedMessages":"199","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"200","messages":"201","suppressedMessages":"202","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"203","messages":"204","suppressedMessages":"205","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"206","messages":"207","suppressedMessages":"208","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"209","messages":"210","suppressedMessages":"211","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"212","messages":"213","suppressedMessages":"214","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"215","messages":"216","suppressedMessages":"217","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"218","messages":"219","suppressedMessages":"220","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"221","messages":"222","suppressedMessages":"223","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"224","messages":"225","suppressedMessages":"226","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"227","messages":"228","suppressedMessages":"229","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"230","messages":"231","suppressedMessages":"232","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"233","messages":"234","suppressedMessages":"235","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"236","messages":"237","suppressedMessages":"238","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"239","messages":"240","suppressedMessages":"241","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"242","messages":"243","suppressedMessages":"244","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"245","messages":"246","suppressedMessages":"247","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"248","messages":"249","suppressedMessages":"250","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"251","messages":"252","suppressedMessages":"253","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"254","messages":"255","suppressedMessages":"256","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"257","messages":"258","suppressedMessages":"259","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"260","messages":"261","suppressedMessages":"262","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"263","messages":"264","suppressedMessages":"265","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"266","messages":"267","suppressedMessages":"268","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"269","messages":"270","suppressedMessages":"271","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"272","messages":"273","suppressedMessages":"274","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"275","messages":"276","suppressedMessages":"277","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"278","messages":"279","suppressedMessages":"280","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"281","messages":"282","suppressedMessages":"283","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"284","messages":"285","suppressedMessages":"286","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"287","messages":"288","suppressedMessages":"289","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"290","messages":"291","suppressedMessages":"292","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"293","messages":"294","suppressedMessages":"295","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"296","messages":"297","suppressedMessages":"298","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"299","messages":"300","suppressedMessages":"301","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"302","messages":"303","suppressedMessages":"304","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"305","messages":"306","suppressedMessages":"307","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"308","messages":"309","suppressedMessages":"310","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"311","messages":"312","suppressedMessages":"313","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"314","messages":"315","suppressedMessages":"316","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"317","messages":"318","suppressedMessages":"319","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"320","messages":"321","suppressedMessages":"322","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"323","messages":"324","suppressedMessages":"325","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"326","messages":"327","suppressedMessages":"328","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"329","messages":"330","suppressedMessages":"331","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"332","messages":"333","suppressedMessages":"334","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"335","messages":"336","suppressedMessages":"337","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"338","messages":"339","suppressedMessages":"340","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"341","messages":"342","suppressedMessages":"343","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"344","messages":"345","suppressedMessages":"346","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"347","messages":"348","suppressedMessages":"349","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"350","messages":"351","suppressedMessages":"352","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"353","messages":"354","suppressedMessages":"355","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"356","messages":"357","suppressedMessages":"358","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"359","messages":"360","suppressedMessages":"361","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"362","messages":"363","suppressedMessages":"364","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"365","messages":"366","suppressedMessages":"367","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"368","messages":"369","suppressedMessages":"370","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"371","messages":"372","suppressedMessages":"373","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"374","messages":"375","suppressedMessages":"376","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"377","messages":"378","suppressedMessages":"379","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"380","messages":"381","suppressedMessages":"382","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/junyingli/techLearn/sparrow/.eslintrc.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/index.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/utils.js",[],[],"/Users/junyingli/techLearn/sparrow/commitlint.config.js",[],[],"/Users/junyingli/techLearn/sparrow/jest.config.js",[],[],"/Users/junyingli/techLearn/sparrow/rollup.config.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/renderer/renderer.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/renderer/shape.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/renderer/transform.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/context.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/renderer.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/shape.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/transform.js",[],[],"/Users/junyingli/techLearn/sparrow/src/renderer/utils.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/identity.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/utils.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/time.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/band.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/identity.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/linear.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/log.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/ordinal.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/point.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/quantile.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/quantize.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/threshold.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/scale/time.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/ordinal.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/coordinate/cartesian.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/coordinate/coordinate.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/coordinate/polar.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/coordinate/transpose.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/coordinate/coordinate.js",[],[],"/Users/junyingli/techLearn/sparrow/src/coordinate/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/coordinate/transform.js",[],[],"/Users/junyingli/techLearn/sparrow/src/coordinate/transpose.js",[],["383","384"],"/Users/junyingli/techLearn/sparrow/src/utils/helper.js",[],[],"/Users/junyingli/techLearn/sparrow/src/utils/index.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/geometry.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/link.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/path.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/text.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/geometry/utils.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/cell.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/channel.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/d.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/geometry.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/line.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/path.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/point.js",[],[],"/Users/junyingli/techLearn/sparrow/src/geometry/style.js",[],[],"/Users/junyingli/techLearn/sparrow/src/utils/array.js",[],["385"],"/Users/junyingli/techLearn/sparrow/src/utils/dom.js",[],[],"/Users/junyingli/techLearn/sparrow/src/utils/tree.js",[],[],"/Users/junyingli/techLearn/sparrow/src/utils/vector.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/guide/legend.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/guide/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/scale/interpolate.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/statistic/bin.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/statistic/normalize.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/statistic/stack.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/__tests__/statistic/symmetry.spec.js",[],[],"/Users/junyingli/techLearn/sparrow/src/statistic/index.js",[],[],"/Users/junyingli/techLearn/sparrow/src/statistic/normalize.js",[],[],"/Users/junyingli/techLearn/sparrow/src/statistic/stack.js",[],[],"/Users/junyingli/techLearn/sparrow/src/statistic/symmetry.js",[],[],{"ruleId":"386","severity":2,"message":"387","line":5,"column":21,"nodeType":"388","messageId":"389","endLine":5,"endColumn":37,"suppressions":"390"},{"ruleId":"386","severity":2,"message":"391","line":5,"column":39,"nodeType":"388","messageId":"389","endLine":5,"endColumn":52,"suppressions":"392"},{"ruleId":"386","severity":2,"message":"393","line":93,"column":30,"nodeType":"388","messageId":"389","endLine":93,"endColumn":38,"suppressions":"394"},"no-unused-vars","'transformOptions' is defined but never used.","Identifier","unusedVar",["395"],"'canvasOptions' is defined but never used.",["396"],"'accessor' is assigned a value but never used.",["397"],{"kind":"398","justification":"399"},{"kind":"398","justification":"399"},{"kind":"398","justification":"399"},"directive",""] \ No newline at end of file diff --git a/__tests__/view/view.spec.js b/__tests__/view/view.spec.js new file mode 100644 index 0000000..0b72790 --- /dev/null +++ b/__tests__/view/view.spec.js @@ -0,0 +1,186 @@ +import { createViews } from '../../src/view/view'; +import { createRenderer } from '../../src/renderer/renderer'; +import { mount, createDiv } from '../utils'; + +function renderViews(views, width = 640, height = 480) { + const renderer = createRenderer(width, height); + mount(createDiv(), renderer.node()); + return views.map(([{ + x, y, width, height, + }]) => renderer.rect({ + x, y, width, height, stroke: 'black', fill: 'none', + })); +} + +describe('createViews', () => { + test('basic container', () => { + const views = createViews({}); + renderViews(views); + + expect(views.length).toBe(1); + const [[view, [node]]] = views; + expect(view).toEqual({ + x: 0, y: 0, width: 640, height: 480, + }); + expect(node).toEqual({}); + }); + + test('layer container', () => { + const views = createViews({ + type: 'layer', + children: [{}, {}], + }); + renderViews(views); + + expect(views.length).toBe(1); + const [[view, nodes]] = views; + expect(view).toEqual({ + x: 0, y: 0, width: 640, height: 480, + }); + expect(nodes.length).toBe(3); + }); + + test('row container', () => { + const views = createViews({ + type: 'row', + children: [{}, {}], + }); + renderViews(views); + expect(views.length).toBe(3); + + const [, [view, [node]]] = views; + expect(view).toEqual({ + height: 480, width: 300, x: 0, y: 0, + }); + expect(node).toEqual({}); + }); + + test('col container', () => { + const views = createViews({ + type: 'col', + padding: 20, + flex: [1, 2, 1], + children: [ + {}, {}, {}, + ], + }); + renderViews(views); + + expect(views.length).toBe(4); + + const [, [view, [node]]] = views; + expect(view).toEqual({ + height: 110, width: 640, x: 0, y: 0, + }); + expect(node).toEqual({}); + }); + + test('flex container', () => { + const views = createViews({ + type: 'row', + children: [ + {}, + { type: 'col', children: [{}, {}] }, + ], + }); + renderViews(views); + + expect(views.length).toBe(5); + const [, , , [view, [node]]] = views; + expect(view).toEqual({ + height: 220, width: 300, x: 340, y: 0, + }); + expect(node).toEqual({}); + }); + + test('facet container with specified x', () => { + const data = [ + { sex: 'male', skin: 'white' }, + { sex: 'male', skin: 'black' }, + { sex: 'female', skin: 'white' }, + { sex: 'female', skin: 'yellow' }, + ]; + const views = createViews({ + type: 'facet', + encodings: { + x: 'sex', + }, + data, + children: [{}], + }); + renderViews(views); + + expect(views.length).toBe(3); + const [, [view, [node]]] = views; + const { transform, ...rest } = view; + expect(rest).toEqual({ + height: 375, width: 275, x: 45, y: 45, + }); + expect(node).toEqual({}); + expect(transform(data)).toEqual([ + { sex: 'male', skin: 'white' }, + { sex: 'male', skin: 'black' }, + ]); + }); + + test('facet container with specified y', () => { + const data = [ + { sex: 'male', skin: 'white' }, + { sex: 'male', skin: 'black' }, + { sex: 'female', skin: 'white' }, + { sex: 'female', skin: 'yellow' }, + ]; + const views = createViews({ + type: 'facet', + encodings: { + y: 'skin', + }, + data, + children: [{}, {}], + }); + renderViews(views); + + expect(views.length).toBe(4); + const [, [view, [node]]] = views; + const { transform, ...rest } = view; + expect(rest).toEqual({ + height: 125, width: 550, x: 45, y: 45, + }); + expect(node).toEqual({}); + expect(transform(data)).toEqual([ + { sex: 'male', skin: 'white' }, + { sex: 'female', skin: 'white' }, + ]); + }); + + test('facet container', () => { + const data = [ + { sex: 'male', skin: 'white' }, + { sex: 'male', skin: 'black' }, + { sex: 'female', skin: 'white' }, + { sex: 'female', skin: 'yellow' }, + ]; + const views = createViews({ + type: 'facet', + encodings: { + x: 'sex', + y: 'skin', + }, + data, + padding: 20, + children: [{}, {}], + }); + renderViews(views); + + expect(views.length).toBe(7); + const [, [view, [node]]] = views; + const { transform, ...rest } = view; + expect(rest).toEqual({ + height: 111.66666666666667, width: 265, x: 45, y: 45, + }); + expect(node).toEqual({}); + expect(transform(data)).toEqual([ + { sex: 'male', skin: 'white' }, + ]); + }); +}); diff --git a/src/view/facet.js b/src/view/facet.js new file mode 100644 index 0000000..40745ac --- /dev/null +++ b/src/view/facet.js @@ -0,0 +1,34 @@ +import { group } from '../utils'; + +export function computeFacetViews(box, { + data, encodings = {}, padding = 0, + paddingLeft = 45, paddingRight = 45, paddingBottom = 45, paddingTop = 60, +}) { + const { x, y } = encodings; + const cols = x ? Array.from(group(data, (d) => d[x]).keys()) : [undefined]; + const rows = y ? Array.from(group(data, (d) => d[y]).keys()) : [undefined]; + const n = cols.length; + const m = rows.length; + const views = []; + const width = box.width - paddingLeft - paddingRight; + const height = box.height - paddingTop - paddingBottom; + const boxWidth = (width - padding * (n - 1)) / n; + const boxHeight = (height - padding * (m - 1)) / m; + for (let i = 0; i < n; i += 1) { + for (let j = 0; j < m; j += 1) { + const transform = (data) => { + const inRow = (d) => d[x] === cols[i] || cols[i] === undefined; + const inCol = (d) => d[y] === rows[j] || rows[j] === undefined; + return data.filter((d) => inRow(d) && inCol(d)); + }; + views.push({ + x: paddingLeft + box.x + padding * i + i * boxWidth, + y: paddingRight + box.y + padding * j + j * boxHeight, + width: boxWidth, + height: boxHeight, + transform, + }); + } + } + return views; +} diff --git a/src/view/flex.js b/src/view/flex.js new file mode 100644 index 0000000..df923b9 --- /dev/null +++ b/src/view/flex.js @@ -0,0 +1,23 @@ +export function computeFlexViews(box, node) { + const { + type, children, flex = children.map(() => 1), padding = 40, + } = node; + const [mainStart, mainSize, crossSize, crossStart] = type === 'col' + ? ['y', 'height', 'width', 'x'] + : ['x', 'width', 'height', 'y']; + + const sum = flex.reduce((total, value) => total + value); + const totalSize = box[mainSize] - padding * (children.length - 1); + const sizes = flex.map((value) => totalSize * (value / sum)); + + const childrenViews = []; + for (let next = box[mainStart], i = 0; i < sizes.length; next += sizes[i] + padding, i += 1) { + childrenViews.push({ + [mainStart]: next, + [mainSize]: sizes[i], + [crossStart]: box[crossStart], + [crossSize]: box[crossSize], + }); + } + return childrenViews; +} diff --git a/src/view/index.js b/src/view/index.js new file mode 100644 index 0000000..8c4bb67 --- /dev/null +++ b/src/view/index.js @@ -0,0 +1 @@ +export { createViews } from './view'; diff --git a/src/view/layer.js b/src/view/layer.js new file mode 100644 index 0000000..3d95476 --- /dev/null +++ b/src/view/layer.js @@ -0,0 +1,4 @@ +export function computeLayerViews(box, node) { + const { children = [] } = node; + return new Array(children.length).fill(0).map(() => ({ ...box })); +} diff --git a/src/view/view.js b/src/view/view.js new file mode 100644 index 0000000..5887115 --- /dev/null +++ b/src/view/view.js @@ -0,0 +1,48 @@ +import { computeFlexViews } from './flex'; +import { computeFacetViews } from './facet'; +import { computeLayerViews } from './layer'; +import { descendants, group } from '../utils'; + +export function createViews(root, computes = { + layer: computeLayerViews, + col: computeFlexViews, + row: computeFlexViews, + facet: computeFacetViews, +}) { + const nodes = descendants(root); + const { + width = 640, height = 480, x = 0, y = 0, + } = root; + const rootView = { + width, height, x, y, + }; + const nodeView = new Map([[root, rootView]]); + + for (const node of nodes) { + const view = nodeView.get(node); + const { children = [], type } = node; + const computeChildrenViews = computes[type]; + if (computeChildrenViews) { + const childrenViews = computeChildrenViews(view, node); + if (computeChildrenViews !== computeFacetViews) { + for (const [i, child] of Object.entries(children)) { + nodeView.set(child, childrenViews[i]); + } + } else { + for (const child of children) { + for (const view of childrenViews) { + nodeView.set({ ...child }, view); + } + } + } + } + } + + const key = (d) => `${d.x}-${d.y}-${d.width}-${d.height}`; + const keyViews = group(Array.from(nodeView.entries()), ([, view]) => key(view)); + return Array.from(keyViews.values()).map((views) => { + const view = views[0][1]; + const nodes = views.map((d) => d[0]); + return [view, nodes]; + }); +}