{"id":13806927,"url":"https://github.com/LocusEnergy/ember-d3-helpers","last_synced_at":"2025-05-13T23:33:38.682Z","repository":{"id":57223621,"uuid":"53536857","full_name":"LocusEnergy/ember-d3-helpers","owner":"LocusEnergy","description":"Collection of Ember.js helpers for building composable D3 charts","archived":false,"fork":false,"pushed_at":"2022-12-07T11:09:41.000Z","size":1586,"stargazers_count":35,"open_issues_count":15,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-08T07:44:59.535Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LocusEnergy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-09T22:34:22.000Z","updated_at":"2020-04-20T17:59:23.000Z","dependencies_parsed_at":"2023-01-24T16:45:59.445Z","dependency_job_id":null,"html_url":"https://github.com/LocusEnergy/ember-d3-helpers","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LocusEnergy%2Fember-d3-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LocusEnergy%2Fember-d3-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LocusEnergy%2Fember-d3-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LocusEnergy%2Fember-d3-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LocusEnergy","download_url":"https://codeload.github.com/LocusEnergy/ember-d3-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225267426,"owners_count":17447153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:01:18.067Z","updated_at":"2024-11-18T23:30:31.793Z","avatar_url":"https://github.com/LocusEnergy.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/LocusEnergy/ember-d3-helpers.svg?branch=master)](https://travis-ci.org/LocusEnergy/ember-d3-helpers)\n\n\u003c!-- [![Code Climate](https://codeclimate.com/github/spencer516/ember-d3-helpers/badges/gpa.svg)](https://codeclimate.com/github/spencer516/ember-d3-helpers)\n[![Ember Observer Score](http://emberobserver.com/badges/ember-d3-helpers.svg)](http://emberobserver.com/addons/ember-d3-helpers)\n --\u003e\n\n# ember-d3-helpers\n\nThis library provides a collection of helpers for building D3 graphs via Ember.js templates.\nComponent and helpers provided in this library are intended to be primitives that one could use to build a D3 graphs.\n\nSupport for more features is ongoing.\n\n## Configuration\n\nCurrently, there are no configuration options for this addon in `config/environment.js`. At the moment, this addon will add all the required `d3` dependencies.\n\n## Live Examples\n\nYou can view a demo of a few ways to use these helpers [here](http://locusenergy.github.io/ember-d3-helpers).\nCheckout [`ember-sparkles`](https://github.com/LocusEnergy/ember-sparkles) to see example implementations using these primitives.\n\n## Components\n* [`d3-graph`](#d3-graph)\n* [`d3-element`](#d3-element)\n\n## Helpers\n* [Selection Helpers](#selection-helpers)\n  - [`d3-select`](#d3-select)\n  - [`d3-select-all`](#d3-select-all)\n  - [`d3-join`](#d3-join)\n  - [`d3-attr`](#d3-attr)\n  - [`d3-call`](#d3-call)\n* [Shape helpers](#shape-helpers)\n  - [`d3-arc`](#d3-arc)\n  - [`d3-area`](#d3-area)\n  - [`d3-line`](#d3-line)  \n  - [`d3-pie`](#d3-pie)\n* [Transition Helpers](#transition-helpers)\n  - [`d3-transition`](#d3-transition-transition)\n  - [`d3-transition-delay`](#d3-transition-delay-amount)\n  - [`d3-attr-tween`](#d3-attr-tween)\n* [Linear Scales](#linear-scales)\n\t- [`linear-scale`](#linear-scale)\n\t- [`time-scale`](#time-scale)\n  - [`seq-color-scale`](#seq-color-scale)\n* [Ordinal Scales](#ordinal-scales)\n\t- [`band-scale`](#band-scale)\n\t- [`point-scale`](#point-scale)\n  - [`cat-color-scale`](#cat-color-scale)\n* [Scale Derivatives](#scale-derivatives)\n\t- [`scale-tics`](#scale-ticks)\n\t- [`scale-value`](#scale-value)\n* [Misc Helpers](#misc-helpers)\n\t- [`immut-array`](#immut-array)\n\t- [`time-interval`](#time-interval)\n\n# Usage\n\n## `{{d3-graph}}`\n\n`d3-graph` is used to provide root level\nselection to render discrete D3 elements, such as SVG `\u003csvg\u003e` and groups `\u003cg\u003e`.\nYou can change this with by specifying the component's `tagName`\n(ie `{{d3-graph (pipe ...) tagName=\"svg\"}}`).\n\nIt can be used inline.\n\n```hbs\n{{d3-graph (pipe\n  (d3-attr \"name\" \"fred\")\n)}}\n```\n\nIt can be nested to allow multiple graph pipes to be rendered into the root component.\n\n```hbs\n{{#d3-graph as |d3|}}\n  {{d3.graph (pipe ...)}}\n  {{d3.graph (pipe ...)}}\n{{/d3-graph}}\n```\n\nYou 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.\n\n```hbs\n{{#d3-graph (pipe\n    (d3-select-all \"rect\")\n    (d3-data data)\n  ) as |d3|}}\n  {{! selection here will be result of pipe above }}\n  {{d3.graph (pipe ...)}}\n  {{d3.graph (pipe ...)}}\n{{\n```\n----------\n\n\n## `{{d3-element}}`\n\n`d3-element` is used to render simple SVG elements using d3's dynamic data join.\n\n#### Properties\n\n_required_\n* `element-name`: a string specifying the type of SVG element to render (`circle`, `rect`, etc.)\n* `data`: data to be bound to the component\n\n_optional_\n* `selector`: a unique selector string\n* `data-accessor`: accessor function to pass to d3's data join method\n* `transition`: a d3 transition object\n\n\n#### Configurable Pipes\n\n_required_\n* `on-enter`\n\n_optional_\n* `enter-transition`\n* `update-transition`\n* `on-update`: if not provided, the post-transition update step uses `on-enter` (mirrors typical D3 behavior)\n* `exit-transition`\n* `on-exit`\n\n#### example\n```hbs\n{{d3-element\n  element-name='circle'\n  selector='rotator'\n  data=points\n  on-enter=(pipe\n    (d3-attr 'cx' (r/get 'cx'))\n    (d3-attr 'cy' (r/get 'cy'))\n    (d3-attr 'r' 3)\n  )\n  update-transition=(pipe\n    (d3-attr 'r' 0)\n  )\n  on-exit=(pipe\n    (d3-attr 'r' 200)\n  )\n}}\n\n```\n\n----------\n\n### Selection Helpers\n\n#### `(d3-select selector)`\n[D3 Select](https://github.com/d3/d3-selection#select)\n\nSelect an element matching selector and return a selection object.\n\n```hbs\n{{d3-graph (pipe\n  (d3-select \"#my-link\")\n  (d3-attr \"name\" \"fred\")\n)}}\n```\n\n#### `(d3-select-all selector)`\n[D3 Select All](https://github.com/d3/d3-selection#selectAll)\n\nSelects all elements that match the specified selector string.\n\n```hbs\n{{d3-graph (pipe\n  (d3-select-all \"rect\")\n  (d3-data data)\n  (d3-style \"color\" \"red\")\n)}}\n```\n\n#### `(d3-data data [key])`\n[D3 Data](https://github.com/d3/d3-selection#selection_data)\n\nJoins 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.\n\n```hbs\n{{d3-graph (pipe\n  (d3-select-all \"rect\")\n  (d3-data data key)\n  (d3-join\n    enter=(pipe\n      (d3-append \"rect\")\n      (d3-text (r/get \"number\"))\n    )\n  )\n)}}\n```\n\n#### `(d3-join [enter=] [update=] [exit=])`\n\nHelper for implementing D3's general update pattern. This helper doesn't have a corresponding function in the API because\nthis helper represents a pattern rather than a specific function in the API. Use it when you need to specify `selection.enter().update().exit()`.\n\nRead more about [D3's General Update Pattern](https://bl.ocks.org/mbostock/3808218).\n\n```hbs\n{{d3-graph (pipe\n  (d3-select \"svg\")\n  (d3-select-all \"rect\")\n  (d3-data data)\n  (d3-join\n    enter=(pipe\n      (d3-append \"rect\")\n      (d3-text (r/param))\n    )\n    update=(pipe\n      (d3-text (r/param))\n    )\n    exit=(pipe\n      (d3-remove)\n    )\n  )\n)}}\n```\n\n#### `(d3-attr name value)`\n[D3 Attr](https://github.com/d3/d3-selection#selection_attr)\n\nSet attribute with specified name to specified value. Value can be a string or a function.\n\n```hbs\n{{d3-graph (pipe\n  (d3-select \".myelement\")\n  (d3-attr \"name\" name)\n)}}\n```\n\n#### `(d3-call (pipe ...))`\n[D3 Call](https://github.com/d3/d3-selection#selection_call)\n\nInvokes the specified function exactly once, passing in this selection along with any optional arguments.\n\n```hbs\n{{d3-graph (pipe\n  (d3-select \".test-items\")\n  (d3-call (pipe\n    (d3-select-all \".car\")\n    (d3-attr \"color\" \"red\")\n  ))\n  (d3-call (pipe\n    (d3-select-all \".boat\")\n    (d3-attr \"color\" \"blue\")\n  ))\n  (d3-append 'i')\n  (d3-attr \"class\" \"truck\")\n)}}\n```\n#### `(d3-on typenames [listener [capture]])`\n[D3 On](https://github.com/d3/d3-selection#selection_on)\n\nAdds or removes a _listener_ to each selected element for the specified event\n_typenames_. The specified _listener_ will be evaluated for each selected\nelement, being passed the current datum (_d_), the current index (_i_), and the\ncurrent group (_nodes_), with this as the current DOM element.\n\nAn optional _capture_ flag may be specified which corresponds to the W3C\n[useCapture flag](https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration).\n\n```hbs\n{{d3-graph (pipe\n  (d3-select \".test-items\")\n  (d3-call (pipe\n    (d3-select-all \".car\")\n    (d3-on \"click\" listener)\n  ))\n)}}\n```\n\n----------\n\n\n### Shape Helpers\n\n### `(d3-arc params {innerRadius, outerRadius, startAngle, endAngle})`\n[D3 Arc](https://github.com/d3/d3-shape/blob/master/README.md#arcs)\n\nThe arc generator produces a circular or annular sector, as in a pie or donut chart.\n\n\n### `(d3-area [xScale, yScale] {xAccessor, yAccessor})`\n[D3 Areas](https://github.com/d3/d3-shape/blob/master/README.md#areas)\n\nThe area generator produces an area, as in an area chart.\n\n```hbs\n{{d3-graph\n  (pipe\n    (d3-select-all 'path')\n    (d3-data data)\n    (d3-join\n      enter=(pipe\n        (d3-append 'path')\n        (d3-attr 'd'\n          (d3-area\n            xScale\n            yScale\n            xAccessor=(d3-get 'x')\n            yAccessor=(d3-get 'y')\n          )\n        )\n      )\n    )\n  )\n}}\n```\n\n### `(d3-line [xScale, yScale] {xAccessor, yAccessor})`\n[D3 Lines](https://github.com/d3/d3-shape/blob/master/README.md#lines)\n\nThe line generator produces a spline or polyline, as in a line chart.\n\n----------\n\n\n### Transition Helpers\n\n#### `(d3-transition [transition])`\n[D3 Transition](https://github.com/d3/d3-transition/blob/master/README.md#transition)\n\nApply transition to a selection. Transition can be a name for this transition or a parent transition.\n\n```hbs\n{{d3-graph (pipe\n  (d3-select-all \"rect\")\n  (d3-data data)\n  (d3-join\n    enter=(pipe\n      (d3-append \"rect\")\n      (d3-attr height)\n      (d3-transition)\n      (d3-attr (r/get \"y\"))\n  ))\n)}}\n```\n\n#### `(d3-transition-delay amount)`\n[D3 Transition Delay](https://github.com/d3/d3-transition/blob/master/README.md#transition_delay)\n\nApply a delay to a transition. Must be chained behind a transition.\n\n```hbs\n{{d3-graph (pipe\n  (d3-join\n    enter=(pipe\n      (d3-append \"rect\")\n      (d3-attr height)\n      (d3-transition)\n      (d3-delay 300)\n      (d3-attr (r/get \"y\"))\n  ))\n)}}\n```\n\n#### `(d3-attr-tween)`\n[D3 Attr Tween](https://github.com/d3/d3-transition/blob/master/README.md#transition_attrTween)\n\nFor each selected element, creates a tween for the attribute with the specified name with the specified interpolator value.\n\nGood description of `transition.attrTween` can be found in [this example](http://bl.ocks.org/cmdoptesc/6228457).\n\n----------\n\n### Linear scales\n\n#### `linear-scale`\n[D3 Linear Scale](https://github.com/d3/d3-scale#linear-scales)\n\n```js\nexport default Ember.Component.extend({\n  domain: [0, 10],\n  range: [0, 100]\n});\n```\n\n```hbs\n{{#with (linear-scale domain range nice=true) as |scale|}}\n  \u003cspan\u003eI am {{scale-value scale 5}} 50 years old.\u003c/span\u003e\n{{/with}}\n```\n\n#### `time-scale`\n[D3 Time Scale](https://github.com/d3/d3-scale#time-scales)\n\n```js\nexport default Ember.Component.extend({\n  domain: [\n    new Date(2016, 2, 1),\n    new Date(2016, 2, 31)\n  ]\n});\n```\n\n```hbs\n{{#with (time-scale domain) as |scale|}}\n  {{#each (scale-ticks scale (time-interval 'day')) as |date|}}\n    \u003ca\u003e{{date}}\u003c/a\u003e\n  {{/each}}\n{{/with}}\n```\n### `seq-color-scale`\nSequential color scale description.\n\n### Ordinal scales\n\n#### `band-scale`\nBand scale description\n\n#### `point-scale`\nPoint Scale description\n\n#### `cat-color-scale`\nCategorical color scale.\n\n----------\n\n### Scale Derivatives\n\n#### `scale-ticks`\nScale ticks\n\n#### `scale-value`\nGet the calculated value from a scale\n\n----------\n\n### Misc Helpers\n\n#### `immut-array`\nImmutable array helper description\n\n#### `time-interval`\nA time interval helper.\n\n----------\n\n\n## Installation\n\n* `git clone \u003crepository-url\u003e` this repository\n* `cd ember-d3-helpers`\n* `npm install`\n* `bower install`\n\n## Running\n\n* `ember serve`\n* Visit your app at [http://localhost:4200](http://localhost:4200).\n\n## Running Tests\n\n* `npm test` (Runs `ember try:each` to test your addon against multiple Ember versions)\n* `ember test`\n* `ember test --server`\n\n## Building\n\n* `ember build`\n\nFor more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).\n","funding_links":[],"categories":["Packages"],"sub_categories":["Helpers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLocusEnergy%2Fember-d3-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLocusEnergy%2Fember-d3-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLocusEnergy%2Fember-d3-helpers/lists"}