Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Charts: a phone line chart's last two dates no longer overlap (31m) (#925)
Oleksandr Ivanchenkod99a300be4c2
diff --git a/frontend/src/components/results/Chart.tsx b/frontend/src/components/results/Chart.tsxindex 6de96866..45dd8cdb 100644--- a/frontend/src/components/results/Chart.tsx+++ b/frontend/src/components/results/Chart.tsx@@ -162,6 +162,9 @@ export const Chart: React.FC<RendererProps<ChartBlock>> = ({ block }) => {// Bars: every category is named when its band fits a shortened label (5 bars at 390 px do); lines thin out.const MIN_BAND_LABEL = 28;const labelEvery = isBar ? Math.max(1, Math.ceil(MIN_BAND_LABEL / xStep)) : Math.max(1, Math.ceil(n / (narrow ? 4 : 10)));+ const lastX = n - 1;+ const gapX = lastX % labelEvery;+ const showLastX = gapX === 0 || gapX * 2 >= labelEvery;const labelChars = isBar ? Math.max(3, Math.floor((xStep * labelEvery - 4) / 6)) : 10;const activePoint = active ? block.points[active.pointIdx] : null;@@ -238,10 +241,10 @@ export const Chart: React.FC<RendererProps<ChartBlock>> = ({ block }) => {<line x1={PAD.left} x2={PAD.left} y1={PAD.top} y2={HEIGHT - PAD.bottom} className="stroke-zinc-700" strokeWidth={1} /><line x1={PAD.left} x2={WIDTH - PAD.right} y1={HEIGHT - PAD.bottom} y2={HEIGHT - PAD.bottom} className="stroke-zinc-700" strokeWidth={1} />- {/* X labels, thinned out so 390 px never clips. */}+ {/* X labels, thinned out so 390 px never clips. The last point is labelled when it sits at least half a+ step off the cadence; the regular label just before it then goes, so the two never overlap. */}{block.points.map((p, i) => {- const gap = (n - 1) % labelEvery;- if (i % labelEvery !== 0 && !(i === n - 1 && gap * 2 >= labelEvery)) return null;+ if (i === lastX ? !showLastX : i % labelEvery !== 0 || (gapX > 0 && showLastX && i === lastX - gapX)) return null;return (<textkey={p.id}diff --git a/frontend/tests/resultsChart.test.mjs b/frontend/tests/resultsChart.test.mjsindex debf76ec..fab7d683 100644--- a/frontend/tests/resultsChart.test.mjs+++ b/frontend/tests/resultsChart.test.mjs@@ -174,3 +174,59 @@ for (const width of [300, 270]) {}});}++// 31m chart-last-label-fits: on a phone, a line chart's off-cadence last label printed right after the regular one+// ("2026-10-1926…"). Labels render at the card's measured width, so stub the measurement for narrow and wide.+async function xLabelsAt(block, width) {+ const cw = Object.getOwnPropertyDescriptor(dom.window.HTMLElement.prototype, 'clientWidth');+ const hadRO = 'ResizeObserver' in globalThis;+ Object.defineProperty(dom.window.HTMLElement.prototype, 'clientWidth', { configurable: true, get: () => width });+ globalThis.ResizeObserver = class { observe() {} disconnect() {} };+ try {+ const host = await mount(block);+ const xs = block.points.map((p) => p.x);+ return [...host.querySelectorAll('svg[role="img"] text.fill-zinc-400')].map((t) => xs.indexOf(t.textContent));+ } finally {+ if (cw) Object.defineProperty(dom.window.HTMLElement.prototype, 'clientWidth', cw);+ else delete dom.window.HTMLElement.prototype.clientWidth;+ if (!hadRO) delete globalThis.ResizeObserver;+ }+}+const weekly = (n, kind = 'line') => ({+ ...lineBlock(),+ id: `b-weekly-${kind}-${n}`,+ chart_kind: kind,+ x: { label: 'Week', kind: kind === 'line' ? 'time' : 'category' },+ series: [{ key: 'orders', label: 'Orders', unit: null }],+ points: Array.from({ length: n }, (_, i) => {+ const d = new Date(Date.UTC(2026, 8, 7 + 7 * i)).toISOString().slice(0, 10);+ return { id: `w${i}`, x: d, cells: [String(10 + i)], values: [10 + i] };+ }),+});++test('a line chart labels the last point and never prints two dates on top of each other (31m)', async () => {+ const expected = {+ narrow: { 5: [0, 2, 4], 7: [0, 2, 4, 6], 8: [0, 2, 4, 7], 9: [0, 3, 8], 12: [0, 3, 6, 11] },+ wide: { 5: [0, 1, 2, 3, 4], 7: [0, 1, 2, 3, 4, 5, 6], 8: [0, 1, 2, 3, 4, 5, 6, 7], 9: [0, 1, 2, 3, 4, 5, 6, 7, 8], 12: [0, 2, 4, 6, 8, 11] },+ };+ for (const [size, width] of [['narrow', 358], ['wide', 640]]) {+ for (const n of [5, 7, 8, 9, 12]) {+ const at = await xLabelsAt(weekly(n), width);+ const what = `${size} n=${n}: ${at.join(',')}`;+ assert.deepEqual(at, expected[size][n], what);+ assert.equal(at.at(-1), n - 1, `last point labelled, ${what}`);+ assert.ok(!at.includes(-1), `every label is a whole date, ${what}`);+ // Thinned labels keep at least 2 steps between neighbours; unthinned (wide, n <= 10) keep every point.+ const minGap = Math.min(...at.slice(1).map((v, k) => v - at[k]));+ if (size === 'narrow' || n > 10) assert.ok(minGap >= 2, `neighbours >= 2 steps apart, ${what}`);+ else assert.equal(at.length, n, `wide n<=10 labels every point, ${what}`);+ }+ }+});++test('bar labels stay as they were: 5 to 9 bars at a phone width name every bar (31m)', async () => {+ for (const n of [5, 7, 8, 9]) {+ const at = await xLabelsAt(weekly(n, 'bar'), 358);+ assert.equal(at.length, n, `n=${n}`);+ }+});