We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { Chart } from '@antv/g2';
function findMaxMin(data) { let maxValue = 0; let minValue = 50000; let maxObj = null; let minObj = null; for (const d of data) { if (d.Close > maxValue) { maxValue = d.Close; maxObj = d; } if (d.Close < minValue) { minValue = d.Close; minObj = d; } } return { max: maxObj, min: minObj }; }
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/nintendo.json') .then(res => res.json()) .then(data => { const chart = new Chart({ container: 'container', autoFit: true, height: 500, }); setTimeout(() => {
chart.changeData([ { "Date": "07.01.2016", "Close": 120.19
}, { "Date": "08.01.2016", "Close": 121.157 }, { "Date": "11.01.2016", "Close": 117 }, { "Date": "12.01.2016", "Close": 111.487 }, { "Date": "13.01.2016", "Close": 800 }]); }, 2000); chart.option("scrollbar", { // animate: false, categorySize: 100 /* 横轴间距设置 */ });
chart.data(data); chart.scale({ Date: { tickCount: 10 }, Close: { nice: true, } }); chart.axis('Date', { label: { formatter: text => { const dataStrings = text.split('.'); return dataStrings[2] + '-' + dataStrings[1] + '-' + dataStrings[0]; } } }); chart.line().position('Date*Close'); // annotation const { min, max } = findMaxMin(data); chart.annotation().dataMarker({ top: true, position: [max.Date, max.Close], text: { content: '全部峰值:' + max.Close, }, line: { length: 30, } }); chart.annotation().dataMarker({ top: true, position: [min.Date, min.Close], text: { content: '全部谷值:' + min.Close, }, line: { length: 50, } }); chart.render();
});
The text was updated successfully, but these errors were encountered:
最大值是800,但图表纵依然展示的是之前的值, https://g2.antv.vision/zh/examples/case/line#line7 https://codesandbox.io/s/huo-qu-scrollbar-shi-jian-hui-diao-forked-r8dqgt?file=/index.ts:1993-2077
Sorry, something went wrong.
Sorry, due to problems in the program's architecture design, we are unable to effectively fix the issues. But it fixed in G2 5.0, you can have a try.
No branches or pull requests
import { Chart } from '@antv/g2';
function findMaxMin(data) {
let maxValue = 0;
let minValue = 50000;
let maxObj = null;
let minObj = null;
for (const d of data) {
if (d.Close > maxValue) {
maxValue = d.Close;
maxObj = d;
}
if (d.Close < minValue) {
minValue = d.Close;
minObj = d;
}
}
return { max: maxObj, min: minObj };
}
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/nintendo.json')
.then(res => res.json())
.then(data => {
const chart = new Chart({
container: 'container',
autoFit: true,
height: 500,
});
setTimeout(() => {
},
{
"Date": "08.01.2016",
"Close": 121.157
},
{
"Date": "11.01.2016",
"Close": 117
},
{
"Date": "12.01.2016",
"Close": 111.487
},
{
"Date": "13.01.2016",
"Close": 800
}]);
}, 2000);
chart.option("scrollbar", {
// animate: false,
categorySize: 100 /* 横轴间距设置 */
});
});
The text was updated successfully, but these errors were encountered: