chore: code formatting

This commit is contained in:
github-actions[bot]
2022-01-26 02:08:13 +00:00
parent 47499b95d5
commit c08a17596d
2 changed files with 21 additions and 20 deletions

View File

@@ -3,7 +3,7 @@ export default async function({q, data, imports, account}, {enabled = false} = {
//Plugin execution //Plugin execution
try { try {
//Check if plugin is enabled and requirements are met //Check if plugin is enabled and requirements are met
if ((!enabled)||(!q.fortune)) if ((!enabled) || (!q.fortune))
return null return null
//Load inputs //Load inputs

View File

@@ -62,29 +62,30 @@ export default async function({login, graphql, data, imports, q, queries, accoun
if (_charts === "chartist") { if (_charts === "chartist") {
console.debug(`metrics/compute/${login}/plugins > stargazers > generating charts`) console.debug(`metrics/compute/${login}/plugins > stargazers > generating charts`)
charts = await Promise.all([{data:total, low:total.min, high:total.max}, {data:increments, ref:0, low:increments.min, high:increments.max, sign:true}].map(({data:{dates:set}, high, low, ref, sign = false}) => imports.chartist("line", { charts = await Promise.all([{data:total, low:total.min, high:total.max}, {data:increments, ref:0, low:increments.min, high:increments.max, sign:true}].map(({data:{dates:set}, high, low, ref, sign = false}) => imports.chartist("line", {
width:480 * (1 + data.large), width:480 * (1 + data.large),
height:160, height:160,
showPoint:true, showPoint:true,
axisX:{showGrid:false}, axisX:{showGrid:false},
axisY:{showLabel:false, offset: 20, labelInterpolationFnc:value => imports.format(value, {sign}), high, low, referenceValue: ref}, axisY:{showLabel:false, offset:20, labelInterpolationFnc:value => imports.format(value, {sign}), high, low, referenceValue:ref},
showArea:true, showArea:true,
fullWidth: true, fullWidth:true,
}, { }, {
labels:Object.keys(set).map((date, i, a) => { labels:Object.keys(set).map((date, i, a) => {
const day = date.substring(date.length-2) const day = date.substring(date.length - 2)
if ((i === 0)||((a[i+1])&&(date.substring(0, 7) !== a[i+1].substring(0, 7)))) if ((i === 0) || ((a[i + 1]) && (date.substring(0, 7) !== a[i + 1].substring(0, 7))))
return `${day} ${months[Number(date.substring(5, 7))]}` return `${day} ${months[Number(date.substring(5, 7))]}`
return day return day
}), }),
series:[Object.values(set)], series:[Object.values(set)],
}))) })
data.postscripts.push(`(${function (format) { ))
data.postscripts.push(`(${function(format) {
document.querySelectorAll(".stargazers .chartist").forEach((chart, sign) => { document.querySelectorAll(".stargazers .chartist").forEach((chart, sign) => {
chart.querySelectorAll(".stargazers .chartist .ct-point").forEach(node => { chart.querySelectorAll(".stargazers .chartist .ct-point").forEach(node => {
const [x, y, value] = ["x1", "y1", "ct:value"].map(attribute => node.getAttribute(attribute)) const [x, y, value] = ["x1", "y1", "ct:value"].map(attribute => node.getAttribute(attribute))
const text = document.createElementNS("http://www.w3.org/2000/svg", "text") const text = document.createElementNS("http://www.w3.org/2000/svg", "text")
text.setAttributeNS(null, "x", x) text.setAttributeNS(null, "x", x)
text.setAttributeNS(null, "y", y-5) text.setAttributeNS(null, "y", y - 5)
text.setAttributeNS(null, "class", "ct-post") text.setAttributeNS(null, "class", "ct-post")
text.appendChild(document.createTextNode(format(value, {sign}))) text.appendChild(document.createTextNode(format(value, {sign})))
node.parentNode.append(text) node.parentNode.append(text)