antvis / antvis/F2

line Chart changeData Invalid

Open
#904 2 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://render.alipay.com/p/s/i/?scheme=alipays%3A%2F%2Fplatformapi%2Fstartapp%3FappId%3D2021001156635379%26page%3Dpages%252Findex%252Findex%26enbsv%3D0.1.2006010928.11%26chInfo%3Dch_share__chsub_DingTalkSession](https://render.alipay.com/p/s/i/?scheme=alipays%3A%2F%2Fplatformapi%2Fstartapp%3FappId%3D2021001156635379%26page%3Dpages%252Findex%252Findex%26enbsv%3D0.1.2006010928.11%26chInfo%3Dch_share__chsub_DingTalkSession)

### Steps to reproduce
index.js
```javascript
const wf = require('wefetch');
let chart = null;
const realTimedDataUrl = "https://a.cifm.com/data/getData?code=kamt.rtmin";
const sszs = "https://a.cifm.com/data/getData?code=trends2";
Page({
data: {
data: [],
},
onInitChart(F2, config) {
let data = than.data.data;
chart = new F2.Chart(config);
chart.source(data);
chart.scale('value', {
tickCount: 5
});
chart.render();
return chart;
},

getRealTimedData(needUpdate) {
let data = [], than = this;
const realTimedData = () => wf.get(realTimedDataUrl), sszsData = () => wf.get(sszs);
wf.all([realTimedData(), sszsData()])
.then(res => {
let s2n = res[0].data.data.s2n;
let trends = res[1].data.data.trends;
s2n.forEach((item) => {
let value = item.split(",")[5];
if (value && value !== "-") {
if (value > 0) {
value = Math.abs(value / 10000).toFixed(2);
} else { value = "-" Math.abs(value / 10000).toFixed(2); }
let obj = {};
obj['time'] = item.split(",")[0].split(":")[0] === "9" ? item.split(",")[0] = "09:" item.split(",")[0].split(":")[1] : item.split(",")[0];
obj['name'] = "A";
obj['money'] = value;
trends.forEach((trend) => {
if (trend.split(',')[0].split(" ")[1] == obj['time']) {
obj['name1'] = "B";
obj['index'] = trend.split(',')[2]
data.push(obj);
}
});
}
})
than.setData({
data: data
})
if (needUpdate) {
// fun(data);
chart.repaint();
chart.guide().clear();
chart.changeData(data);
}
})
},

onLoad() {
let than = this;
than.getRealTimedData(false);
setInterval(function () {
than.getRealTimedData(true);
}, 30000)
},
})

```
axml

### What is expected?
data change & Chart update

### What is actually happening?
Data Change , Chart No update

| Environment | Info |
|---|---|
| f2 | 4.0.9 |
| System | Alipay Applet |
| Browser | Alipay Applet |

---
@antv/f2@3.6.3

setInterval Change Data & Change Chart

Contributor guide

Open the contributing guide

Research direction

Start with the changeData flow shown in index.js and reproduce the update behavior in F2 4.0.9 on the Alipay Applet environment using the provided link and data-refresh interval. Compare the result with the reported F2 3.6.3 behavior; done means the chart visibly updates when changeData receives the refreshed data.

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.