Kendo UI Starting Point
Kendo UI starter fiddle for test cases.
by TJ VanToll
HTML
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.default.min.css">
<script src="https://rawgithub.com/telerik/platform-friends-hybrid/master/platform-friends-hybrid/scripts/lib/everlive.all.min.js"></script>
<div id="locations-chart"></div>
<div id="appetizer-chart"></div>
<div id="ratings-chart"></div>
JavaScript
new Everlive({ apiKey: "eVKxNui85A6TopjR" });
function displayResults( data ) {
buildLocationsChart( data.result );
buildAppetizerChart( data.result );
buildRatingsChart( data.result );
};
function buildLocationsChart( result ) {
var north = _.where( result, { location: "north" } ).length,
south = _.where( result, { location: "south" } ).length,
east = _.where( result, { location: "east" } ).length,
west = _.where( result, { location: "west" } ).length;
$( "#locations-chart" ).kendoChart({
title: { text: "Survey Results by Location" },
seriesDefault: { type: "bar" },
series: [
{
name: "Amount",
data: [ north, south, east, west ]
}
],
categoryAxis: {
categories: [ "North", "South", "East", "West" ]
},
valueAxis: {
title: { text: "Number of surveys" }
},
legend: {
visible: false
}
});
};
function buildAppetizerChart( result ) {
var yes = _.where( result, { appetizer: true } ).length,
no = result.length - yes;
$( "#appetizer-chart" ).kendoChart({
title: { text: "Appetizers" },
series: [{
type: "pie",
data: [
{ category: "Yes", value: yes },
{ category: "No", value: no }
]
}],
seriesDefaults: {
labels: {
visible: true,
template: "#= category #: #= value #"
}
}
});
};
function average( items ) {
var sum = 0;
_.each( items, function( item ) {
sum += parseInt( item.rating, 10 );
});
return sum / items.length;
};
function buildRatingsChart( result ) {
var north = _.where( result, { location: "north" } ),
south = _.where( result, { location: "south" } ),
east = _.where( result, { location: "east" } ),
west =...