我在multichart(multilinechart)
中遇到问题nvd3工具提示。我的XAxis
标签是JAN,FEB,MAR... DEC.
,但是当我在图表中鼠标悬停时,它会显示0,1,2,3.. 11
作为工具提示标题。但我需要显示JAN,FEB.. DEC
而不是索引。这是我的图表选项代码,
{
"chart": {
"type": "multiChart",
"height": 400,
"interpolate": "linear",
"showLegend": false,
"margin": {
"top": 50,
"right": 100,
"bottom": 60,
"left": 100
},
"reduceXTicks": false,
"useVoronoi": false,
"useInteractiveGuideline": true,
"duration": 500,
"xAxis": {
"axisLabel": "MONTHLY",
"tickPadding": 10,
"tickSize": 1,
"tickValues": [
0,
1,
2,
3,
4,
5,
6
]
},
"yAxis1": {
"axisLabel": "Left",
"tickPadding": 10
},
"yAxis2": {
"axisLabel": "Right",
"width": 60,
"tickPadding": 10
},
"yDomain1": [
0,
5
],
"yDomain2": [
0,
100
]
}
}
这是图像中的问题(需要显示FEB,但它显示1), 这是第二个(需要显示MAR,但它显示2)
请帮助确定问题,
先谢谢。
答案 0 :(得分:1)
您可以尝试使用方法interactiveLayer.tooltip.headerFormatter
来修改标题的标签,例如:
chart.interactiveLayer.tooltip.headerFormatter(d => {
if (typeof d === 'string') return d
})