1.6.53 • Published 7 years ago

@devinit/charts v1.6.53

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

@devinit/charts

Build Status Codacy Badge Dependency Status

configurable d3 charts from csv like data

Install

Firstly, install @devinit/charts

npm install @devinit/charts

Developing

To start contributing, clone this repository and run npm start

Browse to localhost:8080, to see some charts

Usage

This library exposes a draw function that takes an object with the following properties;

  • element: a DOM node
  • config: a configuration object
  • data: a list of entries

The function returns an object with the following methods

  • update(data: Array): updates visualised data

    Example:

draw({
    element: document.getElementById('area_chart'),
    config: {
        title: 'Area Chart',
        type: 'area',
        colors: ['#ba0c2f', '#93328e', '#b7bf10', '#004862'],
        linearAxis: {
            showAxis: true,
            showGridlines: true,
            axisLabel: 'Country',
        },
        categoryAxis: {
            showAxis: true,
            axisLabel: 'Area',
        }
    },
    data: [
        {"Area": 100, "Country": "Uganda"},
        {"Area": 200, "Country": "Kenya"},
        {"Area": 120, "Country": "Tanzania"},
        {"Area": 270, "Country": "Rwanda"},
        {"Area": 230, "Country": "Burundi"},
    ]
})

With that you get an area chart inside the element with an id of area-chart. The configuration fields depend on the chart type.

Configuration

The following sections outline the accepted configuration fields for each supported chart type

Linear vs Category Charts

These consist of a linear axis and a category axis

Chart types

  • area
  • bar
  • line
  • stacked-bar
  • stacked-area
  • full-stacked-bar
  • full-stacked-area
  • clustered-bar
const config = {
    
    title: 'Line Chart',

    // title alignment: left/center/right,
    titleAlignment: 'left',
    
    // orientation: vertical/horizontal,
    orientation: 'vertical',
  
    linearAxis: {
        // Whether or not to show axis component
        showAxis: false,
        // Whether or not to show grid lines
        showGridlines: false,
        // Data field for this axis
        axisLabel: 'Area',
        // Minimum axis value
        axisMinimum: null,
        // Maximum axis value
        axisMaximum: null,
    },

    categoryAxis: {
        // Whether or not to show axis component
        showAxis: false,
        // Data field for this axis
        axisLabel: 'Countries',
        // Padding between categories
        innerPadding: 0,
        // Padding between axes and end data categories
        outerPadding: 0
    },
    
    legend: {
        // Whether or not to show legend
        showLegend: false,
        // Align of label items; left/center/right
        alignment: 'left',
        // Position of legend on chart: bottom/right
        position: 'bottom',
        // Shape of legend indicators: 
        // circle/square/cross/diamond/triangle/star/wye
        symbol: 'square',
        // Maximum entries per row
        rowSpan: 1
    }
    
}

Circular Charts

Circular charts include pie and donut charts

const data = {
    type: 'pie',
    
    title: 'Donut Chart',
    
    titleAlignment: 'center',
    
    colors: ['#ba0c2f', '#93328e', '#b7bf10', '#004862'],
    
    circular: {
        // Data field for label sectors
        label: 'Country',
        // Data field for sector values
        value: 'Population',
        // Inner radius for donut charts
        innerRadius: 100,
        // Stroke width and color around each sector
        strokeWidth: 5,
        strokeColor: '#fff',
    },
    
    // See previous section
    legend: {
        showLegend: true,
        position: 'bottom',
        alignment: 'center'
    }
}

Hierarchy Charts

Hierachy charts represent tree data e.g tree-map, partition, grouped-vertical-stack. Each series needs a parent identifier.

Chart types

  • treemap
  • partition

Configuration

const config = {
      
    title: 'Partition Chart',
    type: 'partition',
    orientation: 'horizontal',
    
    
    tree: {
        // unique node reference field
        id: 'label',
        // node parent reference field 
        parent: 'parent',
        // node value field
        value: 'value',
        // Maximum visible node depth
        depth: Infinity,
    },
    
    // applies to type = treemap
    treemap: {
        // Tiling algorithm: 
        // binary/dice/slice/sliceDice/squarify/resquarify
        tile: 'sliceDice',
    
    },
    
}

3D Charts (TODO)

3D charts represent three dimensional data

1.6.53

7 years ago

1.6.52

7 years ago

1.6.51

7 years ago

1.6.50

7 years ago

1.6.49

7 years ago

1.6.48

7 years ago

1.6.47

7 years ago

1.6.46

7 years ago

1.6.45

7 years ago

1.6.44

7 years ago

1.6.43

7 years ago

1.6.42

7 years ago

1.6.40

7 years ago

1.6.41

7 years ago

1.6.38

7 years ago

1.6.39

7 years ago

1.6.37

7 years ago

1.6.36

7 years ago

1.6.35

7 years ago

1.6.34

7 years ago

1.6.33

7 years ago

1.6.32

7 years ago

1.6.30

7 years ago

1.6.31

7 years ago

1.6.29

7 years ago

1.6.28

7 years ago

1.6.26

7 years ago

1.6.25

7 years ago

1.6.27

7 years ago

1.6.24

8 years ago

1.6.23

8 years ago

1.6.20

8 years ago

1.6.22

8 years ago

1.6.21

8 years ago

1.6.18

8 years ago

1.6.17

8 years ago

1.6.16

8 years ago

1.6.15

8 years ago

1.6.14

8 years ago

1.6.13

8 years ago

1.6.12

8 years ago

1.6.11

8 years ago

1.6.10

8 years ago

1.6.9

8 years ago

1.6.8

8 years ago

1.6.7

8 years ago

1.6.6

8 years ago

1.6.5

8 years ago

1.6.2

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.3

8 years ago

1.5.2

8 years ago

1.5.0

8 years ago

1.4.7

8 years ago

1.4.6

8 years ago

1.4.5

8 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.29

8 years ago

1.3.28

8 years ago

1.3.27

8 years ago

1.3.26

8 years ago

1.3.25

8 years ago

1.3.23

8 years ago

1.3.24

8 years ago

1.3.22

8 years ago

1.3.21

8 years ago

1.3.20

8 years ago

1.3.19

8 years ago

1.3.18

8 years ago

1.3.17

8 years ago

1.3.16

8 years ago

1.3.15

8 years ago

1.3.14

8 years ago

1.3.13

8 years ago

1.3.12

8 years ago

1.3.11

8 years ago

1.3.10

8 years ago

1.3.9

8 years ago

1.3.8

8 years ago

1.3.7

8 years ago

1.3.6

8 years ago

1.3.5

8 years ago

1.3.4

8 years ago

1.3.3

8 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.11

8 years ago

1.2.9

8 years ago

1.2.8

8 years ago

1.2.7

8 years ago

1.2.6

8 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.9

8 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

0.0.1

8 years ago