Apex 图表时间轴 - 数据标签与工具提示和标题不同步
Apex Charts Timeline - Datalabels not syncro with tooltip and title
我们正在使用 ApexCharts 时间线。
我们使用系列来显示项目持续时间。
一切似乎都很好,但我们有一个宽度数据标签的问题。
数据标签与工具提示和标题不同步。
第一个系列还可以...
series: [
{
name: "AMISOC",
data: [
{
x: "Gestion des mesures d'intégration",
y: [new Date("2020-06").getTime(), new Date("2021-06").getTime()],
},
{
x: "Portefeuilles + validations - Stabilisation",
y: [new Date("2020-06").getTime(), new Date("2021-06").getTime()],
},
{
x: "Stat OFS AMIG - lot 3",
y: [new Date("2020-06").getTime(), new Date("2021-04").getTime()],
},
{
x: "Test 3 VZA",
y: [new Date("2021-01").getTime(), new Date("2022-03").getTime()],
}
]
},
{
name: "FE",
data: [
{
x: "Trafic des paiements (lot 2)",
y: [new Date("2020-06").getTime(), new Date("2021-06").getTime()],
}
]
},
{
name: "IT",
data: [
{
x: "Migration Windows et Outils bureautique",
y: [new Date("2021-03").getTime(), new Date("2021-06").getTime()],
},
{
x: "Upgrade technique Infrastucture 2021",
y: [new Date("2021-01").getTime(), new Date("2021-12").getTime()],
}
]
},
...
],
serie OK
但是标题后面没有跟相关的标题名。
在工具提示中可以,但在数据标签中不行。
有人看出我们哪里做错了吗?
serie NOT SYNC
我确实找到了可行的解决方案:
我替换这段代码
formatter: function (val, opt) {
return opt.w.globals.labels[opt.dataPointIndex];
},
通过这个代码
formatter: function(val,obj) {
return obj.w.config.series[obj.seriesIndex].data[obj.dataPointIndex].x;
},
我们正在使用 ApexCharts 时间线。 我们使用系列来显示项目持续时间。 一切似乎都很好,但我们有一个宽度数据标签的问题。
数据标签与工具提示和标题不同步。
第一个系列还可以...
series: [
{
name: "AMISOC",
data: [
{
x: "Gestion des mesures d'intégration",
y: [new Date("2020-06").getTime(), new Date("2021-06").getTime()],
},
{
x: "Portefeuilles + validations - Stabilisation",
y: [new Date("2020-06").getTime(), new Date("2021-06").getTime()],
},
{
x: "Stat OFS AMIG - lot 3",
y: [new Date("2020-06").getTime(), new Date("2021-04").getTime()],
},
{
x: "Test 3 VZA",
y: [new Date("2021-01").getTime(), new Date("2022-03").getTime()],
}
]
},
{
name: "FE",
data: [
{
x: "Trafic des paiements (lot 2)",
y: [new Date("2020-06").getTime(), new Date("2021-06").getTime()],
}
]
},
{
name: "IT",
data: [
{
x: "Migration Windows et Outils bureautique",
y: [new Date("2021-03").getTime(), new Date("2021-06").getTime()],
},
{
x: "Upgrade technique Infrastucture 2021",
y: [new Date("2021-01").getTime(), new Date("2021-12").getTime()],
}
]
},
...
],
serie OK
但是标题后面没有跟相关的标题名。 在工具提示中可以,但在数据标签中不行。
有人看出我们哪里做错了吗?
serie NOT SYNC
我确实找到了可行的解决方案:
我替换这段代码
formatter: function (val, opt) {
return opt.w.globals.labels[opt.dataPointIndex];
},
通过这个代码
formatter: function(val,obj) {
return obj.w.config.series[obj.seriesIndex].data[obj.dataPointIndex].x;
},