Skip to content

Instantly share code, notes, and snippets.

@shaohua
Created January 14, 2014 03:34
Show Gist options
  • Select an option

  • Save shaohua/8412587 to your computer and use it in GitHub Desktop.

Select an option

Save shaohua/8412587 to your computer and use it in GitHub Desktop.
keen showLineChart
showLineChart: function(){
Keen.onChartsReady(function(){
//Find the amount of money made from purchases each day for the last 7 days
//only count the users that that are over 21 years old.
var mySeries = new Keen.Series("purchases", {
analysisType: "sum",
targetProperty: "total_price",
timeframe: "previous_7_days",
interval: "daily"
});
mySeries.addFilter("user.age", "gt", 21);
//Draw a line chart in a <div/> with an ID of "purchases"
var myLineChart = new Keen.LineChart(mySeries, {
height: 500,
width: 200,
lineWidth: 5,
color: "red",
backgroundColor: "transparent",
title: "Purchases over Previous 7 Days",
showLegend: false
});
myLineChart.draw(document.getElementById("purchases"));
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment