我有下面的图表,其中我有一条“范围”线和“完成的总努力”线以及它们每个的虚线趋势线。(由于 Highcharts 不支持趋势线,我只是用虚线连接数据的第一个和最后一个点。)我正在使用这个插件来绘制趋势线。
目标是扩展虚线趋势线并找到这两条线将在右侧相遇的日期(x 轴值)(如果可能且距离不太远)。我怎样才能做到这一点?
代码:http: //jsfiddle.net/AjJZD/6/
$(function () {
var data1 = [
[Date.UTC(2013, 4, 28), 40],
[Date.UTC(2013, 5, 26), 40],
[Date.UTC(2013, 5, 29), 48],
[Date.UTC(2013, 7, 21), 48]
];
var data2 = [
[Date.UTC(2013, 4, 28), 0],
[Date.UTC(2013, 5, 10), 20],
[Date.UTC(2013, 5, 19), 22],
[Date.UTC(2013, 5, 20), 24],
[Date.UTC(2013, 5, 30), 26],
[Date.UTC(2013, 6, 1), 28],
[Date.UTC(2013, 7, 21), 30]
];
var chart_linear = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
colors: ['#912120', '#C00402', '#115DA9', '#115DA9'],
xAxis: {
type: 'datetime',
gridLineWidth: 1,
gridLineDashStyle: 'shortdot'
},
yAxis: {
min: 0,
gridLineDashStyle: 'shortdot'
},
plotOptions: {
series: {
marker: {
symbol: 'circle'
}
}
},
series: [{
name: 'Scope',
data: data1
}, {
name: 'Scope Change Trend',
type: 'line',
marker: {
enabled: false
},
dashStyle: 'longDash',
data: (function () {
return fitData(data1).data;
})()
}, {
name: 'Total Effort Done',
data: data2
}, {
name: 'Velocity',
type: 'line',
marker: {
enabled: false
},
dashStyle: 'longDash',
data: (function () {
return fitData(data2).data;
})()
}]
});
});