Liking cljdoc? Tell your friends :D

clj-xchart

Clojars Project cljdoc test

Clojure wrapper around XChart, a small library for rendering charts/plots.

Rosling chart

Maintenance fork of hyPiRion/clj-xchart, ported to XChart 4.x / Clojure 1.12 and published to Clojars as net.clojars.savya/clj-xchart.

Stack

Clojure deps.edn tools.build XChart

What

The constructors cover XChart 4.0.3's full chart-type set:

  • XY charts: line, scatter, area, step, step-area, and polygon-area
  • Category charts: bar, stepped-bar, line, area, scatter, and stick
  • Pie and donut charts
  • Bubble charts
  • OHLC charts: candle, hi-lo, and line
  • Box (box-and-whisker) charts
  • Horizontal bar charts
  • Dial charts
  • Radar charts: polygon and circle
  • Heat-map charts

The keyword-based styling covers these items:

  • the full marker and render-style set
  • accessible and printer-friendly color presets
  • the current XChart styler options
  • chart-space or screen-space annotations for axes charts

Existing constructors and keyword-based styling stay compatible.

Installation

Leiningen/Boot:

[net.clojars.savya/clj-xchart "0.5.0"]

deps.edn:

net.clojars.savya/clj-xchart {:mvn/version "0.5.0"}

Usage

The examples page shows many examples, and the tutorial covers basic usage. For more advanced customisation, see the render options page.

(require '[com.hypirion.clj-xchart :as c])

(-> (c/xy-chart {"y = x" {:x [1 2 3] :y [1 2 3]}
                 "y = 2x" {:x [1 2 3] :y [2 4 6]}})
    (c/spit "chart.png"))

Charts with mutable XChart series can be updated in place with (c/update-series! chart series-name data). It accepts the same data shapes as add-series!, and replaces the existing series data rather than appending it. This is supported for XY, category, horizontal-bar, bubble, pie, box, OHLC, and heat-map charts. Category updates must provide the chart's existing categories in the same order; mismatches throw ex-info so cross-series alignment is not silently broken. Bubble charts created with bubble-chart scale sizes before adding them; updates expect those already-scaled bubble sizes because XChart does not retain the original scaling parameters. XChart 4.0.4 has no in-place update operation for dial or radar charts, so calls for those chart types throw ex-info.

The Clojure namespace is still com.hypirion.clj-xchart, so existing require forms keep working; only the Clojars coordinate changed.

Compatibility

XChart 4.x changed its API: the vector-graphics export, the styler hierarchy, and the pie "annotations", which are now "labels". This fork follows those changes. The clj-xchart keyword-based API stays the same, so charts that use earlier com.hypirion/clj-xchart releases still render. See CHANGELOG.md for details.

License

Copyright © 2016 Jean Niklas L'orange.

Maintenance fork (2026) by Savyasachi, original: https://github.com/hyPiRion/clj-xchart. Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version, preserving the original project's license.

Can you improve this documentation? These fine people already did:
Savyasachi & Jean Niklas L'orange
Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close