I am trying a plot a highchart with single series and add some points which are marked in different style on the same line.
For example :
I am trying to plot a week (date & time) on x-axis and number of available hours in that week(5 days).
Available Hours :
Reminders :
I am trying to plot a time series line chart and trying to add a marker for the reminder to the existing line chart at random places which has a tooltip with some information linked to it.
I tried to plot the line chart with 2 series but not able to achieve the expected output. https://jsfiddle.net/2vtyrc9q/3/
[JSFiddle Demo][1]
You can preprocess your data and calculate y
values for the second series:
var stages = [
[0, 10],
[2, 30],
[5, 15],
[10, 12]
],
checkpoints = [1, 3, 4, 7],
j = 1,
i = 0;
for (i; i < checkpoints.length; i++) {
if (checkpoints[i] < stages[j][0]) {
checkpoints[i] = [checkpoints[i], calculateY(i, j)];
} else {
for (j; j < stages.length; j++) {
if (checkpoints[i] < stages[j][0]) {
checkpoints[i] = [checkpoints[i], calculateY(i, j)];
break;
}
}
}
}
function calculateY(i, j) {
var difference,
step;
difference = stages[j][1] - stages[j - 1][1];
step = difference / (stages[j][0] - stages[j - 1][0]);
return stages[j - 1][1] + step * (checkpoints[i] - stages[j - 1][0]);
}
Highcharts.chart('container', {
series: [{
data: stages
}, {
type: 'scatter',
data: checkpoints
}]
});
Live demo: http://jsfiddle.net/BlackLabel/83ankjpf/