dynamic interactive dashboard with zeppelin notebook

点点圈 提交于 2019-12-24 08:01:14

问题


I want to have a more interactive dashboard. like reading the data from database , giving it to select box, onchange of select box send the value and run the query.

i want to achieve this using zeppelin bcz on selected value i have to display the analytics.

what would be the way to achieve this and is this possible to achieve through zeppelin.

i tried with select box, but i couldnot save the selected value and send it to next query and execute that. something like

select age, count(1) value 
from bank 
where marital="${marital=single,single|divorced|married}" 
group by age 
order by age

i didnt get how to store this parameter and send selected parameters from one paragraph to another

or something like handling all these things from UI, lets say javascript html and sending that selected value as parameter to the zeppelin? something like this while using the url

<iframe src="http://myipaddress:8080/#/notebook/2BWCNP7V8/paragraph/20160831-115204_1774035770?asIframe&param1=value1&param2=value2" width="500" height="300"  scrolling="no" frameBorder="0" id="iframe1" style="text-align:center;" >Browser not compatible.</iframe>

and using these param1=value1&param2=value2 in my zeppelin paragraph? technically doable or not i dont understand. please help me how to achieve this? thanks in advance :)


回答1:


We can get all the maritals with following code

val maritals = bank.select("marital").distinct.collect.map(_.getString(0))

And convert to seq ZeppelinContext wanted

val seq = mairitals.zipWithIndex.map{case (x,y) => (y.toString, x)}.toSeq

Then we can select it like this

val index = z.select("marital", "1", seq)
val marital = seq(index.toString.toInt)._2

And the marital can use be used for further processing. like.

val sql = s"""select distinct job from bank where marital=="$marital""""

sqlContext.sql(sql).show

Or like when I use spark-highcharts. In this case I wanna plot average balance over age for certain marital status.

highcharts(bank.filter(col("marital") === marital)
  .series("x" -> "age", "y" -> avg(col("balance")))
  .orderBy(col("age"))).plot()

NOTE: Only the paragraph with the select will be executed automatically when value changed.



来源:https://stackoverflow.com/questions/39279889/dynamic-interactive-dashboard-with-zeppelin-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!