feat(plugins/stargazers): add plugin_stargazers_charts
This commit is contained in:
@@ -7,7 +7,7 @@ export default async function({login, graphql, data, imports, q, queries, accoun
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
let {"charts.type": _charts, worldmap: _worldmap, "worldmap.sample": _worldmap_sample} = imports.metadata.plugins.stargazers.inputs({data, account, q})
|
let {charts: _charts, "charts.type": _charts_type, worldmap: _worldmap, "worldmap.sample": _worldmap_sample} = imports.metadata.plugins.stargazers.inputs({data, account, q})
|
||||||
|
|
||||||
//Retrieve stargazers from graphql api
|
//Retrieve stargazers from graphql api
|
||||||
console.debug(`metrics/compute/${login}/plugins > stargazers > querying api`)
|
console.debug(`metrics/compute/${login}/plugins > stargazers > querying api`)
|
||||||
@@ -60,8 +60,8 @@ export default async function({login, graphql, data, imports, q, queries, accoun
|
|||||||
const months = ["", "Jan.", "Feb.", "Mar.", "Apr.", "May", "June", "July", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."]
|
const months = ["", "Jan.", "Feb.", "Mar.", "Apr.", "May", "June", "July", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."]
|
||||||
|
|
||||||
//Generating charts
|
//Generating charts
|
||||||
let charts = null
|
let charts = _charts ? true : null
|
||||||
if ((_charts === "chartist") && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
|
if ((_charts_type === "chartist") && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
|
||||||
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}) =>
|
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", {
|
imports.chartist("line", {
|
||||||
|
|||||||
@@ -21,6 +21,14 @@ inputs:
|
|||||||
type: boolean
|
type: boolean
|
||||||
default: no
|
default: no
|
||||||
|
|
||||||
|
plugin_stargazers_charts:
|
||||||
|
description: |
|
||||||
|
Charts
|
||||||
|
|
||||||
|
It includes total number of stargazers evolution, along with the number of new stars per day over the last two weeks.
|
||||||
|
type: boolean
|
||||||
|
default: yes
|
||||||
|
|
||||||
plugin_stargazers_charts_type:
|
plugin_stargazers_charts_type:
|
||||||
description: |
|
description: |
|
||||||
Charts display type
|
Charts display type
|
||||||
|
|||||||
@@ -10,10 +10,11 @@
|
|||||||
<%= plugins.stargazers.error.message %>
|
<%= plugins.stargazers.error.message %>
|
||||||
</div>
|
</div>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
|
<% if (plugins.stargazers.charts) { %>
|
||||||
<div class="row margin-bottom">
|
<div class="row margin-bottom">
|
||||||
<section class="column chart chartist">
|
<section class="column chart chartist">
|
||||||
<h3>Total stargazers</h3>
|
<h3>Total stargazers</h3>
|
||||||
<% if (plugins.stargazers.charts) { %>
|
<% if (Array.isArray(plugins.stargazers.charts)) { %>
|
||||||
<%- plugins.stargazers.charts[0] %>
|
<%- plugins.stargazers.charts[0] %>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<div class="chart-bars">
|
<div class="chart-bars">
|
||||||
@@ -32,7 +33,7 @@
|
|||||||
</section>
|
</section>
|
||||||
<section class="column chart chartist">
|
<section class="column chart chartist">
|
||||||
<h3>New stargazers per day</h3>
|
<h3>New stargazers per day</h3>
|
||||||
<% if (plugins.stargazers.charts) { %>
|
<% if (Array.isArray(plugins.stargazers.charts)) { %>
|
||||||
<%- plugins.stargazers.charts[1] %>
|
<%- plugins.stargazers.charts[1] %>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<div class="chart-bars">
|
<div class="chart-bars">
|
||||||
@@ -50,6 +51,7 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
<% } %>
|
||||||
<% if (plugins.stargazers.worldmap) { %>
|
<% if (plugins.stargazers.worldmap) { %>
|
||||||
<div class="row margin-bottom">
|
<div class="row margin-bottom">
|
||||||
<h3 class="margin-lr-auto">Stargazers origins</h3>
|
<h3 class="margin-lr-auto">Stargazers origins</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user