Skip to content

Commit 089dd7e

Browse files
committed
lint
1 parent 732790f commit 089dd7e

File tree

7 files changed

+18
-11
lines changed

7 files changed

+18
-11
lines changed

graph/_graph.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ export function graph(type: string, datalist: datalist, options: options = {}):
2424
const x = ((type === "time" ? d3.scaleTime().domain([new Date(start), new Date(end)]) : d3.scaleLinear().domain([start, end])) as ReturnType<typeof d3.scaleLinear<number, number>>)
2525
.range([margin.top, width - margin.left - margin.right])
2626
let ticks = d3.axisBottom(x)
27-
if (options.ticks)
27+
if (options.ticks) {
2828
ticks = ticks.ticks(options.ticks)
29-
if (options.labels)
29+
}
30+
if (options.labels) {
3031
ticks = ticks.tickFormat((_: unknown, i: number) => `${options.labels?.[i] ?? ""}`)
32+
}
3133
svg.append("g")
3234
.attr("transform", `translate(${margin.left},${height - margin.bottom})`)
3335
.call(ticks)
@@ -171,8 +173,9 @@ export function graph(type: string, datalist: datalist, options: options = {}):
171173
/** Generates a random color based on the provided seed. */
172174
export function mkcolor(seed: string): string {
173175
let hex = 9
174-
for (let i = 0; i < seed.length;)
176+
for (let i = 0; i < seed.length;) {
175177
hex = Math.imul(hex ^ seed.charCodeAt(i++), 9 ** 9)
178+
}
176179
hex = hex ^ hex >>> 9
177180
const r = (hex & 0xff0000) >> 8 * 2
178181
const g = (hex & 0x00ff00) >> 8 * 1

graph/diff.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Imports
2-
import { d3, mksvg, mkconfig, options, type d3arg } from "./_graph.ts"
2+
import { d3, type d3arg, mkconfig, mksvg, type options } from "./_graph.ts"
33
import { pick } from "@std/collections"
4+
export type { options }
45

56
/**
67
* Generates a diff graph.
@@ -83,4 +84,4 @@ export function diff(datalist: Record<PropertyKey, { data: { date: Date; added:
8384

8485
// Render SVG
8586
return svg.node()!.outerHTML
86-
}
87+
}

graph/line.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Imports
2-
import { graph, datalist, options } from "./_graph.ts"
2+
import { type data, type datalist, graph, type options } from "./_graph.ts"
3+
export type { data, datalist, options }
34

45
/**
56
* Renders a line graph.
@@ -17,4 +18,4 @@ import { graph, datalist, options } from "./_graph.ts"
1718
*/
1819
export function line(datalist: datalist, options?: options): string {
1920
return graph("line", datalist, options)
20-
}
21+
}

graph/line_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ test("`line()` generates a line graph", () => {
2020
data: [{ x: 0.5, y: 1.5, text: "B0" }, { x: 2.5, y: 2, text: "B1" }],
2121
},
2222
}, { min: 0, max: 5, ticks: 4, labels: { 0: "0" }, legend: true, title: "title" })).toMatch(svg)
23-
})
23+
})

graph/mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from "./diff.ts"
22
export * from "./line.ts"
33
export * from "./pie.ts"
4-
export * from "./time.ts"
4+
export * from "./time.ts"

graph/pie.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Imports
2-
import { d3, mksvg, mkconfig, mkcolor, options, type d3arg, type d3data } from "./_graph.ts"
2+
import { d3, type d3arg, type d3data, mkcolor, mkconfig, mksvg, type options } from "./_graph.ts"
33
import { pick } from "@std/collections"
4+
export type { options }
45

56
/**
67
* Renders a pie chart.

graph/time.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Imports
2-
import { graph, datalist, options } from "./_graph.ts"
2+
import { type data, type datalist, graph, type options } from "./_graph.ts"
3+
export type { data, datalist, options }
34

45
/**
56
* Renders a time-based graph.

0 commit comments

Comments
 (0)