Github user Leemoonsoo commented on the pull request:
https://github.com/apache/incubator-zeppelin/pull/27#issuecomment-90769401
I have added another example video, constructing simple dashboard by
leveraging Angular display system.
[](http://www.youtube.com/watch?v=QdjZyOkcG_w)
Here's code used in this example
paragraph 0
```scala
val bankText = sc.textFile("/tmp/bank-full.csv")
case class Bank(age:Integer, job:String, marital : String, education :
String, balance : Integer)
val bank = bankText.map(s=>s.split(";")).filter(s=>s(0)!="\"age\"").map(
s=>Bank(s(0).toInt,
s(1).replaceAll("\"", ""),
s(2).replaceAll("\"", ""),
s(3).replaceAll("\"", ""),
s(5).replaceAll("\"", "").toInt
)
)
bank.toDF.registerTempTable("bank");
bank.filter(s=>s.marital == "married").toDF.registerTempTable("married");
val tables = sqlContext.sql("show tables").collect.map(s=>s(0))
z.angularBind("tables", tables)
z.angularBind("selectedTable", "bank")
val selectedTableContext = z.getInterpreterContext()
z.angularUnwatch("selectedTable")
z.angularWatch("selectedTable", (before:Object, after:Object) => {
z.run(2, selectedTableContext)
z.run(3, selectedTableContext)
z.run(4, selectedTableContext)
})
```
paragraph 1
```html
%angular
Please select table <select ng-model="selectedTable" ng-options="o as o for
o in tables"></select>
```
paragraph 2
```scala
{
val stat = sqlContext.sql("select count(*) as cnt, min(balance),
cast(avg(balance) as INT), max(balance) from " +
z.angular("selectedTable")).collect
val count = stat(0)(0)
val minBalance = stat(0)(1)
val maxBalance = stat(0)(2)
val avgBalance = stat(0)(3)
print(s"""%angular
<h2>Table {{selectedTable}}</h2>
<hr />
<div class="row">
<div class="col-md-6"><center><h3>$count</h3>Total
customers</center></div>
<div class="col-md-6"><center><h3>$minBalance</h3>Minimum
balance</center></div>
</div>
<br />
<div>
<div class="col-md-6"><center><h3>$maxBalance</h3>Average
balance</center></div>
<div class="col-md-6"><center><h3>$avgBalance</h3>Maximum
balance</center></div>
</div>
<br /><br /><br /><br /><br /><br /><br />
""")
}
```
paragraph 3
```scala
z.show(sqlContext.sql("select marital, count(1) as cnt from " +
z.angular("selectedTable") + " group by marital order by cnt desc limit 5"))
```
paragraph 4
```scala
z.show(sqlContext.sql("select * from " +
z.angular("selectedTable").toString))
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---