是否有更好的界面来为 Zeppelin 添加 Highcharts 支持
Are there better interface to add Highcharts support to Zeppelin
Apache Zeppelin has good support for AngularJS。虽然 Scala 和 Javascript 之间存在差距。
我正在尝试添加 Highcharts support to Zeppelin to fill in this gap. The main goal is to plot it simply directly from Spark DataFrame。
几轮重构后,我想出了以下界面。
github.com/knockdata/zeppelin-highcharts
这里有两个选项。 哪个选项更好?
选项A
这是绘制图表的示例。
highcharts(bank,
"marital",
List("name" -> "age", "y" -> avg(col("balance")), "orderBy" -> col("age")),
new Title("Marital Job Average Balance").x(-20),
new Subtitle("Source: Zeppelin Tutorial").x(-20),
new XAxis("Age").typ("category"),
new YAxis("Balance(¥)").plotLines(Map("value"->0, "width"->1)),
new Tooltip().valueSuffix("¥"),
new Legend().layout("vertical").align("right").verticalAlign("middle")
)
这是没有额外选项的代码。
highcharts(bank,
"marital",
List("name" -> "age",
"y" -> avg(col("balance")),
"orderBy" -> col("age")))
选项 B
我在@honnix 的回答的启发下提出了这个选项。它有更多的语法糖。
highcharts(bank).series("marital")
.data("name" -> "age", "y" -> avg(col("balance")))
.orderBy(col("age"))
.title(Title("Marital Job Average Balance").x(-20))
.subtitle(Subtitle("Source: Zeppelin Tutorial").x(-20))
.xAxis(XAxis("Age").typ("category"))
.yAxis(YAxis("Balance(¥)").plotLines("value"->0, "width"->1))
.tooltip(Tooltip().valueSuffix("¥"))
.legend(Legend().layout("vertical").align("right").verticalAlign("middle"))
.plot
没有选项的简单情节将是
highcharts(bank).series("marital")
.data("name" -> "age", "y" -> avg(col("balance")))
.orderBy(col("age"))
.plot
这里会生成一个图表。
最好有某种链接方法来传递这些参数,因为将几个列表放在一个 apply() 方法中有点难以阅读。
Apache Zeppelin has good support for AngularJS。虽然 Scala 和 Javascript 之间存在差距。
我正在尝试添加 Highcharts support to Zeppelin to fill in this gap. The main goal is to plot it simply directly from Spark DataFrame。
几轮重构后,我想出了以下界面。
github.com/knockdata/zeppelin-highcharts
这里有两个选项。 哪个选项更好?
选项A
这是绘制图表的示例。
highcharts(bank,
"marital",
List("name" -> "age", "y" -> avg(col("balance")), "orderBy" -> col("age")),
new Title("Marital Job Average Balance").x(-20),
new Subtitle("Source: Zeppelin Tutorial").x(-20),
new XAxis("Age").typ("category"),
new YAxis("Balance(¥)").plotLines(Map("value"->0, "width"->1)),
new Tooltip().valueSuffix("¥"),
new Legend().layout("vertical").align("right").verticalAlign("middle")
)
这是没有额外选项的代码。
highcharts(bank,
"marital",
List("name" -> "age",
"y" -> avg(col("balance")),
"orderBy" -> col("age")))
选项 B
我在@honnix 的回答的启发下提出了这个选项。它有更多的语法糖。
highcharts(bank).series("marital")
.data("name" -> "age", "y" -> avg(col("balance")))
.orderBy(col("age"))
.title(Title("Marital Job Average Balance").x(-20))
.subtitle(Subtitle("Source: Zeppelin Tutorial").x(-20))
.xAxis(XAxis("Age").typ("category"))
.yAxis(YAxis("Balance(¥)").plotLines("value"->0, "width"->1))
.tooltip(Tooltip().valueSuffix("¥"))
.legend(Legend().layout("vertical").align("right").verticalAlign("middle"))
.plot
没有选项的简单情节将是
highcharts(bank).series("marital")
.data("name" -> "age", "y" -> avg(col("balance")))
.orderBy(col("age"))
.plot
这里会生成一个图表。
最好有某种链接方法来传递这些参数,因为将几个列表放在一个 apply() 方法中有点难以阅读。