feat(坐标轴): 支持显示纵轴单位
All checks were successful
Package component / package (push) Successful in 4m18s

This commit is contained in:
李启源
2026-08-18 10:06:36 +08:00
parent 5c71c28429
commit 233b9b0aa2
10 changed files with 78 additions and 12 deletions

View File

@@ -158,6 +158,12 @@ describe('WaveformChart', () => {
expect(paths[0].attributes('data-series-name')).toBe('BT2_2M')
const yAxisLabels = wrapper.findAll('.waveform-chart__y-axis-label')
expect(yAxisLabels.map((label) => label.text())).toEqual(['BT2_2M', 'BT1_2M'])
expect(
wrapper
.findAll('.waveform-chart__axis--y .tick text')
.map((label) => label.text())
.some((label) => label.includes('(T)')),
).toBe(true)
expect(yAxisLabels.map((label) => label.attributes('fill'))).toEqual(['#0960bd', '#ff7f0e'])
const labelX = Number(
yAxisLabels[0].attributes('transform')?.match(/^translate\(([-\d.]+),/)?.[1],

View File

@@ -15,6 +15,7 @@ describe('WaveformChart', () => {
{
trackId: 'shared-frame',
name: '普通量程',
unit: 'V',
data: {
kind: 'points',
points: [
@@ -26,6 +27,7 @@ describe('WaveformChart', () => {
{
trackId: 'shared-frame',
name: '大量程',
unit: 'A',
data: {
kind: 'points',
points: [
@@ -37,6 +39,7 @@ describe('WaveformChart', () => {
{
trackId: 'shared-frame',
name: '小量程',
unit: 'T',
data: {
kind: 'points',
points: [
@@ -57,7 +60,11 @@ describe('WaveformChart', () => {
.map((label) => label.text())
.filter((label) => label.startsWith('E')),
),
).toEqual([[], [expect.stringMatching(/^E\+03 /)], [expect.stringMatching(/^E-04 /)]])
).toEqual([
[],
[expect.stringMatching(/^E\+03 \(A\) /)],
[expect.stringMatching(/^E-04 \(T\) /)],
])
})
it('reprojects annotations with the Y axis assigned to their series', async () => {