scala-chart

Scala Chart Library

License

License

Categories

Categories

Scala Languages
GroupId

GroupId

com.github.wookietreiber
ArtifactId

ArtifactId

scala-chart_2.11
Last Version

Last Version

0.5.1
Release Date

Release Date

Type

Type

jar
Description

Description

scala-chart
Scala Chart Library
Project URL

Project URL

https://github.com/wookietreiber/scala-chart
Project Organization

Project Organization

com.github.wookietreiber
Source Code Management

Source Code Management

https://github.com/wookietreiber/scala-chart

Download scala-chart_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.wookietreiber/scala-chart_2.11/ -->
<dependency>
    <groupId>com.github.wookietreiber</groupId>
    <artifactId>scala-chart_2.11</artifactId>
    <version>0.5.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.wookietreiber/scala-chart_2.11/
implementation 'com.github.wookietreiber:scala-chart_2.11:0.5.1'
// https://jarcasting.com/artifacts/com.github.wookietreiber/scala-chart_2.11/
implementation ("com.github.wookietreiber:scala-chart_2.11:0.5.1")
'com.github.wookietreiber:scala-chart_2.11:jar:0.5.1'
<dependency org="com.github.wookietreiber" name="scala-chart_2.11" rev="0.5.1">
  <artifact name="scala-chart_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.wookietreiber', module='scala-chart_2.11', version='0.5.1')
)
libraryDependencies += "com.github.wookietreiber" % "scala-chart_2.11" % "0.5.1"
[com.github.wookietreiber/scala-chart_2.11 "0.5.1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.8
org.jfree : jfreechart jar 1.0.19
org.scala-lang.modules : scala-swing_2.11 jar 1.0.2
com.itextpdf : itextpdf Optional jar 5.5.10
org.jfree : jfreesvg Optional jar 3.2

test (1)

Group / Artifact Type Version
org.specs2 : specs2-core_2.11 jar 3.8.6

Project Modules

There are no modules declared in this project.

Scala Chart Library

Build Status Maven Central Scaladoc Reference Status

scala-chart is a Scala library for creating and working with charts. It wraps JFreeChart, much like scala-swing does with the original javax.swing package. This project is released under the same license as JFreeChart to make them fully license-compatible. Checkout the API by clicking on the scaladoc badge above.

Usage

Add the following to your sbt build:

libraryDependencies += "com.github.wookietreiber" %% "scala-chart" % "latest.integration"

In case exporting to PDF is required, also add iText to your dependencies:

libraryDependencies += "com.itextpdf" % "itextpdf" % "5.5.6"

In case exporting to SVG is required, also add JFreeSVG to your dependencies:

libraryDependencies += "org.jfree" % "jfreesvg" % "3.0"

Imports

All high-level convenience can be imported with the all you can eat import:

import scalax.chart.api._

For more and more a la carte imports, have a look at the module package for various selfless traits. There is also a module containing everything the api import does which can be used in applications directly:

object MyChartApp extends App with scalax.chart.module.Charting {
  val data = for (i <- 1 to 5) yield (i,i)
  val chart = XYLineChart(data)
  chart.saveAsPNG("/tmp/chart.png")
}

Creating Charts

Creating charts is as simple as using one of the many chart factories, which differ from the JFreeChart ones in the aspect, that they make heavy use of default arguments, so you have to type as less as possible:

val data = for (i <- 1 to 5) yield (i,i)
val chart = XYLineChart(data)

The first argument is always the dataset which is the only required argument. For better readability of your own code, you should name the other arguments:

val chart = XYLineChart(data, title = "My Chart of Some Points")

There are also some enrichments for the charts themselves to display them in a window or save them to disk:

chart.show()
chart.saveAsPNG("/tmp/chart.png")
chart.saveAsJPEG("/tmp/chart.jpg")
chart.saveAsPDF("/tmp/chart.pdf")
chart.saveAsSVG("/tmp/chart.svg")

Animations / Live Chart Updates

You can also do some animations, i.e. perform live updates on your datasets:

val series = new XYSeries("f(x) = sin(x)")
val chart = XYLineChart(series)
chart.show()
for (x <- -4.0 to 4 by 0.1) {
  swing.Swing onEDT {
    series.add(x,math.sin(x))
  }
  Thread.sleep(50)
}

Versions

Version
0.5.1
0.5.0
0.4.2