indicatrix / elm-chartjs-webcomponent / Chartjs.Data

The Data type is used as a basic container for all the chart datasets, along with the corresponding labels


type DataSet
    = BarData Chartjs.DataSets.Bar.DataSet
    | LineData Chartjs.DataSets.Line.DataSet
    | PieData Chartjs.DataSets.DoughnutAndPie.DataSet
    | PolarData Chartjs.DataSets.Polar.DataSet

Type wrapper for an individual dataset

While this type should match the overall chart type, it is possible to put multiple types of dataset on one chart


type alias Data =
{ labels : Maybe (List String)
, datasets : List DataSet 
}

All datasets for a chart are contained in a single Data object This also specifies the category labels, which are shared across datasets (eg. multiple bar charts with the same categories)

defaultData : Data

Data object with no labels or datasets defined

dataFromLabels : List String -> Data

Data object with specified labels but no datasets

buildData : List String -> List DataSet -> Data

Build a Data object from a list of labels and a list of datasets

addDataset : DataSet -> Data -> Data

Add a dataset to a Data object This is very useful for use with the |> operator

defaultData
    |> addDataset dataset1
    |> addDataset dataset2

setDatasets : List DataSet -> Data -> Data

Set all the datasets for a Data object

setLabels : List String -> Data -> Data

Set the labels for a Data object