diff --git a/web/charts.js b/web/charts.js index ad297dd..2a9e026 100644 --- a/web/charts.js +++ b/web/charts.js @@ -37,6 +37,8 @@ // months:[ym], series:[{key,color,values:{ym:amount}}] function monthlyBars(container, months, series, opts) { opts = opts || {}; + const axisLab = opts.labelFn || (m => window.MT.MONTH_LABEL(m).split(" '")[0]); + const fullLab = opts.labelFn || window.MT.MONTH_LABEL; clear(container); const W = container.clientWidth || 800, H = opts.height || 240; const padL = 52, padR = 12, padT = 14, padB = 26; @@ -61,11 +63,11 @@ const x = gx - totalW / 2 + si * (bw + gap); const y = padT + innerH - h; const r = el('rect', { x, y, width: bw, height: Math.max(0, h), rx: 2, fill: s.color, opacity: 0.92, class: 'mbar' }); - r.addEventListener('mousemove', e => window.MTtip && window.MTtip.raw(e, s.label + ' · ' + window.MT.MONTH_LABEL(m), fmtFull(v), s.color)); + r.addEventListener('mousemove', e => window.MTtip && window.MTtip.raw(e, s.label + ' · ' + fullLab(m), fmtFull(v), s.color)); r.addEventListener('mouseleave', () => window.MTtip && window.MTtip.hide()); svg.appendChild(r); }); - svg.appendChild(el('text', { x: gx, y: H - 8, 'text-anchor': 'middle', class: 'chart-axis' }, window.MT.MONTH_LABEL(m).split(" '")[0])); + svg.appendChild(el('text', { x: gx, y: H - 8, 'text-anchor': 'middle', class: 'chart-axis' }, axisLab(m))); }); container.appendChild(svg); } @@ -73,6 +75,8 @@ // ---------- line / area (cumulative net) ---------- function lineChart(container, months, valuesByMonth, opts) { opts = opts || {}; + const axisLab = opts.labelFn || (m => window.MT.MONTH_LABEL(m).split(" '")[0]); + const fullLab = opts.labelFn || window.MT.MONTH_LABEL; clear(container); const W = container.clientWidth || 800, H = opts.height || 200; const padL = 56, padR = 14, padT = 14, padB = 26; @@ -105,10 +109,10 @@ svg.appendChild(el('path', { d: dPath, fill: 'none', stroke: col, 'stroke-width': 2.4, 'stroke-linejoin': 'round' })); pts.forEach((v, i) => { const dot = el('circle', { cx: x(i), cy: y(v), r: 3.4, fill: cssv('--bg'), stroke: col, 'stroke-width': 2 }); - dot.addEventListener('mousemove', e => window.MTtip && window.MTtip.raw(e, window.MT.MONTH_LABEL(months[i]), 'running ' + fmtFull(v), col)); + dot.addEventListener('mousemove', e => window.MTtip && window.MTtip.raw(e, fullLab(months[i]), 'running ' + fmtFull(v), col)); dot.addEventListener('mouseleave', () => window.MTtip && window.MTtip.hide()); svg.appendChild(dot); - svg.appendChild(el('text', { x: x(i), y: H - 8, 'text-anchor': 'middle', class: 'chart-axis' }, window.MT.MONTH_LABEL(months[i]).split(" '")[0])); + svg.appendChild(el('text', { x: x(i), y: H - 8, 'text-anchor': 'middle', class: 'chart-axis' }, axisLab(months[i]))); }); container.appendChild(svg); } diff --git a/web/dashboard.html b/web/dashboard.html index b64e8d7..965aa7e 100644 --- a/web/dashboard.html +++ b/web/dashboard.html @@ -20,6 +20,11 @@