2.1.2 • Published 3 years ago

gridy-chart-d3 v2.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

GridyGrid chart component D3 driver

Installation

npm i gridy-grid d3 gridy-chart-d3 gridy-grid-default sk-theme-default

and plug it to your page

<script src="/node_modules/d3/dist/d3.js"></script>

or from CDN

<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>

then add element to your container or setup it programmatically

    <gridy-grid id="gridyGrid" base-path="/node_modules/gridy-grid/src" sort-field="$.title">
	    <gridy-data-source fields='[{ "title": "Name", "path": "$.name" },{ "title": "Value", "path": "$.value"},{ "title": "Color", "path": "$.color"}]'
                       datasource-type="DataSourceLocal" datapath="$.data"></cbr-data-source>
    
	<gridy-chart type="pie" dri="d3" field-name="Name" field-color="Color" field-value="Value" width="400" height="400"></cbr-chart>
    
    </gridy-grid>
    <script>
        let data = [];
	    data.push({ name: 'FooBar1', value: 10, color: '#98abc5' });
	    data.push({ name: 'FooBar2', value: 23, color: '#8a89a6' });
	    data.push({ name: 'FooBar3', value: 34, color: '#7b6888' });
	    data.push({ name: 'FooBar4', value: 17, color: '#a05d56' });
        let grid = document.querySelector('#gridyGrid');
        grid.addEventListener('bootstrap', () => {
            grid.charts[0].addEventListener('skrender', (event) => {
                grid.dataSource.loadData(data);
            });
        });
    </script>
    

to map datasource data for chart field-${dataKey} attributes are used with field title from datasource mapping as value

Chart types

Pie

	<gridy-chart type="pie" dri="d3" field-color="Color" field-value="Value" width="400" height="400"></cbr-chart>

config attrs: stroke, stroke-width, radius, inner-radius

Bar

	<gridy-chart type="bar" dri="d3" field-color="Color" field-name="Name" field-value="Value" width="400" height="400"></cbr-chart>

config attrs: color (fill)

Histogram

	<gridy-chart type="hist" dri="d3" field-color="Color" field-name="Name" field-value="Value" width="400" height="400"></cbr-chart>

config attrs: color (fill)

Line

	<gridy-chart stroke-width="5" color="#f0f0f0" fill="#f0f0f0" type="line" dri="d3" field-x="x" field-y="y" width="400" height="400"></cbr-chart>

config attrs: color (stroke), stroke-width, fill

Groupline

groupline chart allows multiple lines for data grouped by value of specified field

	<gridy-chart stroke-width="5" color="#f0f0f0" fill="#f0f0f0" type="groupline" dri="d3" field-x="x" field-y="y" field-group="Name" width="400" height="400"></cbr-chart>

config attrs: color (stroke), stroke-width

Configuration

attributes

share-chart-dri - share chart driver instance from cache than instancinate, ok when all types of chart on page have the same type

share-chart-impl - prefer get chart impl from cache than instancinate, ok when all types of chart on page have the same type

2.1.2

3 years ago

2.0.28

3 years ago

2.0.29

3 years ago

2.0.26

3 years ago

2.1.1

3 years ago

2.0.27

3 years ago

2.1.0

3 years ago

2.0.25

3 years ago

2.0.24

3 years ago

2.0.22

3 years ago

2.0.23

3 years ago

2.0.21

3 years ago

2.0.15

3 years ago

2.0.16

3 years ago

2.0.13

4 years ago

2.0.14

4 years ago

2.0.20

3 years ago

2.0.19

3 years ago

2.0.17

3 years ago

2.0.18

3 years ago

2.0.12

4 years ago

2.0.11

4 years ago