├── tests ├── unit │ ├── .gitkeep │ └── loading-d3-modules-test.js ├── integration │ └── .gitkeep ├── dummy │ ├── app │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── models │ │ │ └── .gitkeep │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── templates │ │ │ ├── components │ │ │ │ └── .gitkeep │ │ │ └── application.hbs │ │ ├── resolver.js │ │ ├── router.js │ │ ├── app.js │ │ └── index.html │ ├── public │ │ ├── robots.txt │ │ └── crossdomain.xml │ └── config │ │ └── environment.js ├── test-helper.js ├── helpers │ ├── destroy-app.js │ ├── resolver.js │ ├── start-app.js │ └── module-for-acceptance.js ├── .jshintrc └── index.html ├── .jscsrc ├── .watchmanconfig ├── .bowerrc ├── screenshots └── donut-dummy-app.png ├── config ├── environment.js └── ember-try.js ├── bower.json ├── .npmignore ├── play └── rewrite-example.js ├── testem.js ├── .ember-cli ├── .gitignore ├── ember-cli-build.js ├── .jshintrc ├── .editorconfig ├── .travis.yml ├── lib ├── amd-define-filter.js └── rewrite-amd-definition.js ├── LICENSE.md ├── LICENSE ├── CHANGELOG.md ├── package.json ├── bin └── update-d3-dependencies.js ├── index.js └── README.md /tests/unit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/integration/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "ember-suave" 3 | } 4 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 |

ember-cli-d3-shape

