我有一个甘特,我只想在特定的行上绘制一个带区。在下面的示例中,它显示在每一行上。
它可以是一个乐队情节或类似的东西(例如:SVG,酒吧,...)。只要可以控制容易的位置与开始和结束的时间,因为我会有一些超过30行在不同的位置。
这是一个fiddle
还有我的代码:
// THE CHART
Highcharts.ganttChart('container', {
title: {
text: 'Gantt Chart with Progress Indicators'
},
yAxis: {
categories: ['1', '2']
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
verticalAlign: "top",
format: "{point.custom.label}"
}
}
},
xAxis: {
plotBands: [{
color: '#B3D1AE', // Color value
from: Date.UTC(2014, 10, 21), // Start of the plot band
to: Date.UTC(2014, 10, 22) // End of the plot band
}],
},
series: [{
type: 'line',
zoneAxis: 'x',
zones: [{
value: Date.UTC(2014, 10, 20)
}, {
dashStyle: 'dot',
value: Date.UTC(2014, 10, 25)
}],
data: [{
y: 0,
x: Date.UTC(2014, 10, 18),
custom: {
label: 1
}
}, {
y: 0,
x: Date.UTC(2014, 10, 25, 12),
custom: {
label: 2
}
}]
}, {
name: 'Project 1',
type: 'line',
zoneAxis: 'x',
zones: [{
value: Date.UTC(2014, 10, 28)
}, {
dashStyle: 'dot',
value: Date.UTC(2014, 10, 29)
}],
data: [{
x: Date.UTC(2014, 10, 25, 16),
y: 0,
custom: {
label: 3
}
}, {
x: Date.UTC(2014, 10, 29),
y: 0,
custom: {
label: 4
}
}]
}, {
type: 'line',
zoneAxis: 'x',
data: [{
x: Date.UTC(2014, 10, 25, 16),
y: 1,
custom: {
label: 3
}
}, {
x: Date.UTC(2014, 10, 29),
y: 1,
custom: {
label: 4
}
}]
}]
});
1条答案
按热度按时间ibrsph3r1#
您可以使用
SVG.Renderer
来绘制“plotBands”,并使用axis.toPixels()
方法来控制位置。范例:
演示:https://jsfiddle.net/BlackLabel/qbo8Lmy6/
API参考资料:https://api.highcharts.com/class-reference/Highcharts.SVGRenderer https://api.highcharts.com/class-reference/Highcharts.Axis#toPixels