| elm |
|
|---|
import VegaLite exposing (..)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 [] ]