Lijngrafiekje generator

A 'interactive' linegraph chart

Updated 7 years ago by Gijs Wijngaard

This section documents API usage specific to this template, so for an introduction we suggest you refer to the generic API documentation instead.

template: _209

version: _18

Template data

There are three different formats in which you can supply data to this template. The most convenient for you to use likely depends on the source of your data, as described below.

1. Array of arrays, and a bindings object

You can supply arrays of arrays to opts.data, which might look like:

{
    data: {
        linegraphic: [
            [ "LinegraphicColumn1Value1", "LinegraphicColumn2Value1",
            [ "LinegraphicColumn1Value2", "LinegraphicColumn2Value2",
            [ "LinegraphicColumn1Value3", "LinegraphicColumn2Value3",
            ...
        ]
    }
}

where each array of arrays represents the rows in a data sheet.

To tell the API how the values from each column should be associated with the keys that the template is expecting, you must also supply an object attached to opts.bindings. (The meanings of the keys in the bindings object are documented below.) The minimal bindings you can supply for this template are as shown in this example:

{
    template: "_209",
    version: "_18",
    bindings: {
        linegraphic: {
            key: 0, // index of a column in your data
            value: 1, // index of a column in your data
        }
    },
    data: {
        linegraphic: [
            [ "LinegraphicColumn1Value1", "LinegraphicColumn2Value1",
            [ "LinegraphicColumn1Value2", "LinegraphicColumn2Value2",
            [ "LinegraphicColumn1Value3", "LinegraphicColumn2Value3",
            ...
        ]
    }
}

All possible bindings that you can supply are shown in this example:

{
    template: "_209",
    version: "_18",
    bindings: {
        linegraphic: {
            key: 0, // index of a column in your data
            value: 1, // index of a column in your data
            extra: [2, 3, ...], // index(es) of column(s) in your data
        }
    },
    data: {
        linegraphic: [
            [ "LinegraphicColumn1Value1", "LinegraphicColumn2Value1",
            [ "LinegraphicColumn1Value2", "LinegraphicColumn2Value2",
            [ "LinegraphicColumn1Value3", "LinegraphicColumn2Value3",
            ...
        ]
    }
}

2. Array of objects with arbitrary keys, and a bindings object

This format is most likely useful when you have data from an external source, such as CSV data loaded from d3-dsv. You should supply this attached to the opts.data, which might look like:

{
        linegraphic: [
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            ...
        ]
    }

... but with the keys being the column headers from your source data instead. You must also supply an object attached to opts.bindings. The minimal bindings you can supply for this template are as shown in this example:

{
    template: "_209",
    version: "_18",
    bindings: {
        linegraphic: {
            key: "LinegraphicHeader1",
            value: "LinegraphicHeader2",
        }
    },
    data: {
        linegraphic: [
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            ...
        ]
    }
}

All possible bindings that you can supply are shown in this example:

{
    template: "_209",
    version: "_18",
    bindings: {
        linegraphic: {
            key: "LinegraphicHeader1",
            value: "LinegraphicHeader2",
            extra: ["LinegraphicHeader3", "LinegraphicHeader4", ...],
        }
    },
    data: {
        linegraphic: [
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            { "LinegraphicHeader1": ..., "LinegraphicHeader2": ..., ... },
            ...
        ]
    }
}

(As before, the keys containing "Header" would be replaced by column names from your data source.)

3. Array of objects with template-defined keys

There is an alternative format you can use, which is likely to be easier to use if your data is not from a spreadsheet source. With this alternative format you supply your data to the template as an array of objects, attached to opts.data, where the keys must be those used by the template, as documented below. In this case there is no need to supply a bindings object, since the key names are already those expected by the template. The required properties in the data object are as follows (scroll down for a description of what each property is):

{
    template: "_209",
    version: "_18",
    data: {
    linegraphic: [
        {
            key: ...,
            value: ...,
            extra: [...]
        },
        ...
    ]
},
    ...
}

And the full list of all possible properties is as follows:

{
    template: "_209",
    version: "_18",
    data: {
    linegraphic: [
        {
            key: ...,
            value: ...,
            extra: [...]
        },
        ...
    ]
},
    ...
}

Meanings of the template data keys:

  • linegraphic.key: De tijden (data) of getallen die op de X-as terecht komen. Deze geven vaak een tijdsaanduiding aan
  • linegraphic.value: Dit is voor de lijn die getekend kan worden
  • linegraphic.extra: Dit zijn voor lijnen die wel in zijn geheel getekend zullen zijn (optioneel)

Template settings

Options for opts.state.

Teksten

text_x string

Tekst langs de x-as.

text_y string

Tekst langs de y-as.

text_title string

Tekst van de titel. Voer hier een stukje tekst in als titel van deze visualisatie.

text_description text

Tekst van de beschrijving. Voer hier een stukje tekst in als beschrijving onderaan de visualisatie.

text_button string

Tekst van de knop. Voer hier een stukje tekst in als tekst voor op de knop

label_text boolean

Tekst bij de lijnen. Extra tekst bij de lijnen voor extra informatie over wat de lijn inhoudt.

label_position text

Positie van de tekst bij de lijnen.

Interactiviteit

interactivity boolean

Activeer interactiviteit in de grafiek. De gebruiker kan een lijntje trekken en vervolgens zien wat de echte waarde van deze lijn was.

interactivity_number number

Vanaf welke kolomwaarde interactiviteit. Voer hier het getal in vanaf welke datapunt je wilt dat de gebruiker de rest van de grafiek zelf kan tekenen

Min: 1

Marges

margin_top number

Boven.

margin_right number

Rechts.

margin_bottom number

Onder.

margin_left number

Links.

Lijnen

fill_color boolean

Opvulkleur voor de originele lijn.

colors text

Kleuren voor de andere lijnen, indien toegevoegd. Een met kommas gesepereerde lijst van hex-kleurwaardes

curved_lines boolean

Gekromde lijnen.

Assen

numbers_data boolean

Getallen op X-as. Getallen in plaats van data op de X-as. Alleen activeren wanneer de X-as normale getallen zijn, en geen data.

percentages_data boolean

Percentages op Y-as. Percentages in plaats van getallen op de Y-as

xaxis_items number

Max aantal labels x-as.

Min: 2

yaxis_items number

Max aantal labels y-as.

custom_yvalue boolean

Stel y waarde in.

min_yvalue number

Minimale y-waarde.

max_yvalue number

Maximale y-waarde.

Rooster

grid boolean

Activeer het rooster.

same_ticks boolean

Dezelfde punten aanhouden als de assen.