claude-usage-dashboard 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -20,13 +20,21 @@ export function renderModelDistribution(container, data) {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const containerWidth = container.clientWidth;
|
|
24
|
+
const size = Math.min(containerWidth * 0.45, 200);
|
|
24
25
|
const radius = size / 2;
|
|
25
26
|
const innerRadius = radius * 0.55;
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
+
const isNarrow = containerWidth < 280;
|
|
29
|
+
const wrapper = el.append('div')
|
|
30
|
+
.style('display', 'flex')
|
|
31
|
+
.style('flex-direction', isNarrow ? 'column' : 'row')
|
|
32
|
+
.style('align-items', 'center')
|
|
33
|
+
.style('gap', isNarrow ? '8px' : '20px');
|
|
28
34
|
|
|
29
|
-
const svg = wrapper.append('svg')
|
|
35
|
+
const svg = wrapper.append('svg')
|
|
36
|
+
.attr('width', size).attr('height', size)
|
|
37
|
+
.style('flex-shrink', '0')
|
|
30
38
|
.append('g').attr('transform', `translate(${size / 2},${size / 2})`);
|
|
31
39
|
|
|
32
40
|
const total = d3.sum(data.models, d => d.total_tokens);
|
|
@@ -15,7 +15,18 @@ export function renderProjectDistribution(container, data) {
|
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// Measure longest project name to set left margin dynamically
|
|
19
|
+
const tempSvg = el.append('svg').style('position', 'absolute').style('visibility', 'hidden');
|
|
20
|
+
const tempText = tempSvg.append('text').style('font-size', '12px');
|
|
21
|
+
let maxLabelWidth = 120;
|
|
22
|
+
for (const p of data.projects) {
|
|
23
|
+
tempText.text(p.name);
|
|
24
|
+
maxLabelWidth = Math.max(maxLabelWidth, tempText.node().getComputedTextLength());
|
|
25
|
+
}
|
|
26
|
+
tempSvg.remove();
|
|
27
|
+
const leftMargin = Math.ceil(maxLabelWidth) + 16;
|
|
28
|
+
|
|
29
|
+
const margin = { top: 10, right: 360, bottom: 10, left: leftMargin };
|
|
19
30
|
const barHeight = 24;
|
|
20
31
|
const gap = 8;
|
|
21
32
|
const height = data.projects.length * (barHeight + gap) + margin.top + margin.bottom;
|