sciss / scala-chart   0.8.0

GNU Lesser General Public License v3.0 only GitHub

Scala Chart Library. Mirror of

Scala versions: 3.x 2.13 2.12 2.11

Scala Chart

Build Status Maven Central Scaladoc

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, LGPL v3+, to make them fully license-compatible.

This is a fork from, into my own name space de.sciss.chart and publishing to a separate Maven artifact with group-id de.sciss. The original author is Christian Krause.

Below is the original read-me, only adapted to reflect the changes in package names.

Checkout the API by clicking on the scaladoc badge above.


Add the following to your sbt build:

libraryDependencies += "de.sciss" %% "scala-chart" % "0.8.0"

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

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

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

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


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

import de.sciss.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 de.sciss.chart.module.Charting {
  val data = for (i <- 1 to 5) yield (i,i)
  val chart = XYLineChart(data)

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)

There are also some enrichments for the charts themselves to display them in a window or save them to disk: = "My Chart of Some Points")

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)
for (xi <- -40 to 40) {
  swing.Swing onEDT {
    val x = xi * 0.1
    series.add(x, math.sin(x))