-------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /screenshots/donut-dummy-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivanvanderbyl/ember-cli-d3-shape/HEAD/screenshots/donut-dummy-app.png -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | 'use strict'; 3 | 4 | module.exports = function(/* environment, appConfig */) { 5 | return { }; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import resolver from './helpers/resolver'; 2 | import { 3 | setResolver 4 | } from 'ember-qunit'; 5 | 6 | setResolver(resolver); 7 | -------------------------------------------------------------------------------- /tests/helpers/destroy-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default function destroyApp(application) { 4 | Ember.run(application, 'destroy'); 5 | } 6 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-d3-shape", 3 | "dependencies": { 4 | "ember": "~2.6.0", 5 | "ember-cli-shims": "0.1.1", 6 | "ember-cli-test-loader": "0.2.2", 7 | "ember-qunit-notifications": "0.1.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from './config/environment'; 3 | 4 | const Router = Ember.Router.extend({ 5 | location: config.locationType 6 | }); 7 | 8 | Router.map(function() { 9 | }); 10 | 11 | export default Router; 12 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /bower_components 2 | /config/ember-try.js 3 | /dist 4 | /tests 5 | /tmp 6 | **/.gitkeep 7 | .bowerrc 8 | .editorconfig 9 | .ember-cli 10 | .gitignore 11 | .jshintrc 12 | .watchmanconfig 13 | .travis.yml 14 | bower.json 15 | ember-cli-build.js 16 | testem.js 17 | -------------------------------------------------------------------------------- /play/rewrite-example.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | var rewriteAMDFunction = require('../lib/rewrite-amd-definition'); 4 | var fs = require('fs'); 5 | 6 | var out = rewriteAMDFunction(fs.readFileSync("./node_modules/d3-scale/build/d3-scale.js"), 'd3-scale'); 7 | 8 | console.log(out); 9 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | module.exports = { 3 | "framework": "qunit", 4 | "test_page": "tests/index.html?hidepassed", 5 | "disable_watching": true, 6 | "launch_in_ci": [ 7 | "PhantomJS" 8 | ], 9 | "launch_in_dev": [ 10 | "PhantomJS", 11 | "Chrome" 12 | ] 13 | }; 14 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from '../../resolver'; 2 | import config from '../../config/environment'; 3 | 4 | const resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log 17 | testem.log 18 | .DS_Store 19 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | let App; 7 | 8 | Ember.MODEL_FACTORY_INJECTIONS = true; 9 | 10 | App = Ember.Application.extend({ 11 | modulePrefix: config.modulePrefix, 12 | podModulePrefix: config.podModulePrefix, 13 | Resolver 14 | }); 15 | 16 | loadInitializers(App, config.modulePrefix); 17 | 18 | export default App; 19 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Application from '../../app'; 3 | import config from '../../config/environment'; 4 | 5 | export default function startApp(attrs) { 6 | let application; 7 | 8 | let attributes = Ember.merge({}, config.APP); 9 | attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; 10 | 11 | Ember.run(() => { 12 | application = Application.create(attributes); 13 | application.setupForTesting(); 14 | application.injectTestHelpers(); 15 | }); 16 | 17 | return application; 18 | } 19 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | /* global require, module */ 3 | var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function(defaults) { 6 | var app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | return app.toTree(); 18 | }; 19 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "-Promise" 6 | ], 7 | "browser": true, 8 | "boss": true, 9 | "curly": true, 10 | "debug": false, 11 | "devel": true, 12 | "eqeqeq": true, 13 | "evil": true, 14 | "forin": false, 15 | "immed": false, 16 | "laxbreak": false, 17 | "newcap": true, 18 | "noarg": true, 19 | "noempty": false, 20 | "nonew": false, 21 | "nomen": false, 22 | "onevar": false, 23 | "plusplus": false, 24 | "regexp": false, 25 | "undef": true, 26 | "sub": true, 27 | "strict": false, 28 | "white": false, 29 | "eqnull": true, 30 | "esnext": true, 31 | "unused": true 32 | } 33 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.js] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [*.hbs] 21 | insert_final_newline = false 22 | indent_style = space 23 | indent_size = 2 24 | 25 | [*.css] 26 | indent_style = space 27 | indent_size = 2 28 | 29 | [*.html] 30 | indent_style = space 31 | indent_size = 2 32 | 33 | [*.{diff,md}] 34 | trim_trailing_whitespace = false 35 | -------------------------------------------------------------------------------- /tests/helpers/module-for-acceptance.js: -------------------------------------------------------------------------------- 1 | import { module } from 'qunit'; 2 | import Ember from 'ember'; 3 | import startApp from '../helpers/start-app'; 4 | import destroyApp from '../helpers/destroy-app'; 5 | 6 | const { RSVP: { Promise } } = Ember; 7 | 8 | export default function(name, options = {}) { 9 | module(name, { 10 | beforeEach() { 11 | this.application = startApp(); 12 | 13 | if (options.beforeEach) { 14 | return options.beforeEach(...arguments); 15 | } 16 | }, 17 | 18 | afterEach() { 19 | let afterEach = options.afterEach && options.afterEach(...arguments); 20 | return Promise.resolve(afterEach).then(() => destroyApp(this.application)); 21 | } 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | - "4" 5 | 6 | sudo: false 7 | 8 | cache: 9 | directories: 10 | - node_modules 11 | 12 | env: 13 | - EMBER_TRY_SCENARIO=default 14 | - EMBER_TRY_SCENARIO=ember-1.13 15 | - EMBER_TRY_SCENARIO=ember-release 16 | - EMBER_TRY_SCENARIO=ember-beta 17 | - EMBER_TRY_SCENARIO=ember-canary 18 | 19 | matrix: 20 | fast_finish: true 21 | allow_failures: 22 | - env: EMBER_TRY_SCENARIO=ember-canary 23 | 24 | before_install: 25 | - npm config set spin false 26 | - npm install -g bower 27 | - npm install phantomjs-prebuilt 28 | 29 | install: 30 | - npm install 31 | - bower install 32 | 33 | script: 34 | # Usually, it's ok to finish the test scenario without reverting 35 | # to the addon's original dependency state, skipping "cleanup". 36 | - ember try $EMBER_TRY_SCENARIO test --skip-cleanup 37 | -------------------------------------------------------------------------------- /tests/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "location", 6 | "setTimeout", 7 | "$", 8 | "-Promise", 9 | "define", 10 | "console", 11 | "visit", 12 | "exists", 13 | "fillIn", 14 | "click", 15 | "keyEvent", 16 | "triggerEvent", 17 | "find", 18 | "findWithAssert", 19 | "wait", 20 | "DS", 21 | "andThen", 22 | "currentURL", 23 | "currentPath", 24 | "currentRouteName" 25 | ], 26 | "node": false, 27 | "browser": false, 28 | "boss": true, 29 | "curly": true, 30 | "debug": false, 31 | "devel": false, 32 | "eqeqeq": true, 33 | "evil": true, 34 | "forin": false, 35 | "immed": false, 36 | "laxbreak": false, 37 | "newcap": true, 38 | "noarg": true, 39 | "noempty": false, 40 | "nonew": false, 41 | "nomen": false, 42 | "onevar": false, 43 | "plusplus": false, 44 | "regexp": false, 45 | "undef": true, 46 | "sub": true, 47 | "strict": false, 48 | "white": false, 49 | "eqnull": true, 50 | "esnext": true, 51 | "unused": true 52 | } 53 | -------------------------------------------------------------------------------- /lib/amd-define-filter.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | var Filter = require('broccoli-filter'); 5 | var rewriteAMDFunction = require('./rewrite-amd-definition'); 6 | 7 | /** 8 | * Loading an actual AMD package using Ember's loader.js 9 | * requires some hacks. Basically proper AMD packages check for define.amd, which 10 | * loader.js doesn't define (because reasons). 11 | * 12 | * To get around this we define our own definition in the same way each Ember 13 | * package does. 14 | */ 15 | 16 | function AMDDefineFilter(inputNode, packageName, options) { 17 | options = options || {}; 18 | Filter.call(this, inputNode, { 19 | annotation: options.annotation || "Rewriting package: " + packageName, 20 | }); 21 | this.packageName = packageName; 22 | } 23 | 24 | AMDDefineFilter.prototype = Object.create(Filter.prototype); 25 | AMDDefineFilter.prototype.constructor = AMDDefineFilter; 26 | AMDDefineFilter.prototype.processString = function(code) { 27 | return rewriteAMDFunction(code, this.packageName); 28 | }; 29 | 30 | module.exports = AMDDefineFilter; 31 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ivan Vanderbyl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {{content-for "body-footer"}} 32 | {{content-for "test-body-footer"}} 33 | 34 | 35 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | module.exports = { 3 | scenarios: [ 4 | { 5 | name: 'default', 6 | bower: { 7 | dependencies: { } 8 | } 9 | }, 10 | { 11 | name: 'ember-1.13', 12 | bower: { 13 | dependencies: { 14 | 'ember': '~1.13.0' 15 | }, 16 | resolutions: { 17 | 'ember': '~1.13.0' 18 | } 19 | } 20 | }, 21 | { 22 | name: 'ember-release', 23 | bower: { 24 | dependencies: { 25 | 'ember': 'components/ember#release' 26 | }, 27 | resolutions: { 28 | 'ember': 'release' 29 | } 30 | } 31 | }, 32 | { 33 | name: 'ember-beta', 34 | bower: { 35 | dependencies: { 36 | 'ember': 'components/ember#beta' 37 | }, 38 | resolutions: { 39 | 'ember': 'beta' 40 | } 41 | } 42 | }, 43 | { 44 | name: 'ember-canary', 45 | bower: { 46 | dependencies: { 47 | 'ember': 'components/ember#canary' 48 | }, 49 | resolutions: { 50 | 'ember': 'canary' 51 | } 52 | } 53 | } 54 | ] 55 | }; 56 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 3 | module.exports = function(environment) { 4 | var ENV = { 5 | modulePrefix: 'dummy', 6 | environment: environment, 7 | baseURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | } 14 | }, 15 | 16 | APP: { 17 | // Here you can pass flags/options to your application instance 18 | // when it is created 19 | } 20 | }; 21 | 22 | if (environment === 'development') { 23 | // ENV.APP.LOG_RESOLVER = true; 24 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 25 | // ENV.APP.LOG_TRANSITIONS = true; 26 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 27 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 28 | } 29 | 30 | if (environment === 'test') { 31 | // Testem prefers this... 32 | ENV.baseURL = '/'; 33 | ENV.locationType = 'none'; 34 | 35 | // keep test console output quieter 36 | ENV.APP.LOG_ACTIVE_GENERATION = false; 37 | ENV.APP.LOG_VIEW_LOOKUPS = false; 38 | 39 | ENV.APP.rootElement = '#ember-testing'; 40 | } 41 | 42 | if (environment === 'production') { 43 | 44 | } 45 | 46 | return ENV; 47 | }; 48 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # ember-cli-d3-shape Changelog 2 | 3 | ### 0.9.3 (June 28, 2016) 4 | 5 | - Removed `let` from index so we can support older Node. 6 | 7 | ### 0.9.2 (June 28, 2016) 8 | 9 | - Updated all D3 packages to 1.0.x stable versions. 10 | 11 | ### 0.9.1 (June 28, 2016) 12 | 13 | - Updated include mechanism to support usage in nested addons, including maximum-plaid. 14 | 15 | ### 0.9.0 (June 27, 2016) 16 | 17 | - Updated D3 packages to 1.0.x in line with D3 version `4.0.0-rc.1`. [See D3 commit](https://github.com/d3/d3/commit/21b6f2b49e8f343de37dbddcf0130ddb97302e66) 18 | - Bumped version to 0.9 as this breaks some time formats, and preparing for `1.0` in a few weeks. 19 | 20 | ### 0.8.7 (June 15, 2016) 21 | 22 | - [#19](https://github.com/ivanvanderbyl/ember-cli-d3-shape/pull/19) Updated D3 dependencies to latest stable releases. 23 | 24 | ### 0.8.6 (June 5, 2016) 25 | 26 | - Updated D3 dependencies to match `d3@4.0.0-alpha.44` 27 | - [#16](https://github.com/ivanvanderbyl/ember-cli-d3-shape/pull/16) Added `d3-brush` alpha. 28 | 29 | ### 0.8.5 (May 18, 2016) 30 | 31 | - [#11](https://github.com/ivanvanderbyl/ember-cli-d3-shape/pull/11) Updated ember-cli to 2.5.0 32 | - [#13](https://github.com/ivanvanderbyl/ember-cli-d3-shape/pull/13) Removed dummy app (see `ivanvanderbyl/maximum-plaid` instead) 33 | 34 | ### 0.8.4 (May 16, 2016) 35 | 36 | - Corrected version number on changelog 37 | - Added tests for module loading 38 | 39 | ### 0.8.2 (May 16, 2016) 40 | 41 | - Updated D3 packages to match 4.0.0-alpha.40: 42 | - d3-axis 0.3.0 => 0.3.1 43 | - d3-dsv 0.3.1 => 0.3.2 44 | - d3-quadtree 0.2.1 => 0.7.2 45 | - d3-request 0.4.5 => 0.4.6 46 | - d3-scale 0.6.4 => 0.7.0 47 | - d3-selection 0.7.0 => 0.7.2 48 | - d3-time-format 0.3.1 => 0.3.2 49 | - d3-timer 0.4.1 => 0.4.3 50 | - Added D3 packages: 51 | - d3-drag 0.1.2 52 | - d3-force 0.6.2 53 | - d3-hierarchy 0.2.2 54 | - Added a changelog. 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-d3-shape", 3 | "version": "0.9.4-4.1.1.0", 4 | "description": "Data-Driven Documents for Ember", 5 | "directories": { 6 | "doc": "doc", 7 | "test": "tests" 8 | }, 9 | "scripts": { 10 | "build": "ember build", 11 | "start": "ember server", 12 | "test": "ember try:each" 13 | }, 14 | "repository": "ivanvanderbyl/ember-cli-d3-shape", 15 | "engines": { 16 | "node": ">= 0.10.0" 17 | }, 18 | "author": "Ivan Vanderbyl", 19 | "license": "MIT", 20 | "devDependencies": { 21 | "broccoli-asset-rev": "^2.4.2", 22 | "ember-ajax": "2.3.1", 23 | "ember-cli": "2.6.2", 24 | "ember-cli-app-version": "^1.0.0", 25 | "ember-cli-dependency-checker": "^1.2.0", 26 | "ember-cli-htmlbars": "^1.0.3", 27 | "ember-cli-htmlbars-inline-precompile": "^0.3.1", 28 | "ember-cli-inject-live-reload": "^1.4.0", 29 | "ember-cli-jshint": "^1.0.0", 30 | "ember-cli-qunit": "^2.0.0", 31 | "ember-cli-release": "^1.0.0-beta.1", 32 | "ember-cli-sri": "^2.1.0", 33 | "ember-cli-uglify": "^1.2.0", 34 | "ember-disable-prototype-extensions": "^1.1.0", 35 | "ember-export-application-global": "^1.0.5", 36 | "ember-load-initializers": "^0.5.1", 37 | "ember-resolver": "^2.0.3", 38 | "ember-suave": "2.0.1", 39 | "loader.js": "^4.0.1", 40 | "npm-registry-client": "^7.1.1", 41 | "semver": "^5.1.0" 42 | }, 43 | "keywords": [ 44 | "ember-addon", 45 | "d3", 46 | "d3-shape", 47 | "canvas", 48 | "visualisation", 49 | "new d3" 50 | ], 51 | "dependencies": { 52 | "broccoli-filter": "^1.2.3", 53 | "broccoli-funnel": "^1.0.1", 54 | "broccoli-merge-trees": "^1.1.1", 55 | "broccoli-persistent-filter": "^1.1.6", 56 | "broccoli-stew": "^1.3.2", 57 | "d3": "4.1.1", 58 | "ember-cli-babel": "^5.1.6", 59 | "recast": "^0.11.0", 60 | "walk-sync": "^0.2.7" 61 | }, 62 | "ember-addon": { 63 | "configPath": "tests/dummy/config" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /bin/update-d3-dependencies.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | let packageDependencies = require('../package.json').dependencies; 5 | let semver = require('semver'); 6 | let RegClient = require('npm-registry-client'); 7 | let RSVP = require('rsvp'); 8 | let npm = require('ember-cli/lib/utilities/npm'); 9 | 10 | let packages = Object.keys(packageDependencies) 11 | .filter((packageName) => /^d3\-/.test(packageName)) 12 | .map((packageName) => ({ name: packageName, version: packageDependencies[packageName] })); 13 | 14 | let client = new RegClient(); 15 | 16 | let npmOptions = { 17 | loglevel: 'error', 18 | color: 'always', 19 | // by default, do install peoples optional deps 20 | 'optional': true, 21 | 'save': true, 22 | 'save-exact': true 23 | }; 24 | 25 | let updates = []; 26 | let updatePromises = []; 27 | 28 | packages.forEach((pkg) => { 29 | let uri = `https://registry.npmjs.org/${pkg.name}`; 30 | let params = { timeout: 1000 }; 31 | 32 | updatePromises.push(new RSVP.Promise(function(resolve, reject) { 33 | client.get(uri, params, function(error, data, raw, res) { 34 | if (!error) { 35 | let newVersions = Object.keys(data.versions).filter((version) => semver.gtr(version, pkg.version)); 36 | let updateVersion = newVersions.splice(-1); 37 | if (newVersions.length > 0) { 38 | console.log(`Udpate ${pkg.name} ${pkg.version} => ${updateVersion}`); 39 | updates.push({ name: pkg.name, oldVersion: pkg.version, newVersion: updateVersion }); 40 | 41 | npm('install', [`${pkg.name}@${updateVersion}`], npmOptions) 42 | .then(resolve, reject); 43 | } else { 44 | // console.log(`${pkg.name} UP TO DATE`); 45 | } 46 | } else { 47 | reject(error); 48 | } 49 | }); 50 | })); 51 | }); 52 | 53 | RSVP.all(updatePromises).then((updates) => { 54 | console.log('DONE'); 55 | console.log(updates); 56 | }).catch((err) => { 57 | console.log('FAILED'); 58 | console.error(err); 59 | }); 60 | 61 | // console.log(updates); 62 | -------------------------------------------------------------------------------- /lib/rewrite-amd-definition.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | var recast = require("recast"); 5 | var types = recast.types; 6 | var namedTypes = types.namedTypes; 7 | var b = recast.types.builders; 8 | 9 | function buildExportDefaultDefinition(packageName, deps, node) { 10 | return b.expressionStatement( 11 | b.callExpression( 12 | b.identifier('define'), [ 13 | b.literal(packageName), 14 | b.arrayExpression(deps.map(function(name) { return b.literal(name); })), 15 | node 16 | ] 17 | ) 18 | ); 19 | } 20 | 21 | function getDependenciesForDefine(node) { 22 | if (namedTypes.CallExpression.check(node)) { 23 | return node.arguments[0].elements.map(function(e) { return e.value; }); 24 | }else{ 25 | return []; 26 | } 27 | } 28 | 29 | function isAMDFunctionBody(node) { 30 | return namedTypes.FunctionExpression.check(node) && 31 | node.id === null && 32 | !!node.params && 33 | namedTypes.Identifier.check(node.params[0]) && 34 | node.params[0].name === 'exports'; 35 | } 36 | 37 | function isDefineCallExpression(node) { 38 | return namedTypes.CallExpression.check(node) && 39 | node.callee.name === 'define' && 40 | !!node.arguments && 41 | namedTypes.ArrayExpression.check(node.arguments[0]) && 42 | node.arguments[0].elements[0].value === 'exports' && 43 | node.arguments[1].name === 'factory'; 44 | } 45 | 46 | module.exports = function rewriteAMDFunction(code, packageName){ 47 | var ast = recast.parse(code); 48 | 49 | var amdDependencies, amdFunctionBody; 50 | 51 | types.visit(ast, { 52 | visitCallExpression: function(path) { 53 | if (isDefineCallExpression(path.node)) { 54 | amdDependencies = getDependenciesForDefine(path.node); 55 | } 56 | this.traverse(path); 57 | }, 58 | 59 | visitFunctionExpression: function(path) { 60 | if(isAMDFunctionBody(path.node)){ 61 | amdFunctionBody = path.node; 62 | } 63 | this.traverse(path); 64 | } 65 | }); 66 | 67 | ast = buildExportDefaultDefinition(packageName, amdDependencies, amdFunctionBody); 68 | return recast.print(ast).code; 69 | }; 70 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | var Funnel = require('broccoli-funnel'); 5 | var mergeTrees = require('broccoli-merge-trees'); 6 | var path = require('path'); 7 | var rename = require('broccoli-stew').rename; 8 | var AMDDefineFilter = require('./lib/amd-define-filter'); 9 | var fs = require('fs'); 10 | 11 | function lookupPackage(packageName) { 12 | var modulePath = require.resolve(packageName); 13 | var i = modulePath.lastIndexOf(path.sep + 'build'); 14 | return modulePath.slice(0, i); 15 | } 16 | 17 | module.exports = { 18 | isDevelopingAddon: function() { 19 | return false; 20 | }, 21 | 22 | name: 'ember-cli-d3-shape', 23 | 24 | d3Modules: [ 25 | // Imported from package.json 26 | ], 27 | 28 | /** 29 | * `import()` taken from ember-cli 2.7 30 | */ 31 | import: function(asset, options) { 32 | var app = this.app; 33 | while (app.app) { 34 | app = app.app; 35 | } 36 | app.import(asset, options); 37 | }, 38 | 39 | included: function(app) { 40 | this._super.included && this._super.included.apply(this, arguments); 41 | this.app = app; 42 | 43 | while (app.app) { 44 | app = app.app; 45 | } 46 | 47 | var pkg = require(path.join(lookupPackage('d3'), 'package.json')); 48 | 49 | // Find all dependencies of `d3` 50 | 51 | this.d3Modules = Object.keys(pkg.dependencies).filter(function(name) { 52 | return /^d3\-/.test(name); 53 | }); 54 | 55 | // This essentially means we'll skip importing this package twice, if it's 56 | // a dependency of another package. 57 | if (!app.import) { 58 | if (this.isDevelopingAddon()) { 59 | console.log('[ember-cli-d3-shape] skipping included hook for', app.name); 60 | } 61 | return; 62 | } 63 | 64 | var _this = this; 65 | this.d3Modules.forEach(function(packageName) { 66 | _this.import(path.join('vendor', packageName, packageName + '.js')); 67 | }); 68 | }, 69 | 70 | treeForVendor: function(tree) { 71 | var trees = []; 72 | 73 | if (tree) { 74 | trees.push(tree); 75 | } 76 | 77 | var d3PackagePath = lookupPackage('d3'); 78 | 79 | this.d3Modules.forEach(function(packageName) { 80 | var d3PathToSrc, srcTree; 81 | 82 | // Import existing builds from node d3 packages, which are UMD packaged. 83 | var packageBuildPath = path.join('build', packageName + '.js'); 84 | 85 | d3PathToSrc = path.join(d3PackagePath, 'node_modules', packageName); 86 | 87 | try { 88 | fs.statSync(path.join(d3PathToSrc)).isDirectory(); 89 | } catch(err) { 90 | d3PathToSrc = lookupPackage(packageName); 91 | } 92 | 93 | try { 94 | fs.statSync(path.join(d3PathToSrc, packageBuildPath)).isFile() 95 | } catch(err) { 96 | console.error('[ERROR] D3 Package (' + packageName + ') is not built as expected, cannot continue. Please report this as a bug.'); 97 | return; 98 | } 99 | 100 | var tree = new Funnel(d3PathToSrc, { 101 | include: [packageBuildPath], 102 | destDir: '/' + packageName, 103 | annotation: 'Funnel: D3 Source [' + packageName + ']' 104 | }); 105 | 106 | srcTree = new AMDDefineFilter(tree, packageName); 107 | trees.push(rename(srcTree, function() { 108 | return '/' + packageName + '/' + packageName + '.js'; 109 | })); 110 | }); 111 | 112 | return mergeTrees(trees); 113 | } 114 | }; 115 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | 3 | **Please use [ember-d3](https://github.com/brzpegasus/ember-d3) instead for continues D3@v4.x support as a drop in replacement. This repo is no longer maintained :beers:** 4 | 5 |
6 | 7 | # ember-cli-d3-shape 8 | 9 | [![Build Status](https://travis-ci.org/ivanvanderbyl/ember-cli-d3-shape.svg?branch=master)](https://travis-ci.org/ivanvanderbyl/ember-cli-d3-shape) [![Ember Observer Score](https://emberobserver.com/badges/ember-cli-d3-shape.svg)](https://emberobserver.com/addons/ember-cli-d3-shape) [![npm version](https://badge.fury.io/js/ember-cli-d3-shape.svg)](https://badge.fury.io/js/ember-cli-d3-shape) [![Dependency Status](https://david-dm.org/ivanvanderbyl/ember-cli-d3-shape.svg)](https://david-dm.org/ivanvanderbyl/ember-cli-d3-shape) [![devDependency Status](https://david-dm.org/ivanvanderbyl/ember-cli-d3-shape/dev-status.svg)](https://david-dm.org/ivanvanderbyl/ember-cli-d3-shape#info=devDependencies) 10 | 11 | `ember-cli-d3-shape` is a shim for D3 `4.x`, loaded from NPM as ES6 modules. It includes `d3-shape` and all version 4 modules in D3 `4.x`. 12 | 13 | --- 14 | 15 | D3 Shape is a set of primitives for building complex data visualisations. Because 16 | it depends on all the other components of D3, this package also provides all other 17 | D3 `v4.0` packages (see below for a list). 18 | 19 | This addon is just a shim, if you're looking for a more high level visualisation addon, 20 | check out [maximum-plaid](https://github.com/ivanvanderbyl/maximum-plaid). 21 | 22 | Each package is importable as per the D3 documentation for each package. 23 | This also means that you don't need to import the entire `d3.js` build into your App if you 24 | only need a function or two. For example, check out [d3-array](https://github.com/d3/d3-array) for 25 | an extensive library of useful Array functions not natively found in Javascript. 26 | 27 | Example usage: 28 | 29 | ```js 30 | import { line } from 'd3-shape'; 31 | import { scaleOrdinal } from 'd3-scale'; 32 | import { extent } from 'd3-array'; 33 | ``` 34 | 35 | ### Included D3 modules: 36 | 37 | - [d3-array](https://github.com/d3/d3-array) 38 | - [d3-axis](https://github.com/d3/d3-axis) 39 | - [d3-brush](https://github.com/d3/d3-brush) 40 | - [d3-collection](https://github.com/d3/d3-collection) 41 | - [d3-color](https://github.com/d3/d3-color) 42 | - [d3-dispatch](https://github.com/d3/d3-dispatch) 43 | - [d3-drag](https://github.com/d3/d3-drag) 44 | - [d3-dsv](https://github.com/d3/d3-dsv) 45 | - [d3-ease](https://github.com/d3/d3-ease) 46 | - [d3-force](https://github.com/d3/d3-force) 47 | - [d3-format](https://github.com/d3/d3-format) 48 | - [d3-hierarchy](https://github.com/d3/d3-hierarchy) 49 | - [d3-interpolate](https://github.com/d3/d3-interpolate) 50 | - [d3-path](https://github.com/d3/d3-path) 51 | - [d3-polygon](https://github.com/d3/d3-polygon) 52 | - [d3-quadtree](https://github.com/d3/d3-quadtree) 53 | - [d3-queue](https://github.com/d3/d3-queue) 54 | - [d3-random](https://github.com/d3/d3-random) 55 | - [d3-request](https://github.com/d3/d3-request) 56 | - [d3-scale](https://github.com/d3/d3-scale) 57 | - [d3-selection](https://github.com/d3/d3-selection) 58 | - [d3-shape](https://github.com/d3/d3-shape) 59 | - [d3-time](https://github.com/d3/d3-time) 60 | - [d3-time-format](https://github.com/d3/d3-time-format) 61 | - [d3-timer](https://github.com/d3/d3-timer) 62 | - [d3-transition](https://github.com/d3/d3-transition) 63 | - [d3-voronoi](https://github.com/d3/d3-voronoi) 64 | - [d3-zoom](https://github.com/d3/d3-zoom) 65 | 66 | _This addon will be updated when new releases are cut of these packages. 67 | Currently none of these are 1.0 stable, so some of your code might break by 68 | upgrading. It is recommended that you have solid tests in place._ 69 | 70 | ## Installation & Usage 71 | 72 | Install this like any other Ember Addon: 73 | 74 | ```bash 75 | ember install ember-cli-d3-shape 76 | ``` 77 | 78 | Then import what you need from each module: 79 | 80 | ```js 81 | import { curveCardinalOpen } from 'd3-shape'; 82 | import { select } from 'd3-selection'; 83 | 84 | export default Ember.Component.extend({ 85 | didInsertElement() { 86 | this.plot = select(this.element.querySelector('svg')); 87 | }, 88 | 89 | didRender() { 90 | // NOTE: Do things with the DOM after it has rendered. 91 | this.plot.append('rect').attr('fill', '#15CD72'); 92 | } 93 | }); 94 | ``` 95 | 96 | ## Running 97 | 98 | * `ember server` 99 | * Visit your app at http://localhost:4200. 100 | 101 | ## Running Tests 102 | 103 | * `npm test` (Runs `ember try:testall` to test your addon against multiple Ember versions) 104 | * `ember test` 105 | * `ember test --server` 106 | 107 | ## Building 108 | 109 | * `ember build` 110 | 111 | For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/). 112 | -------------------------------------------------------------------------------- /tests/unit/loading-d3-modules-test.js: -------------------------------------------------------------------------------- 1 | import { module, test } from 'qunit'; 2 | import { mean } from 'd3-array'; 3 | import { axisTop } from 'd3-axis'; 4 | import { brush } from 'd3-brush'; 5 | import { keys } from 'd3-collection'; 6 | import { color } from 'd3-color'; 7 | import { dispatch } from 'd3-dispatch'; 8 | import { drag } from 'd3-drag'; 9 | import { csvParse } from 'd3-dsv'; 10 | import { easeLinear } from 'd3-ease'; 11 | import { forceSimulation } from 'd3-force'; 12 | import { format } from 'd3-format'; 13 | import { hierarchy } from 'd3-hierarchy'; 14 | import { interpolateNumber } from 'd3-interpolate'; 15 | import { path } from 'd3-path'; 16 | import { polygonCentroid } from 'd3-polygon'; 17 | import { quadtree } from 'd3-quadtree'; 18 | import { queue } from 'd3-queue'; 19 | import { randomUniform } from 'd3-random'; 20 | import { request } from 'd3-request'; 21 | import { scaleLinear } from 'd3-scale'; 22 | import { select } from 'd3-selection'; 23 | import { line } from 'd3-shape'; 24 | import { timeDay } from 'd3-time'; 25 | import { timeFormat } from 'd3-time-format'; 26 | import { timeout } from 'd3-timer'; 27 | import { transition } from 'd3-transition'; 28 | import { voronoi } from 'd3-voronoi'; 29 | 30 | module('Unit | D3 Module Loading Test'); 31 | 32 | test('loading d3-array', function(assert) { 33 | assert.equal(mean([1,2,3]), 2); 34 | }); 35 | 36 | test('loading d3-axis', function(assert) { 37 | assert.equal(typeof axisTop, 'function', 'loaded axisTop'); 38 | }); 39 | 40 | test('loading d3-brush', function(assert) { 41 | assert.equal(typeof brush, 'function', 'loaded brush'); 42 | }); 43 | 44 | test('loading d3-collection', function(assert) { 45 | assert.equal(typeof keys, 'function', 'loaded keys'); 46 | }); 47 | 48 | test('loading d3-color', function(assert) { 49 | assert.equal(color('#FFFFFF').toString(), 'rgb(255, 255, 255)', 'loaded color'); 50 | }); 51 | 52 | test('loading d3-dispatch', function(assert) { 53 | assert.expect(1); 54 | let handler = dispatch('start'); 55 | handler.on('start', function(value) { 56 | assert.ok(value, 'it works'); 57 | }); 58 | handler.call('start', this, true); 59 | }); 60 | 61 | test('loading d3-drag', function(assert) { 62 | assert.equal(typeof drag, 'function', 'loaded drag'); 63 | }); 64 | 65 | test('loading d3-dsv', function(assert) { 66 | assert.deepEqual(csvParse('name,location\nIvan,Unknown'), [ 67 | { 68 | 'location': 'Unknown', 69 | 'name': 'Ivan' 70 | } 71 | ], 'loaded dsv'); 72 | }); 73 | 74 | test('loading d3-ease', function(assert) { 75 | assert.equal(easeLinear(0.1), 0.1, 'loaded easeLinear'); 76 | }); 77 | 78 | test('loading d3-force', function(assert) { 79 | assert.equal(typeof forceSimulation, 'function', 'loaded forceSimulation'); 80 | }); 81 | 82 | test('loading d3-format', function(assert) { 83 | assert.equal(format('$,.2f')(1200.98), '$1,200.98', 'loaded d3 format'); 84 | }); 85 | 86 | test('loading d3-hierarchy', function(assert) { 87 | assert.equal(typeof hierarchy, 'function', 'loaded hierarchy'); 88 | }); 89 | 90 | test('loading d3-interpolate', function(assert) { 91 | assert.equal(interpolateNumber(10, 20)(0.2), 12, 'loaded interpolate'); 92 | }); 93 | 94 | test('loading d3-path', function(assert) { 95 | let p = path(); 96 | p.moveTo(10, 10); 97 | p.lineTo(10, 20); 98 | p.closePath(); 99 | assert.equal(p.toString(), 'M10,10L10,20Z', 'loaded path'); 100 | }); 101 | 102 | test('loading d3-polygon', function(assert) { 103 | assert.deepEqual(polygonCentroid([[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]), [0.5,0.5], 'loaded polygonCentroid'); 104 | }); 105 | 106 | test('loading d3-quadtree', function(assert) { 107 | let q = quadtree(); 108 | assert.deepEqual(q.add([0, 0]).root(), { data: [0, 0] }); 109 | assert.deepEqual(q.add([1, 1]).root(), [{ data: [0, 0] }, undefined, undefined, { data: [1, 1] }]); 110 | assert.deepEqual(q.add([1, 0]).root(), [{ data: [0, 0] }, { data: [1, 0] }, undefined, { data: [1, 1] }]); 111 | assert.deepEqual(q.add([0, 1]).root(), [{ data: [0, 0] }, { data: [1, 0] }, { data: [0, 1] }, { data: [1, 1] }]); 112 | }); 113 | 114 | test('loading d3-queue', function(assert) { 115 | let done = assert.async(); 116 | assert.expect(2); 117 | let t = function(callback) { 118 | setTimeout(function() { 119 | callback(null, 10); 120 | }, 30); 121 | }; 122 | 123 | queue().defer(t).awaitAll(callback); 124 | 125 | function callback(error, results) { 126 | assert.equal(null, error); 127 | assert.deepEqual(results, [ 10 ]); 128 | done(); 129 | } 130 | }); 131 | 132 | test('loading d3-random', function(assert) { 133 | assert.equal(randomUniform(6, 10)() > 6, true, 'loaded random'); 134 | }); 135 | 136 | test('loading d3-request', function(assert) { 137 | assert.equal(typeof request, 'function', 'loaded request'); 138 | }); 139 | 140 | test('loading d3-scale', function(assert) { 141 | let xScale = scaleLinear().domain([0,100]).rangeRound([0,500]); 142 | assert.equal(xScale(10), 50, 'loaded scale'); 143 | }); 144 | 145 | test('loading d3-selection', function(assert) { 146 | assert.equal(typeof select, 'function', 'loaded selection'); 147 | }); 148 | 149 | test('loading d3-shape', function(assert) { 150 | let l = line(); 151 | l.x((d) => d.x); 152 | l.y((d) => d.y); 153 | let data = [ 154 | { x: 1, y: 93.24 }, 155 | { x: 2, y: 95.35 }, 156 | { x: 3, y: 98.84 }, 157 | { x: 4, y: 99.92 }, 158 | { x: 5, y: 99.80 }, 159 | { x: 6, y: 99.47 } 160 | ]; 161 | 162 | assert.equal(l(data), 'M1,93.24L2,95.35L3,98.84L4,99.92L5,99.8L6,99.47', 'loaded shape'); 163 | }); 164 | 165 | test('loading d3-time', function(assert) { 166 | assert.deepEqual(timeDay.floor(new Date(2010, 11, 31, 23)), new Date(2010, 11, 31)); 167 | assert.deepEqual(timeDay.floor(new Date(2011, 0, 1, 0)), new Date(2011, 0, 1)); 168 | assert.deepEqual(timeDay.floor(new Date(2011, 0, 1, 1)), new Date(2011, 0, 1)); 169 | }); 170 | 171 | test('loading d3-time-format', function(assert) { 172 | let f = timeFormat('%c'); 173 | assert.equal(f(+new Date(1990, 0, 1)), '1/1/1990, 12:00:00 AM'); 174 | }); 175 | 176 | test('loading d3-timer', function(assert) { 177 | assert.expect(1); 178 | let done = assert.async(); 179 | let delay = 50; 180 | timeout(function() { 181 | assert.ok(true, 'loaded timer'); 182 | done(); 183 | }, delay); 184 | }); 185 | 186 | test('loading d3-transition', function(assert) { 187 | assert.equal(typeof transition, 'function', 'loaded transition'); 188 | }); 189 | 190 | test('loading d3-voronoi', function(assert) { 191 | let v = voronoi(); 192 | assert.equal(v.extent(), null); 193 | assert.equal(v.size(), null); 194 | assert.equal(v.x()([1, 2]), 1); 195 | assert.equal(v.y()([1, 2]), 2); 196 | }); 197 | --------------------------------------------------------------------------------