Skip to content

wuct/elm-charts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 3, 2017
a652617 Β· Oct 3, 2017

History

27 Commits
Jul 20, 2016
Jul 20, 2016
Jul 19, 2016
Jul 18, 2016
Jul 19, 2016
Oct 3, 2017
Jul 20, 2016
Oct 3, 2017

Repository files navigation

elm-charts

A pure Elm chart library

GitHub tag

This project is still in alpha. APIs might change heavily in the future.

To Try

  1. git clone https://github.com/wuct/elm-charts.git
  2. cd elm-charts
  3. elm package install
  4. elm reactor
  5. go to http://localhost:8000/examples/Example.elm

To Install

elm package install wuct/elm-charts

Update to Elm >= 0.18

Run

elm-package install elm-lang/svg 2.0.0 elm-package install elm-lang/core 5.1.1

Or update existing packages

Quick Example

import Svg exposing (svg)
import Svg.Attributes exposing (width, height)
import Chart exposing (Scale, Data)
import BarChart exposing (barChart, color, width)
import LineChart exposing (lineChart, color, width)
import ScatterPlot exposing (scatterPlot, color, size)


data : Data msg
data =
  [
    (1, 22.2, []),
    (2, 34, []),
    (3, 56, [BarChart.color "yellowgreen"]),
    (4, 62, []),
    (5, 77, [])
  ]


xScale : Scale
xScale x =
  20 + x * 20


yScale : Scale
yScale y =
  600 - y * 3


main =
  svg
    [
      Svg.Attributes.width "1000",
      Svg.Attributes.height "600"
    ]
    [
      barChart
        [
          BarChart.color "pink",
          BarChart.width "10"
        ]
        { data = data
        , xScale = xScale
        , yScale = yScale
        },
      lineChart
        [
          LineChart.color "#7E94C7"
        ]
        { data = data
        , xScale = xScale
        , yScale = (\y -> 500 - y * 3)
        },
      scatterPlot
        []
        { data = data
        , xScale = xScale
        , yScale = (\y -> 400 - y * 3)
        }
    ]

To Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request