Skip to content

Resolves #6: Add a dangle example based on the demo #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions example/css/bootstrap-responsive.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions example/css/bootstrap.min.css

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions example/css/dangle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* axis line test */
.axis path {
fill: none;
stroke:#000;
stroke-width: 1.5px;
shape-rendering: crispEdges;
}

/* axis tick marks */
.axis line {
fill: none;
stroke: #000;
stroke-width: 1.1px;
shape-rendering: crispEdges;
}

/* controls the axis text */
.axis text {
fill: #333;
stroke: none;
shape-rendering: crispEdges;
font-size: 16px;
}

/* controls the area */
.area.fill {
fill: #e5f3f9;
fill-opacity: 0.2;
}

/* controls the top line in area */
.area.line {
fill: none;
stroke: #058dc7;
stroke-width: 6.0px;
}

.area.line.points {
fill: #058dc7;
stroke: #fff;
stroke-width: 3.0px;
}

/* histogram styles */
.histo.rect { fill: #058dc7; }

.bar.rect {
fill: #058dc7;
stroke: none;
}

.bar.text {
fill: #000;
stroke: none;
font-size: 12px;
}
123 changes: 123 additions & 0 deletions example/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<!DOCTYPE html>
<html lang="en" ng-app="demo">
<head>
<title>Demo</title>

<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="css/dangle.css">

<!-- Google analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
_gaq.push(['_require', 'inpage_linkid', pluginUrl]);
_gaq.push(['_setAccount', 'UA-12991832-4']);
_gaq.push(['_setDomainName', 'fullscale.co']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>

<body ng-controller="DemoCtrl">

<div class="container-fluid">
<div class="row-fluid">
<div>
<h4>dangle.js Examples</h4>
<p>Tested on the latest version of Chrome, Safari, and Firefox. The examples will also adapt to mobile devices
(tested on Nexus 7 (tablet) and HTC One X (phone), both running Chrome. This runs completely in the browser
so just view source to see how it works. Graphs are interactive and animated. Clicking on any graph will modify
the data, causing everything to update.<p>

<p>dangle is a set of <a href="http://angularjs.org/">AngularJS</a> directives that provide common <a href="http://d3js.org/">D3</a> visualizations for <a href="http://www.elasticsearch.org/">elasticsearch</a>.</p>

<a href="/dangle">Documentation</a>

<hr>

</div>
<div class="span10">
<div class="row-fluid">
<div><strong>Date Histogram Example</strong></div>
<div class="span10" style="height:200px">
<fs:date-histo
duration="750"
interval="month"
on-click="filterSearchA"
bind="results.facets.Times"
/>
</div>
</div>

<hr>

<div class="row-fluid">
<div><strong>Bar Chart Example</strong></div>
<div class="span10" style="height:200px">
<fs:bar
width="900"
height="175"
duration="750"
on-click="filterSearchA"
bind="results.facets.Product"
/>
</div>
</div>

<hr>

<div class="row-fluid">
<div><strong>Pie &amp; Donut Chart Example</strong></div>
<div class="span5" style="height:350px">
<fs:donut
outer-radius="200"
inner-radius="75"
duration="750"
on-click="filterSearchA"
bind="results.facets.Product" />
</div>

<div class="span2" style="height:200px;">
<fs:pie
outer-radius="100"
on-click="filterSearchA"
bind="results.facets.Sex" />
</div>
</div>

<hr>

<div class="row-fluid">
<div><strong>Area Chart Example</strong></div>
<div class="span10" style="height:200px">
<fs:area
bind="results.facets.Times"
duration="750"
interpolate="true"
on-click="filterSearchA" />
</div>
</div>
</div>
</div>

</div>

<!-- Load scripts -->
<script src="js/vendor/angular.min.js"</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/vendor/d3.min.js"></script>
<script src="js/vendor/dangle.min.js"></script>

<!-- Application scripts -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>

</body>
</html>

1 change: 1 addition & 0 deletions example/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
angular.module('demo', ['dangle', 'demo.controllers']);
118 changes: 118 additions & 0 deletions example/js/controllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
angular.module('demo.controllers', [])
.controller('DemoCtrl', function($scope) {
'use strict';

var resultsA = {
facets: {
Product : {
_type : "terms",
missing : 0,
total : 454,
other : 0,
terms : [{
term : "Prod-A",
count : 306
},{
term : "Prod-B",
count : 148
},{
term : "Prod-C",
count : 62
}]
},
Sex : {
_type : "terms",
missing : 0,
total : 454,
other : 0,
terms : [{
term : "Male",
count : 36
},{
term : "Female",
count : 148
}]
},
Times : {
_type: "date_histogram",
entries : [{
time : 1341100800000,
count : 9
}, {
time : 1343779200000,
count : 32
}, {
time : 1346457600000,
count : 78
}, {
time : 1349049600000,
count : 45
}, {
time : 1351728000000,
count : 134
}]
}
}
};

var resultsB = {
facets: {
Product : {
_type : "terms",
missing : 0,
total : 454,
other : 0,
terms : [{
term : "Prod-A",
count : 306
},{
term : "Prod-B",
count : 148
},{
term : "Prod-C",
count : 0
}]
},
Sex : {
_type : "terms",
missing : 0,
total : 454,
other : 0,
terms : [{
term : "Male",
count : 36
}]
},
Times : {
_type: "date_histogram",
entries : [{
time : 1341100800000,
count : 9
}, {
time : 1343779200000,
count : 32
}, {
time : 1346457600000,
count : 78
}]
}
}
};

$scope.filterSearchA = function(type, term) {
switch(currentResults) {
case 'A':
$scope.results = resultsB;
currentResults = 'B';
break;
case 'B':
$scope.results = resultsA;
currentResults = 'A';
break;
}
};

$scope.results = resultsA;
var currentResults = 'A';

});
Loading