我正在尝试使用 highcharts 在 php 中创建图表。我想制作一个条形图显示项目 startdate - endate 显示完成百分比。我有所有 3 个来自数据库的值。我想在图表上显示的第四个值是使用当前日期,如果项目落后于进度条,则在条形图中显示。
以下是我所拥有的
var date = new Date();
//console.log(date.getFullYear() + " " + (date.getMonth()+1) + " " + date.getDay() );
$('#container').highcharts({
chart: {
type: 'spline'
},
title: {
text: 'Snow depth in the Vikjafjellet mountain, Norway'
},
subtitle: {
text: 'An example of irregular time data in Highcharts JS'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%e. %b',
year: '%b'
}
},
yAxis: {
title: {
text: 'Percent %'
},
min: 0,
max: 100
},
tooltip: {
formatter: function() {
var start = new Date(2013,5,11),
end = new Date(2013,11,11),
today = new Date();
return Math.round(100-((end - start) * 100 ) / today) + '%' ;//'<b>'+ this.series.name +'</b><br/>'+ Highcharts.dateFormat('%e. %b', this.x) +': '+ this.y +' m';
}
},
series: [{
name: 'Fastnet OffshWest Shetland',
// Define the data points. All series have a dummy year
// of 1970/71 in order to be compared on the same x axis. Note
// that in JavaScript, months start at 0 for January, 1 for February etc.
data: [
[Date.UTC(2013, 5, 11), 0 ],
[Date.UTC(date.getFullYear(), (date.getMonth()+1), date.getDay()), 30 ],
[Date.UTC(2013, 11, 11), 100 ]
]
}]
});
我一直在修改折线图。我想把它变成一个条形图,显示每个项目的开始日期结束日期。和当前完成的百分比。我还想计算并显示应该使用当前日期完成的预测百分比。