chore: code formatting
This commit is contained in:
@@ -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
|
||||||
@@ -42,4 +42,4 @@ export default async function({q, data, imports, account}, {enabled = false} = {
|
|||||||
catch (error) {
|
catch (error) {
|
||||||
throw {error:{message:"An error occured", instance:error}}
|
throw {error:{message:"An error occured", instance:error}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user