Knockout bindings for d3.
npm install knockout-d3-line-graphMaking a pretty D3.js graph with a knockout binding.
``html`
`js`
var data = [
{ pos: 0, value: 1 },
{ pos: 1, value: 3 },
{ pos: 2, value: 4 },
{ pos: 4, value: 5 }
];
`html`
The x accessor is optional, if not specified it will use the index of the element as the x-position.
`html`
`html`
By default the binding will use the linear scale. Note that specifying a different scale than linear implies using a complex data source so be sure to also specify the x & y accessors.
`js`
function xAxisFormatCallback(axis) {
axis.tickFormat(d3.time.format("%d %H:%M"));
}
`html``
When the graph is rendered the callback will be invoked and additional options included.
Examples are available: https://gustavnikolaj.github.io/knockout-d3-line-graph