Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish to npm

on:
push:
tags:
- '[0-9]*.[0-9]*.[0-9]*'

permissions:
id-token: write
contents: read

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# npm trusted publishing (OIDC) requires npm CLI >= 11.5.1, which ships with Node 24
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Publish to NPM
run: |
if [[ "${{ github.ref_name }}" == *"-beta"* ]]; then
npm publish --access public --tag beta
else
npm publish --access public
fi
10 changes: 8 additions & 2 deletions __tests__/charts/utils/createSvg.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ describe('createSvg', () => {
const svg = selection.node() as HTMLElement;

expect(svg.style.margin).toBe('0px 4px');
expect(svg.style.transform).toBe('translate(0px, 0.125em)');
});

it('should make the container a centering inline-flex box', () => {
createSvg(testContainer, 100, 200);

expect(testContainer.style.display).toBe('inline-flex');
expect(testContainer.style.alignItems).toBe('center');
});

it('should create SVG in proper namespace', () => {
Expand Down Expand Up @@ -129,6 +135,6 @@ describe('createSvg', () => {
const svg2 = selection2.node() as HTMLElement;

expect(svg1.style.margin).toBe(svg2.style.margin);
expect(svg1.style.transform).toBe(svg2.style.transform);
expect(svg1.style.display).toBe(svg2.style.display);
});
});
14 changes: 7 additions & 7 deletions __tests__/snapshot/text-register-plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$180.3k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$180.3k</span></span
></span
><span> relative to the same time last quarter. They are up </span
><span
Expand All @@ -182,7 +182,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$106.1k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$106.1k</span></span
></span
><span> relative to the same time last year. They are </span
><span
Expand Down Expand Up @@ -284,7 +284,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$50.6k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$50.6k</span></span
></span
><span>)</span>
</li>
Expand Down Expand Up @@ -321,7 +321,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$86.2k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$86.2k</span></span
></span
><span>)</span>
</li>
Expand Down Expand Up @@ -359,7 +359,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$160.1k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$160.1k</span></span
></span
><span>)</span>
</li>
Expand Down Expand Up @@ -426,7 +426,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>17</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>17</span></span
></span
><span> relative to the same time last quarter (</span
><span
Expand Down Expand Up @@ -508,7 +508,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-negative"
><span><span>-</span>$2k</span></span
><span style="display: inline-flex; align-items: center"><span>-</span>$2k</span></span
></span
><span> relative to the same time last quarter (</span
><span
Expand Down
14 changes: 7 additions & 7 deletions __tests__/snapshot/text-simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$180.3k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$180.3k</span></span
></span
><span> relative to the same time last quarter. They are up </span
><span
Expand All @@ -182,7 +182,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$106.1k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$106.1k</span></span
></span
><span> relative to the same time last year. They are </span
><span
Expand Down Expand Up @@ -283,7 +283,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$50.6k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$50.6k</span></span
></span
><span>)</span>
</li>
Expand Down Expand Up @@ -319,7 +319,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$86.2k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$86.2k</span></span
></span
><span>)</span>
</li>
Expand Down Expand Up @@ -356,7 +356,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>$160.1k</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>$160.1k</span></span
></span
><span>)</span>
</li>
Expand Down Expand Up @@ -423,7 +423,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-positive"
><span><span>+</span>17</span></span
><span style="display: inline-flex; align-items: center"><span>+</span>17</span></span
></span
><span> relative to the same time last quarter (</span
><span
Expand Down Expand Up @@ -505,7 +505,7 @@
margin: 0px 2px;
"
class="t8-value t8-delta_value t8-value-negative"
><span><span>-</span>$2k</span></span
><span style="display: inline-flex; align-items: center"><span>-</span>$2k</span></span
></span
><span> relative to the same time last quarter (</span
><span
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/t8",
"version": "0.3.0",
"version": "0.3.1",
"description": "T8 is a text visualization solution for unstructured data within the AntV technology stack, and it is a declarative T8 markdown syntax that can be used to describe the content of data interpretation reports.",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
allowBuilds:
esbuild: set this to true or false
3 changes: 1 addition & 2 deletions src/charts/line/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { getElementFontSize } from '../../utils';
import { ChartRenderFunction } from '../types';
import { createSvg, scaleLinear, line, area } from '../utils';
import { createSvg, scaleLinear, line, area, SCALE_ADJUST } from '../utils';

const LINE_STROKE_COLOR = '#5B8FF9';
const LINE_FILL_COLOR = '#5B8FF9';
const LINEAR_FILL_COLOR_ID = 'wsc-line-fill';
const SCALE_ADJUST = 2;

/**
* Line chart configuration
Expand Down
3 changes: 1 addition & 2 deletions src/charts/rank/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { createSvg, Scale, scaleLinear, Selection } from '../utils';
import { createSvg, Scale, scaleLinear, Selection, SCALE_ADJUST } from '../utils';
import { getElementFontSize } from '../../utils';
import { ChartRenderFunction } from '../types';

// Chart colors
const BAR_FILL_COLOR = '#5B8FF9';
const SCALE_ADJUST = 2;

/**
* Highlight message interface
Expand Down
2 changes: 1 addition & 1 deletion src/charts/utils/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const SCALE_ADJUST = 2;
export const SCALE_ADJUST = 0;
export const WIDTH_MARGIN = 0.5;
export const LINE_STROKE_COLOR = '#5B8FF9';
export const HIGHLIGHT_COLOR = '#FF8C00';
Expand Down
10 changes: 8 additions & 2 deletions src/charts/utils/createSvg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ import { Selection } from './selection';
export const createSvg = (container: Element, width: number, height: number): Selection => {
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.style.margin = '0px 4px';
svg.style.transform = 'translate(0px, 0.125em)';
svg.style.display = 'inline-block';

// The container is a wrapper span between the outer inline-flex phrase span and this svg.
// Make it a centering flex box as well, so the svg is centered against the text instead of
// sitting on the baseline of its own line box.
if (container instanceof HTMLElement) {
container.style.display = 'inline-flex';
container.style.alignItems = 'center';
}

svg.setAttribute('height', String(height));
svg.setAttribute('width', String(width));
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/utils/createInlineDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const createInlineDocument = (
position: 'suffix' | 'prefix' = 'suffix',
): HTMLSpanElement => {
const span = document.createElement('span');
span.style.display = 'inline-flex';
span.style.alignItems = 'center';

const originalElementSpan = value;
span.textContent = originalElementSpan;
Expand Down
Loading