mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 10:55:55 +01:00
chore(demo): move to right directory
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
const attrCounts = await api.runOnBackend(() => {
|
||||
return api.sql.getRows(`
|
||||
SELECT
|
||||
name, COUNT(*) AS count
|
||||
FROM attributes
|
||||
WHERE isDeleted = 0
|
||||
GROUP BY name
|
||||
ORDER BY count DESC`);
|
||||
});
|
||||
|
||||
renderPieChart(attrCounts.length <= 10 ? attrCounts : attrCounts.splice(0, 10));
|
||||
renderTable(attrCounts);
|
||||
@@ -0,0 +1,45 @@
|
||||
module.exports = data => {
|
||||
const ctx = api.$container.find('.stats-canvas')[0].getContext("2d");
|
||||
|
||||
const myPieChart = new Chart(ctx, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
datasets: [{
|
||||
data: data.map(nc => nc.count),
|
||||
backgroundColor: ['#3366CC','#DC3912','#FF9900','#109618','#990099','#3B3EAC','#0099C6','#DD4477','#66AA00','#B82E2E','#316395','#994499','#22AA99','#AAAA11','#6633CC','#E67300','#8B0707','#329262','#5574A6','#3B3EAC'],
|
||||
datalabels: {
|
||||
anchor: 'end'
|
||||
}
|
||||
}],
|
||||
labels: data.map(nc => nc.name)
|
||||
},
|
||||
options: {
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
plugins: {
|
||||
datalabels: {
|
||||
backgroundColor: function(context) {
|
||||
return context.dataset.backgroundColor;
|
||||
},
|
||||
borderColor: 'white',
|
||||
borderRadius: 25,
|
||||
borderWidth: 2,
|
||||
color: 'white',
|
||||
display: function(context) {
|
||||
var dataset = context.dataset;
|
||||
var count = dataset.data.length;
|
||||
var value = dataset.data[context.dataIndex];
|
||||
return value > count * 1.5;
|
||||
},
|
||||
font: {
|
||||
weight: 'bold'
|
||||
},
|
||||
formatter: function(value, context) {
|
||||
return context.chart.data.labels[context.dataIndex] + ": " + Math.round(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../../../../../../../../style.css">
|
||||
<base target="_parent">
|
||||
<title data-trilium-title>chart.js</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<h1 data-trilium-h1>chart.js</h1>
|
||||
|
||||
<div class="ck-content">
|
||||
<p>This is a clone of a note. Go to its <a href="../../../../../Weight%20Tracker/Implementation/JS%20code/chart.js">primary location</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../../../../../../../../../style.css">
|
||||
<base target="_parent">
|
||||
<title data-trilium-title>chart.js</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<h1 data-trilium-h1>chart.js</h1>
|
||||
|
||||
<div class="ck-content">
|
||||
<p>This is a clone of a note. Go to its <a href="../../../../../../Weight%20Tracker/Implementation/JS%20code/chart.js">primary location</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
module.exports = counts => {
|
||||
const $statsTable = api.$container.find('.stats-table');
|
||||
|
||||
addRow('total', counts.reduce((acc, cur) => acc + cur.count, 0));
|
||||
|
||||
for (const count of counts) {
|
||||
addRow(count.name, count.count);
|
||||
}
|
||||
|
||||
function addRow(name, count) {
|
||||
$statsTable.append(
|
||||
$("<tr>")
|
||||
.append($("<td>").text(name))
|
||||
.append($("<td>").text(count))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user