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)
- 饼图中如何在数据更新时不产生动画效果
- 柱状图如何多次进行分组 HOT 1
- render 两个行为有延迟, 不同步
- 怎么设置 elementHighlight 的背景色呢?
- 设置图表tooltip相交圆圈为不同颜色空心圆?
- 自定义图例的 itemMarker 为圆角
- 5.0 中 的pie缓冲动效
- Morph 动画前需要判断节点是否存在 HOT 2
- G2 4.x版本,热力图展示问题,当数值为0时或者数值中的最小值时,会出现没有颜色的情况,期望通过设置最大最小透明度来控制 HOT 6
- 我在本地不能正常打开g2的图表示例 HOT 2
- 3D图表缩放问题 HOT 1
- interval重新设置数据报错 HOT 3
- 在 "@antv/g2": "~4.2.10" 版本使用 Chart 时,请问如何取消 legend 的默认点击行为,即不想点击图例后,对应的折线消失,图例只用作显示
- 复合图下多个Y轴的实现问题 HOT 1
- 使用 vite 的 build.rollupOptions.output.manualChunks 配置自定义块分割,当 @antv/g2 和 @antv/g6 不在同一个块中时,打包后运行时报错。
- v5 版本的g2 如何嵌入 g6 HOT 1
- V5 版本如何实现十字辅助线 HOT 1
- 【v5】legend 筛选 快速点击两下,会出现筛选错误
- 双轴的网格对齐线可以共用一份吗? HOT 1
- 怎么设置柱状图柱子之间的距离为固定距离?paddingOuter 是什么意思?为什么范围是【0,1】? HOT 5
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.