mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 11:01:20 +01:00
fix: acp graph labels, dont use indices
This commit is contained in:
@@ -159,28 +159,33 @@ function setupGraphs(callback) {
|
|||||||
Chart.defaults.plugins.tooltip.enabled = false;
|
Chart.defaults.plugins.tooltip.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const t = translator.Translator.create();
|
const keys = [
|
||||||
Promise.all([
|
'[[admin/dashboard:graphs.page-views]]',
|
||||||
t.translateKey('admin/dashboard:graphs.page-views', []),
|
'[[admin/dashboard:graphs.page-views-registered]]',
|
||||||
t.translateKey('admin/dashboard:graphs.page-views-registered', []),
|
'[[admin/dashboard:graphs.page-views-guest]]',
|
||||||
t.translateKey('admin/dashboard:graphs.page-views-guest', []),
|
'[[admin/dashboard:graphs.page-views-bot]]',
|
||||||
t.translateKey('admin/dashboard:graphs.page-views-bot', []),
|
'[[admin/dashboard:graphs.page-views-ap]]',
|
||||||
t.translateKey('admin/dashboard:graphs.page-views-ap', []),
|
'[[admin/dashboard:graphs.unique-visitors]]',
|
||||||
t.translateKey('admin/dashboard:graphs.unique-visitors', []),
|
'[[admin/dashboard:graphs.registered-users]]',
|
||||||
t.translateKey('admin/dashboard:graphs.registered-users', []),
|
'[[admin/dashboard:graphs.guest-users]]',
|
||||||
t.translateKey('admin/dashboard:graphs.guest-users', []),
|
'[[admin/dashboard:on-categories]]',
|
||||||
t.translateKey('admin/dashboard:on-categories', []),
|
'[[admin/dashboard:reading-posts]]',
|
||||||
t.translateKey('admin/dashboard:reading-posts', []),
|
'[[admin/dashboard:browsing-topics]]',
|
||||||
t.translateKey('admin/dashboard:browsing-topics', []),
|
'[[admin/dashboard:recent]]',
|
||||||
t.translateKey('admin/dashboard:recent', []),
|
'[[admin/dashboard:unread]]',
|
||||||
t.translateKey('admin/dashboard:unread', []),
|
];
|
||||||
]).then(function (translations) {
|
const graphLabels = {};
|
||||||
|
translator.translateKeys(keys, config.acpLang).then(function (translations) {
|
||||||
|
keys.forEach(function (key, index) {
|
||||||
|
graphLabels[key.split(':')[1].slice(0, -2)] = translations[index];
|
||||||
|
});
|
||||||
|
|
||||||
const tension = 0.25;
|
const tension = 0.25;
|
||||||
const data = {
|
const data = {
|
||||||
labels: trafficLabels,
|
labels: trafficLabels,
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: translations[0],
|
label: graphLabels['graphs.page-views'],
|
||||||
fill: 'origin',
|
fill: 'origin',
|
||||||
tension: tension,
|
tension: tension,
|
||||||
backgroundColor: 'rgba(220,220,220,0.2)',
|
backgroundColor: 'rgba(220,220,220,0.2)',
|
||||||
@@ -192,7 +197,7 @@ function setupGraphs(callback) {
|
|||||||
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: translations[1],
|
label: graphLabels['graphs.page-views-registered'],
|
||||||
fill: 'origin',
|
fill: 'origin',
|
||||||
tension: tension,
|
tension: tension,
|
||||||
backgroundColor: '#ab464233',
|
backgroundColor: '#ab464233',
|
||||||
@@ -204,7 +209,7 @@ function setupGraphs(callback) {
|
|||||||
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: translations[2],
|
label: graphLabels['graphs.page-views-guest'],
|
||||||
fill: 'origin',
|
fill: 'origin',
|
||||||
tension: tension,
|
tension: tension,
|
||||||
backgroundColor: '#ba8baf33',
|
backgroundColor: '#ba8baf33',
|
||||||
@@ -216,7 +221,7 @@ function setupGraphs(callback) {
|
|||||||
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: translations[3],
|
label: graphLabels['graphs.page-views-bot'],
|
||||||
fill: 'origin',
|
fill: 'origin',
|
||||||
tension: tension,
|
tension: tension,
|
||||||
backgroundColor: '#f7ca8833',
|
backgroundColor: '#f7ca8833',
|
||||||
@@ -228,7 +233,7 @@ function setupGraphs(callback) {
|
|||||||
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: translations[4],
|
label: graphLabels['graphs.page-views-ap'],
|
||||||
fill: 'origin',
|
fill: 'origin',
|
||||||
tension: tension,
|
tension: tension,
|
||||||
backgroundColor: 'rgba(151,187,205,0.2)',
|
backgroundColor: 'rgba(151,187,205,0.2)',
|
||||||
@@ -240,7 +245,7 @@ function setupGraphs(callback) {
|
|||||||
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: translations[5],
|
label: graphLabels['graphs.unique-visitors'],
|
||||||
fill: 'origin',
|
fill: 'origin',
|
||||||
tension: tension,
|
tension: tension,
|
||||||
backgroundColor: 'rgba(151,187,205,0.2)',
|
backgroundColor: 'rgba(151,187,205,0.2)',
|
||||||
@@ -274,7 +279,7 @@ function setupGraphs(callback) {
|
|||||||
type: 'linear',
|
type: 'linear',
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: translations[0],
|
text: graphLabels['graphs.page-views'],
|
||||||
},
|
},
|
||||||
beginAtZero: true,
|
beginAtZero: true,
|
||||||
},
|
},
|
||||||
@@ -283,7 +288,7 @@ function setupGraphs(callback) {
|
|||||||
type: 'linear',
|
type: 'linear',
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: translations[5],
|
text: graphLabels['graphs.unique-visitors'],
|
||||||
},
|
},
|
||||||
beginAtZero: true,
|
beginAtZero: true,
|
||||||
},
|
},
|
||||||
@@ -311,7 +316,7 @@ function setupGraphs(callback) {
|
|||||||
graphs.registered = new Chart(registeredCtx, {
|
graphs.registered = new Chart(registeredCtx, {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: {
|
data: {
|
||||||
labels: translations.slice(5, 7),
|
labels: [graphLabels['graphs.registered-users'], graphLabels['graphs.guest-users']],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: [1, 1],
|
data: [1, 1],
|
||||||
backgroundColor: ['#F7464A', '#46BFBD'],
|
backgroundColor: ['#F7464A', '#46BFBD'],
|
||||||
@@ -324,7 +329,9 @@ function setupGraphs(callback) {
|
|||||||
graphs.presence = new Chart(presenceCtx, {
|
graphs.presence = new Chart(presenceCtx, {
|
||||||
type: 'doughnut',
|
type: 'doughnut',
|
||||||
data: {
|
data: {
|
||||||
labels: translations.slice(7, 12),
|
labels: [
|
||||||
|
graphLabels['on-categories'], graphLabels['reading-posts'], graphLabels['browsing-topics'], graphLabels['recent'], graphLabels['unread'],
|
||||||
|
],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: [1, 1, 1, 1, 1],
|
data: [1, 1, 1, 1, 1],
|
||||||
backgroundColor: ['#F7464A', '#46BFBD', '#FDB45C', '#949FB1', '#9FB194'],
|
backgroundColor: ['#F7464A', '#46BFBD', '#FDB45C', '#949FB1', '#9FB194'],
|
||||||
|
|||||||
Reference in New Issue
Block a user