HTML5 canvas backend for diagrams drawing EDSL


Version on this page:
LTS Haskell 22.29:
Stackage Nightly 2024-07-18:
Latest on Hackage:

See all snapshots diagrams-canvas appears in

BSD-3-Clause licensed by Jeffrey Rosenbluth, Ryan Yates, Brent Yorgey, Andy Gill, Daniel Bergey
Maintained by [email protected]
This version can be pinned in stack with:diagrams-canvas-,1830

Module documentation for


diagrams-canvas is a canvas backend for diagrams based on the blank-canvas https://github.com/ku-fpg/blank-canvas package. Diagrams is a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language. It supports most features defined in diagrams-lib.


cabal update && cabal install diagrams-canvas


A simple example that uses diagrams-canvas to draw a square.

import Diagrams.Prelude
import Diagrams.Backend.Canvas.CmdLine

b1 = (square 20 :: Diagram B) # lw 0.002

main = mainWith (pad 1.1 b1)

Save this to file named Square.hs and compile this program:

ghc --make -threaded Square.hs

This will generate an executable which, when run dispays the resulting diagrams to http://localhost:3000/

$ ./Square -w 750


v1.4.1.2 (2023-06-22)

  • Allow base-4.18, optparse-applicative-0.18, and mtl-2.3
  • Test on GHC 9.6
  • Drop support for GHC < 8.8

v1.4.1.1 (2022-09-12)

  • allow base-4.17, lens-5.2, text-2.0
  • test on GHC 9.4

v1.4.1 (2018-05-09)

  • allow base-4.11

  • allow lens-4.16

  • Add Semigroup (Render Canvas V2 Double) instance

  • r1 (13 August 2021)

    • Allow base-4.15, blank-canvas-0.7, lens-5.0, containers-0.6, statestack-0.3, optparse-applicative-0.16, diagrams-core-1.5
  • r3 (4 Feb 2022): allow optparse-applicative-0.17

v1.4r1 (Hackage revision)

  • allow base-4.10
  • allow optparse-applicative-0.14

v1.4 (2016-10-26)

  • allow lens-4.15
  • allow diagrams-core-1.4
  • allow diagrams-lib-1.4

v1.3.0.7 (2016-08-22)

  • require optparse-applicative-0.13 and fix compilation error

v1.3.0.6 (2016-08-16)

  • allow optparse-applicative-0.13


  • allow base-4.9
  • allow data-default-class-0.1
  • drop support for GHC 7.6
  • test on GHC 8.0.1


  • allow lens-4.14

v1.3.0.3 (2016-01-14)

  • Allow blank-canvas-0.6

v1.3.0.2 (2015-07-19)

Full Changelog

v1.3.0.1 (2015-05-26)

Full Changelog

1.3 (19 April 2015)

  • release to coincide with 1.3

v0.3.0.4 (2015-04-03)

Full Changelog

v0.3.0.3 (2015-01-13)

Full Changelog

v0.3.0.2 (2014-11-17)

Full Changelog

Closed issues:

  • Building with HEAD gives the error “local access only” at localhost:3000 #10

Merged pull requests:

v0.3.0.1 (2014-10-08)

Full Changelog

Closed issues:

  • API blank canvas change #7

Merged pull requests:

v0.3 (2014-09-19)

Full Changelog

Closed issues:

  • Does not support optparse-applicative-0.10 #4

Merged pull requests:

v0.2.0.3 (2014-09-11)

Full Changelog

Merged pull requests:

v0.2.0.2 (2014-09-07)

Full Changelog

v0.2.0.1 (2014-08-22)

Full Changelog

v0.2 (2014-07-08)

Closed issues:

  • Text with Local font size has incorrect vertical alignment. #1

Merged pull requests:

  • Apply accumulated uniform scaling to text size #3 (bergey)

  • Update .cabal version bounds #2 (bergey)

* This Change Log was automatically generated by github_changelog_generator