This library provides a collection of helpers for building D3 graphs via Ember.js templates. Component and helpers provided in this library are intended to be primitives that one could use to build a D3 graphs.
Support for more features is ongoing.
Currently, there are no configuration options for this addon in config/environment.js
. At the moment, this addon will add all the required d3
dependencies.
You can view a demo of a few ways to use these helpers here.
Checkout ember-sparkles
to see example implementations using these primitives.
- Selection Helpers
- Shape helpers
- Transition Helpers
- Linear Scales
- Ordinal Scales
- Scale Derivatives
- Misc Helpers
d3-graph
is used to provide root level
selection to render discrete D3 elements, such as SVG <svg>
and groups <g>
.
You can change this with by specifying the component's tagName
(ie {{d3-graph (pipe ...) tagName="svg"}}
).
It can be used inline.
It can be nested to allow multiple graph pipes to be rendered into the root component.
You can pass a graph pipe into the parent component. The nested components will receive selection that's a result of the parent's graph pipe.
d3-element
is used to render simple SVG elements using d3's dynamic data join.
required
element-name
: a string specifying the type of SVG element to render (circle
,rect
, etc.)data
: data to be bound to the component
optional
selector
: a unique selector stringdata-accessor
: accessor function to pass to d3's data join methodtransition
: a d3 transition object
required
on-enter
optional
enter-transition
update-transition
on-update
: if not provided, the post-transition update step useson-enter
(mirrors typical D3 behavior)exit-transition
on-exit
Select an element matching selector and return a selection object.
Selects all elements that match the specified selector string.
Joins the specified array of data with the selected elements, returning a new selection that it represents the update selection: the elements successfully bound to data.
Helper for implementing D3's general update pattern. This helper doesn't have a corresponding function in the API because
this helper represents a pattern rather than a specific function in the API. Use it when you need to specify selection.enter().update().exit()
.
Read more about D3's General Update Pattern.
Set attribute with specified name to specified value. Value can be a string or a function.
Invokes the specified function exactly once, passing in this selection along with any optional arguments.
Adds or removes a listener to each selected element for the specified event typenames. The specified listener will be evaluated for each selected element, being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element.
An optional capture flag may be specified which corresponds to the W3C useCapture flag.
The arc generator produces a circular or annular sector, as in a pie or donut chart.
The area generator produces an area, as in an area chart.
The line generator produces a spline or polyline, as in a line chart.
Apply transition to a selection. Transition can be a name for this transition or a parent transition.
Apply a delay to a transition. Must be chained behind a transition.
For each selected element, creates a tween for the attribute with the specified name with the specified interpolator value.
Good description of transition.attrTween
can be found in this example.
export default Ember.Component.extend({
domain: [0, 10],
range: [0, 100]
});
export default Ember.Component.extend({
domain: [
new Date(2016, 2, 1),
new Date(2016, 2, 31)
]
});
Sequential color scale description.
Band scale description
Point Scale description
Categorical color scale.
Scale ticks
Get the calculated value from a scale
Immutable array helper description
A time interval helper.
git clone <repository-url>
this repositorycd ember-d3-helpers
npm install
bower install
ember serve
- Visit your app at http://localhost:4200.
npm test
(Runsember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit https://ember-cli.com/.