Comments (1)
恩,是不是你调用 chart.changeData() 的时候传入的是 JSON 数组,而你之前绘制的时候,有对数据做过处理,传入的是 Frame 结构?
官网实例: https://g2.alipay.com/demo/04-bar/clustered-stacked-bar.html
/ / 更新数据
setTimeout(function() {
var newData = [{"State":"AL","Under 5 Years":454546,"5 to 13 Years":56354634,"14 to 17 Years":34663,"18 to 24 Years":450818,"25 to 44 Years":1231572,"45 to 64 Years":1215966,"65 Years and Over":641667},{"State":"AK","Under 5 Years":52083,"5 to 13 Years":85640,"14 to 17 Years":42153,"18 to 24 Years":74257,"25 to 44 Years":198724,"45 to 64 Years":183159,"65 Years and Over":50277},{"State":"AZ","Under 5 Years":515910,"5 to 13 Years":828669,"14 to 17 Years":362642,"18 to 24 Years":601943,"25 to 44 Years":1804762,"45 to 64 Years":1523681,"65 Years and Over":862573},{"State":"AR","Under 5 Years":202070,"5 to 13 Years":343207,"14 to 17 Years":157204,"18 to 24 Years":264160,"25 to 44 Years":754420,"45 to 64 Years":727124,"65 Years and Over":407205},{"State":"CA","Under 5 Years":2704659,"5 to 13 Years":4499890,"14 to 17 Years":2159981,"18 to 24 Years":3853788,"25 to 44 Years":10604510,"45 to 64 Years":8819342,"65 Years and Over":4114496},{"State":"CO","Under 5 Years":358280,"5 to 13 Years":587154,"14 to 17 Years":261701,"18 to 24 Years":466194,"25 to 44 Years":1464939,"45 to 64 Years":1290094,"65 Years and Over":511094},{"State":"CT","Under 5 Years":211637,"5 to 13 Years":403658,"14 to 17 Years":196918,"18 to 24 Years":325110,"25 to 44 Years":916955,"45 to 64 Years":968967,"65 Years and Over":478007}];
var Frame = G2.Frame;
var frame = new Frame(newData);
frame = Frame.combinColumns(frame,['Under 5 Years', '5 to 13 Years', '14 to 17 Years', '18 to 24 Years', '25 to 44 Years', '45 to 64 Years', '65 Years and Over'],'population', 'age', 'State');
frame.addCol('type', function(obj) {
var key = obj.age;
var type;
if (key === 'Under 5 Years' || key === '5 to 13 Years' || key === '14 to 17 Years') {
type = 'a';
} else if (key === '18 to 24 Years') {
type = 'b';
} else if (key === '25 to 44 Years') {
type = 'c';
} else {
type = 'd';
}
return type;
});
chart.changeData(frame);
}, 3000);
from g2.
Related Issues (20)
- 标题(Title)设置不生效。 HOT 2
- [v5]仪表盘:底部间距很大
- vue3引用g2报错index.esm.js:617 Uncaught TypeError: Cannot read properties of undefined (reading 'font') HOT 5
- g2的tooltip在安卓10的webview中报错 HOT 3
- # Element Cannot Update When Mapper Updated
- 如何通过Spec的方式声明多个View? HOT 2
- antv里面依赖lodash会有安全问题
- 【v5】使用官方文档代码报错 HOT 1
- 【V5】axia 轴线标题如何实现位置偏移无法自定义位置吗?
- Tooltip is not displayed for the second view. HOT 5
- 在第二个view上无法展示tooltip <Tooltip is not displayed on the second view> HOT 1
- g2plot折线图平滑度如何修改 HOT 1
- 使用facetRect() 做横向排列的对比直方图时,从第二个直方图起无法去掉Y轴label,而且Color 标题不能取消
- 配置slider的formatter后,sparkline不再显示
- 【V5】 折线图 缺少 encode('shape', 'vhv') 的样式
- 水波图显示问题5.x版本 HOT 2
- 2.5D柱状图tooltip不显示 HOT 2
- 水波图无法显示出来 HOT 4
- 面积图,图表数据全部为null时,如何不画线 HOT 1
- G2折线图卡死 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from g2.