Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit ·
4affc7e
1
Parent(s): b42aabd
improved axis formatting
Browse files
app/src/content/embeds/d3-benchmark-comparison.html
CHANGED
|
@@ -274,7 +274,7 @@
|
|
| 274 |
|
| 275 |
function stepsToTokens(step) { return step * TOKENS_PER_STEP; }
|
| 276 |
function formatTokens(tokens) {
|
| 277 |
-
if (tokens >= 1e9) return d3.format('.
|
| 278 |
if (tokens >= 1e6) return d3.format('.1f')(tokens / 1e6) + 'M';
|
| 279 |
return d3.format(',')(tokens);
|
| 280 |
}
|
|
@@ -445,7 +445,7 @@
|
|
| 445 |
// X axis
|
| 446 |
gRoot.selectAll('.axis-x').data([0]).join('g').attr('class', 'axes axis-x')
|
| 447 |
.attr('transform', `translate(0,${innerHeight})`)
|
| 448 |
-
.call(d3.axisBottom(x).ticks(5).tickFormat(d3.format('.
|
| 449 |
.call(g => {
|
| 450 |
g.selectAll('text').attr('fill', 'var(--tick-color)').style('font-size', '11px');
|
| 451 |
g.selectAll('path, line').attr('stroke', 'var(--axis-color)');
|
|
@@ -588,7 +588,7 @@
|
|
| 588 |
|
| 589 |
// Y axis
|
| 590 |
gRoot.selectAll('.axis-y').data([0]).join('g').attr('class', 'axes axis-y')
|
| 591 |
-
.call(d3.axisLeft(y).ticks(6).tickFormat(d3.format('.
|
| 592 |
.call(g => {
|
| 593 |
g.selectAll('text').attr('fill', 'var(--tick-color)').style('font-size', '11px');
|
| 594 |
g.selectAll('path, line').attr('stroke', 'var(--axis-color)');
|
|
|
|
| 274 |
|
| 275 |
function stepsToTokens(step) { return step * TOKENS_PER_STEP; }
|
| 276 |
function formatTokens(tokens) {
|
| 277 |
+
if (tokens >= 1e9) return d3.format('.1f')(tokens / 1e9) + 'B';
|
| 278 |
if (tokens >= 1e6) return d3.format('.1f')(tokens / 1e6) + 'M';
|
| 279 |
return d3.format(',')(tokens);
|
| 280 |
}
|
|
|
|
| 445 |
// X axis
|
| 446 |
gRoot.selectAll('.axis-x').data([0]).join('g').attr('class', 'axes axis-x')
|
| 447 |
.attr('transform', `translate(0,${innerHeight})`)
|
| 448 |
+
.call(d3.axisBottom(x).ticks(5).tickFormat(d3.format('.2f')).tickSizeOuter(0))
|
| 449 |
.call(g => {
|
| 450 |
g.selectAll('text').attr('fill', 'var(--tick-color)').style('font-size', '11px');
|
| 451 |
g.selectAll('path, line').attr('stroke', 'var(--axis-color)');
|
|
|
|
| 588 |
|
| 589 |
// Y axis
|
| 590 |
gRoot.selectAll('.axis-y').data([0]).join('g').attr('class', 'axes axis-y')
|
| 591 |
+
.call(d3.axisLeft(y).ticks(6).tickFormat(d3.format('.2f')).tickSizeOuter(0))
|
| 592 |
.call(g => {
|
| 593 |
g.selectAll('text').attr('fill', 'var(--tick-color)').style('font-size', '11px');
|
| 594 |
g.selectAll('path, line').attr('stroke', 'var(--axis-color)');
|