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)
- Axis 轴 labelAutoRotate 旋转异常 HOT 1
- 增加 label position 策略:exceedAdjust HOT 11
- g2能根据配置直接生成base64用于浏览器的打印吗 HOT 3
- G2 5.1.18中柱状图X轴数据过多时(200条),轴刻度间距怎么设置大点 HOT 5
- antv/g2 5.0 移除了getCanvas等方法后怎么同步拿到画布内容 HOT 1
- G2 5.1.18 柱状图elementSelect中background的样式修改 HOT 1
- 雷达图点击图例后,线条会飘到外面 HOT 1
- 柱线组合图,坐标轴转置之后,tooltip显示缺失 HOT 1
- brushXHighlight属性样式设置会导致一部分不符合预期高亮 HOT 1
- changeData更新数据。图例没有实时更新 HOT 3
- 当 encode.series 指定了某一个值时, tooltip.items 自定义 name 会失效
- link mark 设置 lineWidth 的时候,箭头显示不对
- overflowHide 对于标签在图形上放置不下的时候,随机隐藏标签。 HOT 4
- Tooltip、Brush 等交互在 shadow dom 内失效 HOT 3
- 柱线组合图,坐标轴转置之后,tooltip显示缺失
- chart.facetRect()分面不支持仪表盘
- 设置x轴刻度数无效
- 官方示例水波图NaN% HOT 1
- 答疑labelAutoHide使用
- 开启缩略轴,数据标签被裁切 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.