gpt4 book ai didi

javascript - 桑基 : Show dynamically text on x-axis

转载 作者:行者123 更新时间:2023-12-03 00:53:25 25 4
gpt4 key购买 nike

如何根据过渡在 x 轴上显示动态文本。在我的第一个案例中,我得到两个转换(足球 -> 篮球和篮球 -> Gerard),因此我将显示两个标签,如下所示

但是当我们只得到一个转换时,如何处理 x 轴上的标签。我需要的是当只有一个转换时,应该只出现一个标签。在下面的情况下,应该出现半决赛标签。

Highcharts.chart('container', {

chart: {
showAxes: true
},
title: {
text: ''
},
xAxis: {
type: "category",
categories: ['Semi-Final','Final Phase'],
max: 2,
labels: {
x: 10,
y: 30,
},
lineColor: 'transparent',
tickLength: 0
},
yAxis: {
visible: false
},
series: [{
keys: ['from', 'to', 'weight'],
data: [
['Football', 'Cricket', 20 ],
],
type: 'sankey',
}]
});

最佳答案

显示的标签数量取决于轴极值。您可以使 max 属性依赖于数据数量:

    events: {
load: function() {
var max = this.series[0].nodeColumns.length - 2;

this.xAxis[0].update({
max: max
})

}
}

现场演示:https://jsfiddle.net/BlackLabel/7s5h41qr/

API:https://api.highcharts.com/highcharts/xAxis.max

关于javascript - 桑基 : Show dynamically text on x-axis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52949002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com