Plot chronological events on top of your trending data to learn what decisions, product changes or macro events affected your numbers. You give it the analytics data and named events, it shows you how the two play together.
Built by @jfeldstein. Wraps (and thus requires) HighCharts. Originally announced on jfeldstein.com.
This code is free. Go nuts.
- Have jQuery and Highcharts already installed in your project.
- Download jquery.epochchart.js into your project.
- Have fun!
// One line
$('#chart').epochchart(line, markers [, options]);
or
// Multiple lines
$('#chart').epochchart(lines, markers [, options]);
{
// Change the marker used to denote events, or link to a custom image.
marker: url(marker.png),
// Overwrite the options we pass into Highcharts here.
// Use anything from http://api.highcharts.com/highcharts
highchartsOpts: { ... },
// Change the date formats in tooltips and the x-axis by entering a
// Highcharts.dateFormat-compatible formatting string.
// See: http://api.highcharts.com/highcharts#Highcharts.dateFormat()
dateFormat: '...',
// Reposition the fixed tooltip. Pixel values from the top left.
tooltip: {x: 30, y: 10}
}
<div id="oneline"></div>
<script>
// Dates as unix timestamps
var line = {
name: "The Line",
data: [[1259114255000, 2], [1259200655000, 2.25], [1259287055000, 5]]
};
var markers = [[1259200655000, "Hired the new sales guy."]];
$('#oneline').epochchart(line, markers);
</script>
Which looks like:
<div id="chart"></div>
<script>
// Dates as unix timestamps
var data1 = [[1259114255000, 2], [1259287055000, 5]];
var data2 = [[1259114255000, 5], [1259287055000, 2]];
var lines = [{
name: "Line 1",
data: data1
},{
name: "Line 2",
data: data2
}]
var markers = [[1259200655000, "The intersection"]];
$('#chart').epochchart(lines, markers);
</script>
Which looks like:
<div id="chart"></div>
<script>
// Anything from the HighCharts API: http://api.highcharts.com/highcharts
var opts = {
highchartsOpts: {
plotOptions: {
spline: {
color: '#FF0000'
}
}
}
};
var line = {
name: "A Single Line",
data: [[1259114255000, 2], [1259287055000, 5]]
};
var markers = [[1259200655000, "On the up!"]];
$('#chart').epochchart(lines, markers, opts);
</script>
Which looks like:
coffee --compile --watch jquery.epochchart.coffee
(thanks to jashkenas)