gpt4 book ai didi

javascript - Highcharts 甘特图 (JS) - 删除 x 轴中的日期

转载 作者:行者123 更新时间:2023-11-30 14:17:48 28 4
gpt4 key购买 nike

我在 JavaScript 中使用 Highcharts 甘特图。

我想停用表格顶部的标题,这对我来说没有用。截图中的红色矩形: https://files.normanfeltz.fr/files/2018-11-13_13-53-13.png

经过多次搜索和多次阅读文档,我没有找到如何做到这一点。

JavaScript 代码:

var today = new Date();

today.setUTCHours(0);
today.setUTCMinutes(0);
today.setUTCSeconds(0);
today.setUTCMilliseconds(0);
today = today.getTime();

var day = 1000 * 60 * 60 * 24;
var map = Highcharts.map;
var dateFormat = Highcharts.dateFormat;

var controles = [
{
name: "SERIE 1",
color: 'pink',
operations: []
},
{
name: "SERIE 2",
color: 'green',
operations: [
{
name: "LIGNE 1",
from: today + 1000 * (6 * 3600 + 00 * 60 + 30),
to: today + 1000 * (6 * 3600 + 10 * 60 + 53)
},
{
name: "LIGNE 1",
from: today + 1000 * (13 * 3600 + 49 * 60 + 44),
to: today + 1000 * (14 * 3600 + 3 * 60 + 14)
}
]
},
{
name: "SERIE 3",
color: 'orange',
operations: [
{
name: "LIGNE 2",
from: today + 1000 * (6 * 3600 + 10 * 60 + 47),
to: today + 1000 * (6 * 3600 + 45 * 60 + 57)
}
]
},
{
name: "SERIE 4",
color: 'red',
operations: [
{
name: "LIGNE 1",
from: today + 1000 * (9 * 3600 + 22 * 60 + 12),
to: today + 1000 * (9 * 3600 + 31 * 60 + 01)
}
]
},
{
name: "SERIE 5",
color: 'yellow',
operations: [
{
name: "LIGNE 3",
from: today + 1000 * (14 * 3600 + 14 * 60 + 56),
to: today + 1000 * (14 * 3600 + 46 * 60 + 38)
},
{
name: "LIGNE 1",
from: today + 1000 * (6 * 3600 + 10 * 60 + 54),
to: today + 1000 * (9 * 3600 + 1 * 60 + 15)
},
{
name: "LIGNE 1",
from: today + 1000 * (9 * 3600 + 31 * 60 + 11),
to: today + 1000 * (9 * 3600 + 53 * 60 + 32)
},
{
name: "LIGNE 1",
from: today + 1000 * (10 * 3600 + 16 * 60 + 56),
to: today + 1000 * (11 * 3600 + 30 * 60 + 55)
},
{
name: "LIGNE 1",
from: today + 1000 * (12 * 3600 + 2 * 60 + 10),
to: today + 1000 * (13 * 3600 + 49 * 60 + 43)
},
{
name: "LIGNE 4",
from: today + 1000 * (9 * 3600 + 53 * 60 + 29),
to: today + 1000 * (10 * 3600 + 19 * 60 + 39)
},
{
name: "LIGNE 5",
from: today + 1000 * (14 * 3600 + 47 * 60 + 17),
to: today + 1000 * (15 * 3600 + 32 * 60 + 7)
},
{
name: "LIGNE 5",
from: today + 1000 * (15 * 3600 + 49 * 60 + 05),
to: today + 1000 * (16 * 3600 + 9 * 60 + 37)
}
]
},
{
name: "SERIE 6",
color: 'gray',
operations: [
{
name: "LIGNE 1",
from: today + 1000 * (9 * 3600 + 1 * 60 + 16),
to: today + 1000 * (9 * 3600 + 22 * 60 + 11)
},
{
name: "LIGNE 1",
from: today + 1000 * (11 * 3600 + 30 * 60 + 56),
to: today + 1000 * (12 * 3600 + 2 * 60 + 9)
}
]
},
{
name: "SERIE 7",
color: 'blue',
operations: [
{
name: "LIGNE 1",
from: today + 1000 * (9 * 3600 + 31 * 60 + 02),
to: today + 1000 * (9 * 3600 + 31 * 60 + 10)
},
]
},
{
name: "SERIE 8",
color: 'purple',
operations: []
}
];

var lines = [];

var series = controles.map(function (controle, i) {
var data = controle.operations.map(function (operation) {
if (lines.indexOf(operation.name) == -1) {lines.push(operation.name)}
return {
id: 'operation-' + controle.name + "-" + lines.indexOf(operation.name),
name: operation.name,
color: controle.color,
start: operation.from,
end: operation.to,
y: lines.indexOf(operation.name)
};
});
return {
name: controle.name,
data: data
};
});

Highcharts.ganttChart('container', {
credits: {
enabled: false
},
legend: {
enabled: true,
squareSymbol: false,
symbolRadius: 0,
},
series: series,
xAxis: {
tickInterval: 3600 * 1000,
gridLineWidth: 1
},
yAxis: {
type: 'category',
grid: {
columns: [{
categories: map(lines, function (line) {
return line;
})
}]
}
}
});

完整代码:https://jsfiddle.net/h72odjqu/

诺曼·费尔茨

最佳答案

Highcharts Gantt 添加了额外的 xAxis,您可以通过以下方式隐藏它:

xAxis: [{
tickInterval: 3600 * 1000,
gridLineWidth: 1
}, {
visible: false,
opposite: false
}]

现场演示: https://jsfiddle.net/BlackLabel/dmcgyv78/

关于javascript - Highcharts 甘特图 (JS) - 删除 x 轴中的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53265645/

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