Comments (7)
hi, you can declare formatter
callback function for your tooltip title's data attribute, as follows:
chart.source(data,{ // 列定义
'type': {
// this will affect legend、tooltip and axis.
formatter: function (value) {
if (value == 1) {
return '警告';
}
return '错误';
}
}
});
from g2.
the scale formatter will affect legend, tooltip and axis. It can't only format the tooltip or calculate with other field data。
In G2 4.x,TooltipCfg.title set a string will make some format but not flexible, I hope a function type so.
from g2.
Hi simaQ,
Thank you for your reply.
I tried to integrate the piece of code you gave me, but still it doesn't work. If I put a console.log within the callback function, it's never called.
from g2.
Oh okay my bad. I didn't understand that here 'type' actually means the axis name.
In my dataset my axis were named 'x' and 'y'.
Everything is working perfectly, thank you very much. :-)
from g2.
Now this prop is removed in v2, correct? How can I achieve the same behaviour?
from g2.
chart.scale('type', {
// this will affect legend、tooltip and axis.
formatter: function (value) {
if (value == 1) {
return '警告';
}
return '错误';
}
});
from g2.
@Me-Momo sorry, it seems that I am talking about g2plot, which is a higher abstraction level of g2, correct?
Anyway, this behaviour does not allow you to have one axis values to be dependent on the others, I mean:
chart.scale('type', {
// this will affect legend、tooltip and axis.
// I can't do smth like: (value == 1 && date == X), due to I do not have date value
formatter: function (value) {
if (value == 1) {
return '警告';
}
return '错误';
}
});
Thanks!
from g2.
Related Issues (20)
- 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
- 开启缩略轴(slider)后,数据标签(label)不响应缩略轴变化
- 在shadow dom里,并且在多层容器下,tooltip位置出现偏离 HOT 1
- X轴是否支持二级,目前看示例都只有一级
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.