scala的交互式图表工具wisp

项目地址:https://github.com/quantifind/wisp

wisp是一个实时的交互式的绘制图表工具。

安装好sbt,然后将wisp项目下载到本地,然后cd到wisp项目根目录,比如我的是(cd D:\spark\wisp),然后执行sbt "project wisp" console,编译成功后,会进入sbt 控制台。

然后就可以开始编写代码了:

首先第一步都是要导入:import com.quantifind.charts.Highcharts._

然后就可以根据需要绘制不同的图表了,比如绘制一条折线图:line(Seq(1,3,2,4,6))

输入help可以查看帮助,所有支持的图表等等信息:

scala> help()
serving resources from: file:/Users/austin/IdeaProjects/wisp/index-1418919953763.html
2014-12-18 08:25:53.984:INFO:oejs.Server:jetty-7.6.0.v20120127
2014-12-18 08:25:54.022:INFO:oejsh.ContextHandler:started o.e.j.s.ServletContextHandler{/,file:/Users/austin/IdeaProjects/wisp/index-1418919953763.html}
2014-12-18 08:25:54.035:INFO:oejs.AbstractConnector:Started SocketConnector@0.0.0.0:61395
Server started: http://192.168.1.251:61395/index-1418919953763.html

Available Plot Types: Takes an Iterable, an Iterable of pairs, a pair of Iterables, or an Iterable and a Function

    area
    areaspline
    bar
    column
    line
    pie
    scatter
    spline
    regression

Other plotting options:

    histogram                          Iterable of Numerics or Pairs
    boxplot                            Collections of five Numerics : low, q1, median, q3, high

Stylistic changes:

    hold                               plots the next plot on top of the existing plot
    unhold                             plots the next plot in a new chart
    title(String)                      add a title to the most recent plot
    xAxis(String)                      adds a label to the x-axis
    xAxisType([                        updates the x-axis type
      "linear", "logarithmic",
      "datetime", "category"
    ])
    xAxisCategories(Iterable[String])  create named labels for x-axis
    yAxis(String)                      adds a label to y-axis
    yAxisType([                        updates the y-axis type
      "linear", "logarithmic",
      "datetime", "category"
    ])
    yAxisCategories(Iterable[String])  create named labels for y-axis
    legend(Iterable[String])           adds a legend to the most recent plot
    stack(["normal", "percent"])       stacks bars, columns, and lines relative to each other

Server Controls:

    undo                               undoes the most recent action
    redo                               the opposite of undo
    delete                             wipes the most recent chart from the page
    deleteAll                          wipes all plots from the page
当你画错了图的时候可以执行undo,redo是undo的反向操作。

除了绘制图表以外,还可以改变图表的外观,比如xAxis("x轴的label")改变x轴的默认显示lable.或者title("图表的标题")来改变图表的标题,这些操作都是针对的是最近的那个图表(most recent plot)的操作,hold命令可以hold住一个图表,以后可以在这个图表上追加其他图表,比如我想在一个图表上画两条折线,我可以按顺序执行以下命令:

line(1,2,3,4,5)

hold

line(5,4,3,2,1)

如果不加hold的话,第二条折线会展示在另一个最新的图表上。

执行unhold取消hold住的图表,这样新执行的命令会绘制新的图表。

更多细节参考官方文档。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值