Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/antonfisher/d3-time-logarithmic-scale-chart

D3 Time Logarithmic Scale Chart using d3.v4.js
https://github.com/antonfisher/d3-time-logarithmic-scale-chart

d3js javascrit

Last synced: 10 days ago
JSON representation

D3 Time Logarithmic Scale Chart using d3.v4.js

Awesome Lists containing this project

README

        

# D3 Time Logarithmic Scale Chart

Using d3.v4.js

[![Demo](https://raw.githubusercontent.com/antonfisher/d3-time-logarithmic-scale-chart/docs/images/demo-v1.gif)](https://antonfisher.com/d3-time-logarithmic-scale-chart/)

[Live demo](https://antonfisher.com/d3-time-logarithmic-scale-chart/)

## Usage

Add the library script on the page:

```html

```

Add chart container:
```html

```

Render the chart:
```html
const chartEl = document.getElementById('chart');
new TimeLogarithmicScaleChart(chartEl, data);
```

## API

```js
// parent DOM Element
const chartEl = document.getElementById('chart');

// an array of objects {time: , value: }
const data = [
{time: Date().now() - 60 * 1000, value: 0},
{time: Date().now(), value: 10}
];

// config object
const config = {
animation: true,
curve: d3.curveCardinal.tension(0.75),
debug: false,
margin: 40,
minInterval: '1h',
stroke: 'lightblue',
strokeWidth: 2,
yTickFormat: '.0%'
};

// render chart
const chart = new TimeLogarithmicScaleChart(chartEl, data, config);

// update chart
chart.update(newData);
```