Skip to content

Commit

Permalink
test(viz): update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 5, 2020
1 parent b423600 commit 4172803
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/viz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
"doc": "node_modules/.bin/typedoc --mode modules --out doc src",
"pub": "yarn build:release && yarn publish --access public",
"tool:candles": "ts-node -P tools/tsconfig.json tools/candles.ts",
"tool:intervals": "ts-node -P tools/tsconfig.json tools/intervals.ts"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/viz/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe("viz", () => {
domain: [0, 4],
range: [50, 250],
pos: 100,
major: { ticks: linTickMarks() },
minor: { ticks: linTickMarks() },
major: { ticks: linTickMarks(1) },
minor: { ticks: linTickMarks(1) },
})
);
assert.deepEqual(axis, [
Expand Down Expand Up @@ -80,8 +80,8 @@ describe("viz", () => {
pos: 100,
labelAttribs: { "text-anchor": "end" },
labelOffset: [-15, 5],
major: { ticks: linTickMarks(), size: -10 },
minor: { ticks: linTickMarks() },
major: { ticks: linTickMarks(1), size: -10 },
minor: { ticks: linTickMarks(1) },
})
);
assert.deepEqual(axis, [
Expand Down
11 changes: 3 additions & 8 deletions packages/viz/tools/candles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import {
const prices: any[] = JSON.parse(
readFileSync("dev/ohlc.json").toString()
).Data.map((x: any) => ({ ...x, time: x.time * 1000 }));
const domain = dataBounds((x) => x.time, prices, 1 * HOUR);
const res = plotCartesian({
xaxis: linearAxis({
domain: dataBounds((x) => x.time, prices, 1 * HOUR),
domain,
range: [100, 1250],
pos: 500,
labelOffset: [0, 20],
Expand Down Expand Up @@ -47,12 +48,6 @@ const res = plotCartesian({
minor: { ticks: linTickMarks(50) },
}),
plots: [
// areaPlot(vals, {
// attribs: { fill: "red" },
// }),
// scatterPlot(vals, {
// attribs: { size: 5, fill: "none", stroke: "red" },
// }),
candlePlot(
prices.map((p: any) => [
p.time,
Expand All @@ -74,7 +69,7 @@ const res = plotCartesian({
});

writeFileSync(
"export/linechart.svg",
"export/candles.svg",
serialize(
convertTree(svg({ width: 1280, height: 560, "font-size": "10px" }, res))
)
Expand Down

0 comments on commit 4172803

Please sign in to comment.