antvis / antvis/F2

重新设置 colDefs 后, 数据为 null 空时纵坐标消失未显示

Open
#1,142 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8k
Forks
637
PR merge metrics
No merged PRs in 30d

Description

- [x] I have searched the [issues](https://github.com/antvis/f2/issues) of this repository and believe that this is not a duplicate.

### Reproduction link
[https://f2.antv.vision/zh/examples/line/basic#basic](https://f2.antv.vision/zh/examples/line/basic#basic)

### Steps to reproduce
在该 demo 上替换成如下代码, 重新设置 colDefs 后, 纵坐标消失未显示

import F2 from '@antv/f2';

const data = [{
date: '2017-06-05',
value: null
}, {
date: '2017-06-06',
value: null
}, {
date: '2017-07-21',
value: null
}];

const chart = new F2.Chart({
id: 'container',
pixelRatio: window.devicePixelRatio
});

chart.source(data, {});
chart.tooltip({
custom: true,
showXTip: true,
showYTip: true,
snap: true,
crosshairsType: 'xy',
crosshairsStyle: {
lineDash: [ 2 ]
}
});
chart.axis('date', {
label: function label(text, index, total) {
const textCfg = {};
if (index === 0) {
textCfg.textAlign = 'left';
} else if (index === total - 1) {
textCfg.textAlign = 'right';
}
return textCfg;
}
});
chart.line().position('date*value');
chart.render();
chart.source(data, {
value: {
tickCount: 5,
min: 0
},
date: {
type: 'timeCat',
range: [ 0, 1 ],
tickCount: 3
}
});
chart.repaint();

若未重新设置 colDefs 后, 如下代码纵坐标是显示的。

import F2 from '@antv/f2';

const data = [{
date: '2017-06-05',
value: null
}, {
date: '2017-06-06',
value: null
}, {
date: '2017-07-21',
value: null
}];

const chart = new F2.Chart({
id: 'container',
pixelRatio: window.devicePixelRatio
});

chart.source(data, {
value: {
tickCount: 5,
min: 0
},
date: {
type: 'timeCat',
range: [ 0, 1 ],
tickCount: 3
}
});
chart.tooltip({
custom: true,
showXTip: true,
showYTip: true,
snap: true,
crosshairsType: 'xy',
crosshairsStyle: {
lineDash: [ 2 ]
}
});
chart.axis('date', {
label: function label(text, index, total) {
const textCfg = {};
if (index === 0) {
textCfg.textAlign = 'left';
} else if (index === total - 1) {
textCfg.textAlign = 'right';
}
return textCfg;
}
});
chart.line().position('date*value');
chart.render();

| Environment | Info |
|---|---|
| f2 | 3.8.1 |
| System | - |
| Browser | - |

Contributor guide

Open the contributing guide

Research direction

Start with the linked line/basic reproduction and compare the initial chart.source call with the later chart.source and chart.repaint sequence. Confirm that resetting the column definitions with all value fields null preserves the y-axis, then locate the relevant rendering behavior and add a regression test if an existing test entry point covers this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.