Skip to content

Latest commit

 

History

History
52 lines (44 loc) · 1.32 KB

File metadata and controls

52 lines (44 loc) · 1.32 KB
elm
dependencies
gicentre/elm-vegalite
latest
import VegaLite exposing (..)

Hello Litvis

Top 5 programming languages according to the TIOBE index.

helloLitvis : Spec
helloLitvis =
    let
        data =
            dataFromColumns []
                << dataColumn "language" (strs [ "Java", "C", "C++", "Python", "C#" ])
                << dataColumn "rating" (nums [ 15.8, 13.6, 7.2, 5.8, 5.3 ])

        enc =
            encoding
                << position X
                    [ pName "language"
                    , pSort [ soByField "rating" opMean, soDescending ]
                    ]
                << position Y [ pName "rating", pQuant ]
    in
    toVegaLite [ data [], enc [], bar [] ]

Here are the same data but displayed as horizontal bars arranged in alphabetical order:

helloLitvis2 : Spec
helloLitvis2 =
    let
        data =
            dataFromColumns []
                << dataColumn "language" (strs [ "Java", "C", "C++", "Python", "C#" ])
                << dataColumn "rating" (nums [ 15.8, 13.6, 7.2, 5.8, 5.3 ])

        enc =
            encoding
                << position Y [ pName "language" ]
                << position X [ pName "rating", pQuant ]
    in
    toVegaLite [ data [], enc [], bar [] ]