Skip to content

Commit ff10083

Browse files
chore: code formatting
1 parent b4908d8 commit ff10083

File tree

4 files changed

+50
-50
lines changed

4 files changed

+50
-50
lines changed

source/app/metrics/utils.mjs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ export const Graph = {
822822
/**Basic Graph */
823823
graph(type, data, {area = true, points = true, text = true, low = NaN, high = NaN, match = null, labels = null, width = 480, height = 315, ticks = 0} = {}) {
824824
//Generate SVG
825-
const margin = {top:10, left:10, right:10, bottom:45}
825+
const margin = {top: 10, left: 10, right: 10, bottom: 45}
826826
const d3n = new D3node()
827827
const svg = d3n.createSVG(width, height)
828828

@@ -862,7 +862,7 @@ export const Graph = {
862862
.range([margin.left, height - margin.top - margin.bottom])
863863
svg.append("g")
864864
.attr("transform", `translate(${margin.left},${margin.top})`)
865-
.call(d3.axisRight(y).ticks(Math.round(height/50)).tickSize(width - margin.left - margin.right))
865+
.call(d3.axisRight(y).ticks(Math.round(height / 50)).tickSize(width - margin.left - margin.right))
866866
.call(g => g.select(".domain").remove())
867867
.call(g => g.selectAll(".tick line").attr("stroke-opacity", 0.5).attr("stroke-dasharray", "2,2"))
868868
.call(g => g.selectAll(".tick text").attr("x", 0).attr("dy", -4))
@@ -883,7 +883,7 @@ export const Graph = {
883883
d3.line()
884884
.curve(d3.curveLinear)
885885
.x(d => x(d[0]))
886-
.y(d => y(d[1]))
886+
.y(d => y(d[1])),
887887
)
888888
.attr("fill", "transparent")
889889
.attr("stroke", "#87ceeb")
@@ -892,24 +892,24 @@ export const Graph = {
892892
//Generate graph area
893893
if (area) {
894894
svg.append("path")
895-
.datum(datum)
896-
.attr("transform", `translate(${margin.left},${margin.top})`)
897-
.attr(
898-
"d",
899-
d3.area()
900-
.curve(d3.curveLinear)
901-
.x(d => x(d[0]))
902-
.y0(d => y(d[1]))
903-
.y1(() => y(low)),
904-
)
905-
.attr("fill", "rgba(88, 166, 255, .1)")
895+
.datum(datum)
896+
.attr("transform", `translate(${margin.left},${margin.top})`)
897+
.attr(
898+
"d",
899+
d3.area()
900+
.curve(d3.curveLinear)
901+
.x(d => x(d[0]))
902+
.y0(d => y(d[1]))
903+
.y1(() => y(low)),
904+
)
905+
.attr("fill", "rgba(88, 166, 255, .1)")
906906
}
907907

908908
//Generate graph points
909909
if (points) {
910910
svg.append("g")
911-
.selectAll("circle")
912-
.data(yticked)
911+
.selectAll("circle")
912+
.data(yticked)
913913
.join("circle")
914914
.attr("transform", `translate(${margin.left},${margin.top})`)
915915
.attr("cx", d => x(d[0]))
@@ -929,10 +929,10 @@ export const Graph = {
929929
.attr("stroke-linejoin", "round")
930930
.attr("stroke-width", 4)
931931
.attr("paint-order", "stroke fill")
932-
.selectAll("text")
933-
.data(yticked)
934-
.join("text")
935-
.attr("transform", `translate(${margin.left},${margin.top-4})`)
932+
.selectAll("text")
933+
.data(yticked)
934+
.join("text")
935+
.attr("transform", `translate(${margin.left},${margin.top - 4})`)
936936
.attr("x", d => x(d[0]))
937937
.attr("y", d => y(d[1]))
938938
.text(d => d[2] ? d[2] : "")
@@ -955,46 +955,46 @@ export const Graph = {
955955

956956
//Construct arcs
957957
const color = d3.scaleOrdinal(K, d3.schemeSpectral[K.length])
958-
const arcs = d3.pie().padAngle(1/radius).sort(null).value(i => V[i])(I)
958+
const arcs = d3.pie().padAngle(1 / radius).sort(null).value(i => V[i])(I)
959959
const arc = d3.arc().innerRadius(0).outerRadius(radius)
960-
const labels = d3.arc().innerRadius(radius/2).outerRadius(radius/2)
960+
const labels = d3.arc().innerRadius(radius / 2).outerRadius(radius / 2)
961961

962962
svg.append("g")
963-
.attr("transform", `translate(${width/2},${height/2})`)
963+
.attr("transform", `translate(${width / 2},${height / 2})`)
964964
.attr("stroke", "white")
965965
.attr("stroke-width", 1)
966966
.attr("stroke-linejoin", "round")
967-
.selectAll("path")
968-
.data(arcs)
969-
.join("path")
967+
.selectAll("path")
968+
.data(arcs)
969+
.join("path")
970970
.attr("fill", d => colors?.[K[d.data]] ?? color(K[d.data]))
971971
.attr("d", arc)
972-
.append("title")
972+
.append("title")
973973
.text(d => `${K[d.data]}\n${V[d.data]}`)
974974

975975
svg.append("g")
976-
.attr("transform", `translate(${width/2},${height/2})`)
976+
.attr("transform", `translate(${width / 2},${height / 2})`)
977977
.attr("font-family", "sans-serif")
978978
.attr("font-size", 12)
979979
.attr("text-anchor", "middle")
980980
.attr("fill", "white")
981981
.attr("stroke", "rbga(0,0,0,.9)")
982982
.attr("paint-order", "stroke fill")
983-
.selectAll("text")
984-
.data(arcs)
985-
.join("text")
983+
.selectAll("text")
984+
.data(arcs)
985+
.join("text")
986986
.attr("transform", d => `translate(${labels.centroid(d)})`)
987-
.selectAll("tspan")
988-
.data(d => {
989-
const lines = `${K[d.data]}\n${V[d.data]}`.split(/\n/)
990-
return (d.endAngle - d.startAngle) > 0.25 ? lines : lines.slice(0, 1)
991-
})
992-
.join("tspan")
987+
.selectAll("tspan")
988+
.data(d => {
989+
const lines = `${K[d.data]}\n${V[d.data]}`.split(/\n/)
990+
return (d.endAngle - d.startAngle) > 0.25 ? lines : lines.slice(0, 1)
991+
})
992+
.join("tspan")
993993
.attr("x", 0)
994994
.attr("y", (_, i) => `${i * 1.1}em`)
995995
.attr("font-weight", (_, i) => i ? null : "bold")
996996
.text(d => d)
997997

998998
return d3n.svgString()
999-
}
999+
},
10001000
}

source/plugins/community/stock/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal
3131

3232
//Generating chart
3333
console.debug(`metrics/compute/${login}/plugins > stock > generating chart`)
34-
const chart = imports.Graph.timeline(close.map((y, i) => ({x:new Date(timestamp[i]*1000), y})), {low:Math.min(...close), high:Math.max(...close), points:false, text:false, width: 480 * (1 + data.large), height:200})
34+
const chart = imports.Graph.timeline(close.map((y, i) => ({x: new Date(timestamp[i] * 1000), y})), {low: Math.min(...close), high: Math.max(...close), points: false, text: false, width: 480 * (1 + data.large), height: 200})
3535

3636
//Results
3737
return {chart, currency, price, previous, delta: price - previous, symbol, company, interval, duration}

source/plugins/habits/index.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ export default async function({login, data, rest, imports, q, account}, {enabled
120120
if ((["graph", "chartist"].includes(_charts)) && (imports.metadata.plugins.habits.extras("charts.type", {extras}))) {
121121
console.debug(`metrics/compute/${login}/plugins > habits > generating charts`)
122122
habits.charts = await Promise.all([
123-
{type: "line", data: {...empty(24), ...Object.fromEntries(Object.entries(habits.commits.hours).filter(([k]) => !Number.isNaN(+k)))}, ticks:24, low: 0, high: habits.commits.hours.max},
124-
{type: "line", data: {...empty(7), ...Object.fromEntries(Object.entries(habits.commits.days).filter(([k]) => !Number.isNaN(+k)))}, ticks:7, low: 0, high: habits.commits.days.max, labels:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], half: true},
125-
{type: "pie", data: Object.fromEntries(Object.entries(habits.linguist.languages).map(([k, v]) => [k, (100*v).toFixed(2)])), colors:habits.linguist.colors, half: true},
123+
{type: "line", data: {...empty(24), ...Object.fromEntries(Object.entries(habits.commits.hours).filter(([k]) => !Number.isNaN(+k)))}, ticks: 24, low: 0, high: habits.commits.hours.max},
124+
{type: "line", data: {...empty(7), ...Object.fromEntries(Object.entries(habits.commits.days).filter(([k]) => !Number.isNaN(+k)))}, ticks: 7, low: 0, high: habits.commits.days.max, labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], half: true},
125+
{type: "pie", data: Object.fromEntries(Object.entries(habits.linguist.languages).map(([k, v]) => [k, (100 * v).toFixed(2)])), colors: habits.linguist.colors, half: true},
126126
].map(({type, data, high, low, ticks, colors = null, labels = null, half = false}) => {
127127
const width = 480 * (half ? 0.45 : 1)
128128
const height = 160
129129
if (type === "line")
130-
return imports.Graph.line(Object.entries(data).map(([x, y]) => ({x:+x, y})), {low, high, ticks, labels, width, height})
130+
return imports.Graph.line(Object.entries(data).map(([x, y]) => ({x: +x, y})), {low, high, ticks, labels, width, height})
131131
console.log(data)
132132
if (type === "pie")
133133
return imports.Graph.pie(data, {colors, width, height})

source/plugins/stargazers/index.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default async function({login, graphql, data, imports, q, queries, accoun
99
//Load inputs
1010
let {days, charts: _charts, "charts.type": _charts_type, worldmap: _worldmap, "worldmap.sample": _worldmap_sample} = imports.metadata.plugins.stargazers.inputs({data, account, q})
1111
if (!days) {
12-
days = Math.abs(parseInt((new Date() - new Date(data.user.createdAt))/1000/60/60/24))
12+
days = Math.abs(parseInt((new Date() - new Date(data.user.createdAt)) / 1000 / 60 / 60 / 24))
1313
console.debug(`metrics/compute/${login}/plugins > stargazers > set days to ${days}`)
1414
}
1515

@@ -65,13 +65,13 @@ export default async function({login, graphql, data, imports, q, queries, accoun
6565

6666
//Generating charts
6767
let charts = _charts ? true : null
68-
if ((["graph", "chartist"].includes(_charts_type)) && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
68+
if ((["graph", "chartist"].includes(_charts_type)) && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
6969
console.debug(`metrics/compute/${login}/plugins > stargazers > generating charts`)
70-
charts = await Promise.all([{data: total, low: total.min, high: total.max}, {data: increments, low: 0, high: increments.max, sign: true}].map(({data: {dates: set}, low, high, sign = false}) =>
71-
imports.Graph.timeline(Object.entries(set).map(([x, y]) => ({x:new Date(x), y, text:imports.format(y, {sign})})), {low, high,
72-
match:(data, ticks) => data.filter(([x]) => ticks.map(t => t.toISOString().slice(0, 10)).includes(x.toISOString().slice(0, 10))),
73-
})
74-
))
70+
charts = await Promise.all(
71+
[{data: total, low: total.min, high: total.max}, {data: increments, low: 0, high: increments.max, sign: true}].map(({data: {dates: set}, low, high, sign = false}) =>
72+
imports.Graph.timeline(Object.entries(set).map(([x, y]) => ({x: new Date(x), y, text: imports.format(y, {sign})})), {low, high, match: (data, ticks) => data.filter(([x]) => ticks.map(t => t.toISOString().slice(0, 10)).includes(x.toISOString().slice(0, 10)))})
73+
),
74+
)
7575
}
7676

7777
//Generating worldmap

0 commit comments

Comments
 (0)