├── .gitignore
├── .idea
├── .name
├── chartographer.iml
├── codeStyleSettings.xml
├── encodings.xml
├── jsLibraryMappings.xml
├── libraries
│ └── chartographer_node_modules.xml
├── misc.xml
├── modules.xml
├── scopes
│ └── scope_settings.xml
├── vcs.xml
├── webResources.xml
└── workspace.xml
├── Gruntfile.js
├── LICENSE
├── README.md
├── bower.json
├── bower_components
├── d3
│ ├── .bower.json
│ ├── .spmignore
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── bower.json
│ ├── composer.json
│ ├── d3.js
│ └── d3.min.js
└── plottable
│ ├── .bower.json
│ ├── bower.json
│ ├── plottable.css
│ ├── plottable.d.ts
│ ├── plottable.js
│ └── plottable.min.js
├── chartographer.d.ts
├── chartographer.js
├── chartographer.ts
├── examples
└── line.html
├── license_header.txt
├── package.json
├── tsd.json
├── tslint.json
└── typings
└── d3
└── d3.d.ts
/.gitignore:
--------------------------------------------------------------------------------
1 | .tscache/
2 | node_modules/
3 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | chartographer
--------------------------------------------------------------------------------
/.idea/chartographer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/codeStyleSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/jsLibraryMappings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/libraries/chartographer_node_modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/webResources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | $PROJECT_DIR$/Gruntfile.js
60 |
61 |
62 | false
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | 1410157603873
138 | 1410157603873
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function(grunt) {
2 | "use strict";
3 |
4 | var path = require("path");
5 | var cwd = process.cwd();
6 |
7 | var tsJSON = {
8 | dev: {
9 | src: ["chartographer.ts", "typings/d3/d3.d.ts", "bower_components/plottable/plottable.d.ts"],
10 | outDir: ".",
11 | options: {
12 | target: 'es5',
13 | noImplicitAny: false,
14 | sourceMap: false,
15 | declaration: true,
16 | compiler: "./node_modules/grunt-ts/customcompiler/tsc",
17 | removeComments: false
18 | }
19 | }
20 | };
21 |
22 | // poor man's deep copy
23 | var deepCopy = function(x) {
24 | return JSON.parse(JSON.stringify(x));
25 | };
26 |
27 | tsJSON.dev_release = deepCopy(tsJSON.dev);
28 | delete tsJSON.dev_release.options.compiler;
29 |
30 | var bumpJSON = {
31 | options: {
32 | files: ['package.json', 'bower.json'],
33 | updateConfigs: ['pkg'],
34 | commit: false,
35 | createTag: false,
36 | push: false
37 | }
38 | };
39 | var configJSON = {
40 | pkg: grunt.file.readJSON("package.json"),
41 | bump: bumpJSON,
42 | concat: {
43 | header: {
44 | src: ["license_header.txt", "chartographer.js"],
45 | dest: "chartographer.js",
46 | }
47 | },
48 | sed: {
49 | version_number: {
50 | pattern: "@VERSION",
51 | replacement: "<%= pkg.version %>",
52 | path: "chartographer.js"
53 | }
54 | },
55 | ts: tsJSON,
56 | tslint: {
57 | options: {
58 | configuration: grunt.file.readJSON("tslint.json")
59 | },
60 | files: ["*.ts"]
61 | },
62 | jshint: {
63 | files: ['Gruntfile.js', 'quicktests/**/*.js'],
64 | options: {
65 | "curly": true,
66 | "eqeqeq": true,
67 | "evil": true,
68 | "indent": 2,
69 | "latedef": true,
70 | "globals": {
71 | "jQuery": true,
72 | "d3": true,
73 | "window": true,
74 | "console": true,
75 | "$": true,
76 | "makeRandomData": true,
77 | "setTimeout": true,
78 | "document": true,
79 | "Plottable": true
80 | },
81 | "strict": true,
82 | "eqnull": true
83 | }
84 | },
85 | watch: {
86 | "options": {
87 | livereload: 35731
88 | },
89 | "rebuild": {
90 | "tasks": ["dev-compile"],
91 | "files": ["chartographer.ts"]
92 | }
93 | },
94 | connect: {
95 | server: {
96 | options: {
97 | port: 9998,
98 | hostname: "*",
99 | base: "",
100 | livereload: 35731
101 | }
102 | }
103 | },
104 | clean: {
105 | tscommand: ["tscommand*.tmp.txt"]
106 | },
107 | uglify: {
108 | main: {
109 | files: {'chartographer.min.js': ['chartographer.js']}
110 | }
111 | }
112 | };
113 |
114 |
115 | // project configuration
116 | grunt.initConfig(configJSON);
117 |
118 | require('load-grunt-tasks')(grunt);
119 |
120 | grunt.registerTask("default", "launch");
121 | function makeDevCompile(release) {
122 | return [
123 | release ? "ts:dev_release" : "ts:dev",
124 | "concat:header",
125 | "sed",
126 | "clean:tscommand"
127 | ];
128 | }
129 |
130 | grunt.registerTask("dev-compile", makeDevCompile(false));
131 | grunt.registerTask("release-compile", makeDevCompile(true));
132 |
133 | grunt.registerTask("release:patch", ["bump:patch", "dist-compile"]);
134 | grunt.registerTask("release:minor", ["bump:minor", "dist-compile"]);
135 | grunt.registerTask("release:major", ["bump:major", "dist-compile"]);
136 |
137 | grunt.registerTask("dist-compile", [
138 | "release-compile",
139 | "tslint",
140 | "uglify",
141 | ]);
142 |
143 |
144 | grunt.registerTask("launch", ["connect", "dev-compile", "watch"]);
145 | };
146 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Palantir Technologies, Inc.
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
13 | all 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
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Chartographer
2 |
3 | Charographer is a simple declarative API for creating pretty charts on websites. It uses [Plottable](http://plottablejs.org/), a modular charting library, to create easy reusable charts. Since Plottable is built on D3, it implicitly uses D3 and SVG for rendering. CSS can be used for most styling (e.g. font sizes and gridline thickness) although color choice depends on API usage.
4 |
5 | Chartographer makes it trivially easy to produce elegant charts, and its API has a 1-to-1 correspondance with JSON, so charts can be generated using its API or by inputting properly formatted JSON objects.
6 |
7 | Chartographer strongly favors convention over configuration. If you want to make more bespoke charts or tweak them, Plottable is a far more flexible library for chart creation. The Chartographer source is deliberately simple to read and Chartographer templates are a great jumping off point for creating more complex charts using Plottable.
8 |
9 | ## License
10 |
11 | Chartographer is made available under the MIT License. Copyright 2014, Palantir Technologies.
12 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "chartographer",
3 | "description": "A library of simple charts made with Plottable and D3",
4 | "version": "0.1.0",
5 | "main": ["chartographer.js"],
6 | "license": "MIT",
7 | "ignore": [
8 | "**/*",
9 | "!bower.json",
10 | "!chartographer.js",
11 | "!chartographer.min.js",
12 | "!chartographer.d.ts"
13 | ],
14 | "keywords": [
15 | "chartographer",
16 | "chartographerjs",
17 | "chartographer.js",
18 | "plottable",
19 | "plottablejs",
20 | "plottable.js",
21 | "d3",
22 | "data viz",
23 | "chart",
24 | "charts",
25 | "reusable charts",
26 | "visualization",
27 | "scatterplot",
28 | "bar chart",
29 | "plot",
30 | "plots"
31 | ],
32 | "dependencies": {
33 | "plottable": "0.35.0"
34 | },
35 | "homepage": "http://github.com/palantir/chartographer",
36 | "repository": {
37 | "type": "git",
38 | "url": "git://github.com/palantir/chartographer.git"
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/bower_components/d3/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3",
3 | "version": "3.4.13",
4 | "main": "d3.js",
5 | "scripts": [
6 | "d3.js"
7 | ],
8 | "ignore": [
9 | ".DS_Store",
10 | ".git",
11 | ".gitignore",
12 | ".npmignore",
13 | ".travis.yml",
14 | "Makefile",
15 | "bin",
16 | "component.json",
17 | "index.js",
18 | "lib",
19 | "node_modules",
20 | "package.json",
21 | "src",
22 | "test"
23 | ],
24 | "homepage": "https://github.com/mbostock/d3",
25 | "_release": "3.4.13",
26 | "_resolution": {
27 | "type": "version",
28 | "tag": "v3.4.13",
29 | "commit": "e2dc80f5385c153066150075a4208131e0b78c68"
30 | },
31 | "_source": "git://github.com/mbostock/d3.git",
32 | "_target": "3.4.13",
33 | "_originalSource": "d3"
34 | }
--------------------------------------------------------------------------------
/bower_components/d3/.spmignore:
--------------------------------------------------------------------------------
1 | bin
2 | lib
3 | src
4 | test
5 |
--------------------------------------------------------------------------------
/bower_components/d3/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | If you’re looking for ways to contribute, please [peruse open issues](https://github.com/mbostock/d3/issues?milestone=&page=1&state=open). The icebox is a good place to find ideas that are not currently in development. If you already have an idea, please check past issues to see whether your idea or a similar one was previously discussed.
4 |
5 | Before submitting a pull request, consider implementing a live example first, say using [bl.ocks.org](http://bl.ocks.org). Real-world use cases go a long way to demonstrating the usefulness of a proposed feature. The more complex a feature’s implementation, the more usefulness it should provide. Share your demo using the #d3js tag on Twitter or by sending it to the d3-js Google group.
6 |
7 | If your proposed feature does not involve changing core functionality, consider submitting it instead as a [D3 plugin](https://github.com/d3/d3-plugins). New core features should be for general use, whereas plugins are suitable for more specialized use cases. When in doubt, it’s easier to start with a plugin before “graduating” to core.
8 |
9 | To contribute new documentation or add examples to the gallery, just [edit the Wiki](https://github.com/mbostock/d3/wiki)!
10 |
11 | ## How to Submit a Pull Request
12 |
13 | 1. Click the “Fork” button to create your personal fork of the D3 repository.
14 |
15 | 2. After cloning your fork of the D3 repository in the terminal, run `npm install` to install D3’s dependencies.
16 |
17 | 3. Create a new branch for your new feature. For example: `git checkout -b my-awesome-feature`. A dedicated branch for your pull request means you can develop multiple features at the same time, and ensures that your pull request is stable even if you later decide to develop an unrelated feature.
18 |
19 | 4. The `d3.js` and `d3.min.js` files are built from source files in the `src` directory. _Do not edit `d3.js` directly._ Instead, edit the source files, and then run `make` to build the generated files.
20 |
21 | 5. Use `make test` to run tests and verify your changes. If you are adding a new feature, you should add new tests! If you are changing existing functionality, make sure the existing tests run, or update them as appropriate.
22 |
23 | 6. Sign D3’s [Individual Contributor License Agreement](https://docs.google.com/forms/d/1CzjdBKtDuA8WeuFJinadx956xLQ4Xriv7-oDvXnZMaI/viewform). Unless you are submitting a trivial patch (such as fixing a typo), this form is needed to verify that you are able to contribute.
24 |
25 | 7. Submit your pull request, and good luck!
26 |
--------------------------------------------------------------------------------
/bower_components/d3/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010-2014, Michael Bostock
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * The name Michael Bostock may not be used to endorse or promote products
15 | derived from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
--------------------------------------------------------------------------------
/bower_components/d3/README.md:
--------------------------------------------------------------------------------
1 | # Data-Driven Documents
2 |
3 |
4 |
5 | **D3.js** is a JavaScript library for manipulating documents based on data. **D3** helps you bring data to life using HTML, SVG and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation.
6 |
7 | Want to learn more? [See the wiki.](https://github.com/mbostock/d3/wiki)
8 |
9 | For examples, [see the gallery](https://github.com/mbostock/d3/wiki/Gallery) and [mbostock’s bl.ocks](http://bl.ocks.org/mbostock).
10 |
--------------------------------------------------------------------------------
/bower_components/d3/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3",
3 | "version": "3.4.13",
4 | "main": "d3.js",
5 | "scripts": [
6 | "d3.js"
7 | ],
8 | "ignore": [
9 | ".DS_Store",
10 | ".git",
11 | ".gitignore",
12 | ".npmignore",
13 | ".travis.yml",
14 | "Makefile",
15 | "bin",
16 | "component.json",
17 | "index.js",
18 | "lib",
19 | "node_modules",
20 | "package.json",
21 | "src",
22 | "test"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/bower_components/d3/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mbostock/d3",
3 | "description": "A small, free JavaScript library for manipulating documents based on data.",
4 | "keywords": ["dom", "svg", "visualization", "js", "canvas"],
5 | "homepage": "http://d3js.org/",
6 | "license": "BSD-3-Clause",
7 | "authors": [
8 | {
9 | "name": "Mike Bostock",
10 | "homepage": "http://bost.ocks.org/mike"
11 | }
12 | ],
13 | "support": {
14 | "issues": "https://github.com/mbostock/d3/issues",
15 | "wiki": "https://github.com/mbostock/d3/wiki",
16 | "API": "https://github.com/mbostock/d3/wiki/API-Reference",
17 | "source": "https://github.com/mbostock/d3"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/bower_components/plottable/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "plottable",
3 | "description": "A library for creating charts out of D3",
4 | "version": "0.35.0",
5 | "main": [
6 | "plottable.js",
7 | "plottable.css"
8 | ],
9 | "license": "MIT",
10 | "ignore": [
11 | "**/*",
12 | "!bower.json",
13 | "!plottable.js",
14 | "!plottable.css",
15 | "!plottable.min.js",
16 | "!plottable.d.ts"
17 | ],
18 | "keywords": [
19 | "plottable",
20 | "plottablejs",
21 | "plottable.js",
22 | "d3",
23 | "data viz",
24 | "chart",
25 | "charts",
26 | "reusable charts",
27 | "visualization",
28 | "scatterplot",
29 | "bar chart",
30 | "plot",
31 | "plots"
32 | ],
33 | "dependencies": {
34 | "d3": "3.4.13"
35 | },
36 | "homepage": "plottablejs.org",
37 | "repository": {
38 | "type": "git",
39 | "url": "git://github.com/palantir/plottable.git"
40 | },
41 | "devDependencies": {
42 | "chai": "1.9.0",
43 | "mocha": "1.17.1",
44 | "jQuery": "2.1.0",
45 | "jquery.simulate": "1.2.0",
46 | "lodash": "~2.4.1"
47 | },
48 | "_release": "0.35.0",
49 | "_resolution": {
50 | "type": "version",
51 | "tag": "v0.35.0",
52 | "commit": "2a9cc5766f31b96aecb48dac108f15e11fa34964"
53 | },
54 | "_source": "git://github.com/palantir/plottable.git",
55 | "_target": "0.35.0",
56 | "_originalSource": "plottable"
57 | }
--------------------------------------------------------------------------------
/bower_components/plottable/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "plottable",
3 | "description": "A library for creating charts out of D3",
4 | "version": "0.35.0",
5 | "main": ["plottable.js", "plottable.css"],
6 | "license": "MIT",
7 | "ignore": [
8 | "**/*",
9 | "!bower.json",
10 | "!plottable.js",
11 | "!plottable.css",
12 | "!plottable.min.js",
13 | "!plottable.d.ts"
14 | ],
15 | "keywords": [
16 | "plottable",
17 | "plottablejs",
18 | "plottable.js",
19 | "d3",
20 | "data viz",
21 | "chart",
22 | "charts",
23 | "reusable charts",
24 | "visualization",
25 | "scatterplot",
26 | "bar chart",
27 | "plot",
28 | "plots"
29 | ],
30 | "dependencies": {
31 | "d3": "3.4.13"
32 | },
33 | "homepage": "plottablejs.org",
34 | "repository": {
35 | "type": "git",
36 | "url": "git://github.com/palantir/plottable.git"
37 | },
38 | "devDependencies": {
39 | "chai": "1.9.0",
40 | "mocha": "1.17.1",
41 | "jQuery": "2.1.0",
42 | "jquery.simulate": "1.2.0",
43 | "lodash": "~2.4.1"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/bower_components/plottable/plottable.css:
--------------------------------------------------------------------------------
1 |
2 | svg.plottable {
3 | display : block; /* SVGs must be block elements for width/height calculations to work in Firefox. */
4 | }
5 |
6 | .plottable .bounding-box {
7 | /* Invisible pink bounding-box to allow for collision testing */
8 | fill: pink;
9 | visibility: hidden;
10 | }
11 |
12 | .plottable .label text {
13 | font-family: "Helvetica Neue", sans-serif;
14 | fill: #32313F;
15 | }
16 |
17 | .plottable .bar-label-text-area text {
18 | font-family: "Helvetica Neue", sans-serif;
19 | font-size: 14px;
20 | }
21 |
22 | .plottable .light-label text {
23 | fill: white;
24 | }
25 |
26 | .plottable .dark-label text {
27 | fill: #32313F;
28 | }
29 |
30 | .plottable .axis-label text {
31 | font-size: 10px;
32 | font-weight: bold;
33 | letter-spacing: 1px;
34 | line-height: normal;
35 | text-transform: uppercase;
36 | }
37 |
38 | .plottable .title-label text {
39 | font-size: 20px;
40 | font-weight: bold;
41 | }
42 |
43 | .plottable .text-label-vertical {
44 | writing-mode: tb;
45 | }
46 |
47 | .plottable .axis line.baseline {
48 | stroke: #CCC;
49 | stroke-width: 1px;
50 | }
51 |
52 | .plottable .axis line.tick-mark {
53 | stroke: #CCC;
54 | stroke-width: 1px;
55 | }
56 |
57 | .plottable .axis text {
58 | fill: #32313F;
59 | font-family: "Helvetica Neue", sans-serif;
60 | font-size: 12px;
61 | font-weight: 200;
62 | line-height: normal;
63 | }
64 |
65 | .plottable .bar-plot .baseline {
66 | stroke: #999;
67 | }
68 |
69 | .bar-plot .render-area rect.not-hovered {
70 | opacity: 0.5;
71 | }
72 |
73 | .plottable .gridlines line {
74 | stroke: #3C3C3C; /* hackhack: gridlines should be solid; see #820 */
75 | opacity: 0.25;
76 | stroke-width: 1px;
77 | }
78 |
79 | .plottable .drag-box {
80 | fill: aliceblue;
81 | opacity: .7;
82 | stroke: #C0C8FF;
83 |
84 | }
85 |
86 | .plottable .legend text {
87 | font-family: "Helvetica Neue", sans-serif;
88 | font-size: 12px;
89 | font-weight: bold;
90 | line-height: normal;
91 | }
92 |
93 | .plottable .legend .toggled-off circle {
94 | fill: #d3d3d3;
95 | }
96 |
97 | .plottable .plot.toggled-on {
98 | visibility:visible;
99 | }
100 |
101 | .plottable .plot.toggled-off {
102 | visibility:hidden;
103 | }
104 |
--------------------------------------------------------------------------------
/chartographer.d.ts:
--------------------------------------------------------------------------------
1 | declare module Chartographer {
2 | class Chart {
3 | private _xType;
4 | private _yType;
5 | private _xAccessor;
6 | private _yAccessor;
7 | private datasets;
8 | private plots;
9 | private plot;
10 | private _xLabel;
11 | private _yLabel;
12 | private _titleLabel;
13 | colorVar: string;
14 | isNewStylePlot: boolean;
15 | plotType: string;
16 | private colorRange;
17 | private hasDeployed;
18 | constructor(datasets: any, spec: any);
19 | xType(t: string): Chart;
20 | yType(t: string): Chart;
21 | xAccessor(accessor: any): Chart;
22 | yAccessor(accessor: any): Chart;
23 | colors(colors: string[]): Chart;
24 | titleLabel(label: string): Chart;
25 | xLabel(label: string): Chart;
26 | yLabel(label: string): Chart;
27 | renderTo(svg: any): void;
28 | _project(attr: string, accessor: any, scale?: Plottable.Scale.AbstractScale): void;
29 | _generatePlots(x: Plottable.Scale.AbstractScale, y: Plottable.Scale.AbstractScale): void;
30 | private setType(t, isX);
31 | private deduceType(accessor, dataset);
32 | private modifyDataForNewStylePlot();
33 | getComponents(): ChartComponents;
34 | }
35 | class LineChart extends Chart {
36 | plotType: string;
37 | colorVar: string;
38 | }
39 | class ScatterChart extends Chart {
40 | plotType: string;
41 | }
42 | class BarChart extends Chart {
43 | plotType: string;
44 | isNewStylePlot: boolean;
45 | }
46 | class StackedBarChart extends BarChart {
47 | plotType: string;
48 | isNewStylePlot: boolean;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/chartographer.js:
--------------------------------------------------------------------------------
1 | /*!
2 | Chartographer 0.1.0 (https://github.com/danmane/chartogrpaher)
3 | Copyright 2014 Palantir Technologies
4 | Licensed under MIT (https://github.com/danmane/chartographer/blob/master/LICENSE)
5 |
6 | ************************************************
7 | ** Looking for readable source? **
8 | ** Check out the .ts (typescript) file! **
9 | ************************************************
10 |
11 | */
12 |
13 | var __extends = this.__extends || function (d, b) {
14 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
15 | function __() { this.constructor = d; }
16 | __.prototype = b.prototype;
17 | d.prototype = new __();
18 | };
19 | var Chartographer;
20 | (function (Chartographer) {
21 | var Chart = (function () {
22 | function Chart(datasets, spec) {
23 | this._xAccessor = "x";
24 | this._yAccessor = "y";
25 | this.colorVar = "fill";
26 | this.isNewStylePlot = false;
27 | this.hasDeployed = false;
28 | if (datasets instanceof Array)
29 | datasets = { "": datasets };
30 | datasets = d3.entries(datasets);
31 | this.datasets = datasets.map(function (kv) { return makeDataset(kv.key, kv.value); });
32 | }
33 | Chart.prototype.xType = function (t) {
34 | this._xType = this.setType(t, true);
35 | return this;
36 | };
37 | Chart.prototype.yType = function (t) {
38 | this._yType = this.setType(t, false);
39 | return this;
40 | };
41 | Chart.prototype.xAccessor = function (accessor) {
42 | this._xAccessor = accessor;
43 | return this;
44 | };
45 | Chart.prototype.yAccessor = function (accessor) {
46 | this._yAccessor = accessor;
47 | return this;
48 | };
49 | Chart.prototype.colors = function (colors) {
50 | this.colorRange = colors;
51 | return this;
52 | };
53 | Chart.prototype.titleLabel = function (label) {
54 | this._titleLabel = label;
55 | return this;
56 | };
57 | Chart.prototype.xLabel = function (label) {
58 | this._xLabel = label;
59 | return this;
60 | };
61 | Chart.prototype.yLabel = function (label) {
62 | this._yLabel = label;
63 | return this;
64 | };
65 | Chart.prototype.renderTo = function (svg) {
66 | this.getComponents().table.renderTo(svg);
67 | };
68 | Chart.prototype._project = function (attr, accessor, scale) {
69 | if (this.isNewStylePlot) {
70 | this.plot.project(attr, accessor, scale);
71 | }
72 | else {
73 | this.plots.forEach(function (p) { return p.project(attr, accessor, scale); });
74 | }
75 | };
76 | Chart.prototype._generatePlots = function (x, y) {
77 | var _this = this;
78 | if (this.isNewStylePlot) {
79 | this.plot = new Plottable.Plot[this.plotType](x, y);
80 | this.datasets.forEach(function (d) { return _this.plot.addDataset(d.metadata()[nameKey], d); });
81 | }
82 | else {
83 | this.plots = this.datasets.map(function (d) { return new Plottable.Plot[_this.plotType](x, y).addDataset(d); });
84 | }
85 | };
86 | Chart.prototype.setType = function (t, isX) {
87 | t = t.toLowerCase();
88 | if (t === "time" && !isX)
89 | throw new Error("Can't use time as y-type");
90 | if (validTypes.indexOf(t) === -1)
91 | throw new Error("Unrecognized type" + t);
92 | if (t === "log")
93 | t = "modifiedLog";
94 | return t;
95 | };
96 | Chart.prototype.deduceType = function (accessor, dataset) {
97 | var data = dataset.data();
98 | var a = typeof (accessor) === "string" ? function (x) { return x[accessor]; } : accessor;
99 | var d = a(data[0]);
100 | if (d instanceof Date)
101 | return "time";
102 | if (typeof (d) === "number")
103 | return "linear";
104 | if (typeof (d) === "string")
105 | return "ordinal";
106 | console.log("Data type couldn't be deduced; here's an example");
107 | console.log(d);
108 | throw new Error("Unrecognized data type");
109 | };
110 | Chart.prototype.modifyDataForNewStylePlot = function () {
111 | this.datasets.forEach(function (dataset) {
112 | var key = dataset.metadata()[nameKey];
113 | dataset.data().forEach(function (v) { return v[nameKey] = key; });
114 | });
115 | };
116 | Chart.prototype.getComponents = function () {
117 | if (this.isNewStylePlot)
118 | this.modifyDataForNewStylePlot();
119 | this._xType || (this._xType = this.deduceType(this._xAccessor, this.datasets[0]));
120 | this._yType || (this._yType = this.deduceType(this._yAccessor, this.datasets[0]));
121 | var xScale = new Plottable.Scale[camelCase(this._xType)]();
122 | var yScale = new Plottable.Scale[camelCase(this._yType)]();
123 | var colorScale = new Plottable.Scale.Color();
124 | if (this.colorRange)
125 | colorScale.range(this.colorRange);
126 | var xScaleForGridlines = this._xType === "ordinal" ? null : xScale;
127 | var yScaleForGridlines = this._yType === "ordinal" ? null : yScale;
128 | var gridlines = new Plottable.Component.Gridlines(xScaleForGridlines, yScaleForGridlines);
129 | var legend = colorScale.domain().length > 1 ? new Plottable.Component.HorizontalLegend(colorScale) : null;
130 | this._generatePlots(xScale, yScale);
131 | this._project("x", this._xAccessor, xScale);
132 | this._project("y", this._yAccessor, yScale);
133 | var colorAccessor = this.isNewStylePlot ? nameKey : function (d, i, m) { return m[nameKey]; };
134 | this._project(this.colorVar, colorAccessor, colorScale);
135 | var center = this.plot || new Plottable.Component.Group(this.plots);
136 | center.merge(gridlines);
137 | var xAxis = new Plottable.Axis[type2axis[this._xType]](xScale, "bottom");
138 | var yAxis = new Plottable.Axis[type2axis[this._yType]](yScale, "left");
139 | var titleLabel = this._titleLabel ? new Plottable.Component.TitleLabel(this._titleLabel) : null;
140 | var xLabel = this._xLabel ? new Plottable.Component.AxisLabel(this._xLabel) : null;
141 | var yLabel = this._yLabel ? new Plottable.Component.AxisLabel(this._yLabel, "left") : null;
142 | var table = new Plottable.Component.Table([
143 | [null, null, titleLabel],
144 | [null, null, legend],
145 | [yLabel, yAxis, center],
146 | [null, null, xAxis],
147 | [null, null, xLabel]
148 | ]);
149 | table.classed("chartographer", true);
150 | var chartComponents = {
151 | xScale: xScale,
152 | yScale: yScale,
153 | colorScale: colorScale,
154 | gridlines: gridlines,
155 | legend: legend,
156 | xAxis: xAxis,
157 | yAxis: yAxis,
158 | center: center,
159 | plot: this.plot,
160 | plots: this.plots,
161 | titleLabel: titleLabel,
162 | xLabel: xLabel,
163 | yLabel: yLabel,
164 | table: table
165 | };
166 | return chartComponents;
167 | };
168 | return Chart;
169 | })();
170 | Chartographer.Chart = Chart;
171 | var LineChart = (function (_super) {
172 | __extends(LineChart, _super);
173 | function LineChart() {
174 | _super.apply(this, arguments);
175 | this.plotType = "Line";
176 | this.colorVar = "stroke";
177 | }
178 | return LineChart;
179 | })(Chart);
180 | Chartographer.LineChart = LineChart;
181 | var ScatterChart = (function (_super) {
182 | __extends(ScatterChart, _super);
183 | function ScatterChart() {
184 | _super.apply(this, arguments);
185 | this.plotType = "Scatter";
186 | }
187 | return ScatterChart;
188 | })(Chart);
189 | Chartographer.ScatterChart = ScatterChart;
190 | var BarChart = (function (_super) {
191 | __extends(BarChart, _super);
192 | function BarChart() {
193 | _super.apply(this, arguments);
194 | this.plotType = "ClusteredBar";
195 | this.isNewStylePlot = true;
196 | }
197 | return BarChart;
198 | })(Chart);
199 | Chartographer.BarChart = BarChart;
200 | var StackedBarChart = (function (_super) {
201 | __extends(StackedBarChart, _super);
202 | function StackedBarChart() {
203 | _super.apply(this, arguments);
204 | this.plotType = "StackedBar";
205 | this.isNewStylePlot = true;
206 | }
207 | return StackedBarChart;
208 | })(BarChart);
209 | Chartographer.StackedBarChart = StackedBarChart;
210 | var nameKey = "_chartographer_name";
211 | var makeDataset = function (key, data) { return new Plottable.Dataset(data, { "_chartographer_name": key }); };
212 | var validTypes = ["linear", "log", "ordinal", "time"];
213 | var camelCase = function (s) { return s[0].toUpperCase() + s.substring(1); };
214 | var type2axis = { linear: "Numeric", modifiedLog: "Numeric", ordinal: "Category", time: "Time" };
215 | })(Chartographer || (Chartographer = {}));
216 |
--------------------------------------------------------------------------------
/chartographer.ts:
--------------------------------------------------------------------------------
1 | module Chartographer {
2 | /*
3 | * Plottable is currently undergoing an API shift; new plots (aka "NewStylePlots")
4 | * have a more advanced API that accepts multiple datasets, but not all plots are
5 | * so enlightened. Until the old plots are converted (should be by end of September),
6 | * there is some casing logic to access the old API for old plots.
7 | **/
8 |
9 | interface ChartComponents {
10 | xScale: Plottable.Scale.AbstractScale;
11 | yScale: Plottable.Scale.AbstractScale;
12 | colorScale: Plottable.Scale.AbstractScale;
13 | xAxis: Plottable.Axis.AbstractAxis;
14 | yAxis: Plottable.Axis.AbstractAxis;
15 | xLabel?: Plottable.Component.AxisLabel;
16 | yLabel?: Plottable.Component.AxisLabel;
17 | titleLabel?: Plottable.Component.TitleLabel;
18 | legend?: Plottable.Component.HorizontalLegend;
19 | plot?: Plottable.Plot.AbstractPlot; // if NewStylePlot
20 | plots?: Plottable.Plot.AbstractPlot[]; // if non NewStylePlot
21 | table: Plottable.Component.Table;
22 | }
23 |
24 | export class Chart {
25 | private _xType: string; // "Linear", "Log", "Ordinal", "Time"
26 | private _yType: string; // "Linear", "Log", "Ordinal"
27 | private _xAccessor: any = "x";
28 | private _yAccessor: any = "y"
29 | private datasets: Plottable.Dataset[];
30 |
31 | private plots: Plottable.Plot.AbstractXYPlot[];
32 | private plot: Plottable.Plot.AbstractPlot;
33 | private _xLabel: string;
34 | private _yLabel: string;
35 | private _titleLabel: string;
36 | public colorVar = "fill";
37 | public isNewStylePlot = false;
38 | public plotType: string;
39 | private colorRange: string[];
40 | private hasDeployed = false;
41 | // Chartographer deploys by rendering, or providing its pieces.
42 |
43 | constructor(datasets: any, spec: any) {
44 | if (datasets instanceof Array) datasets = {"": datasets};
45 | datasets = d3.entries(datasets);
46 | this.datasets = datasets.map((kv) => makeDataset(kv.key, kv.value));
47 | }
48 |
49 | /* Manually set the xType for the data: "Linear" || "Log" || "Ordinal" || "Time" */
50 | public xType(t: string) {this._xType = this.setType(t, true); return this;}
51 | /* Manually set the yType for the data: "Linear" || "Log" || "Ordinal" || "Time" */
52 | public yType(t: string) {this._yType = this.setType(t, false); return this;}
53 | public xAccessor(accessor: any) {this._xAccessor = accessor; return this;}
54 | public yAccessor(accessor: any) {this._yAccessor = accessor; return this;}
55 | public colors(colors: string[]) {this.colorRange = colors; return this;}
56 | public titleLabel(label: string) {this._titleLabel = label; return this;}
57 | public xLabel(label: string) {this._xLabel = label; return this;}
58 | public yLabel(label: string) {this._yLabel = label; return this;}
59 |
60 | public renderTo(svg: any) {
61 | this.getComponents().table.renderTo(svg);
62 | }
63 |
64 | public _project(attr: string, accessor: any, scale?: Plottable.Scale.AbstractScale) {
65 | if (this.isNewStylePlot) {
66 | this.plot.project(attr, accessor, scale);
67 | } else {
68 | this.plots.forEach((p: Plottable.Plot.AbstractPlot) => p.project(attr, accessor, scale));
69 | }
70 | }
71 |
72 | public _generatePlots(x: Plottable.Scale.AbstractScale, y: Plottable.Scale.AbstractScale) {
73 | if (this.isNewStylePlot) {
74 | this.plot = new Plottable.Plot[this.plotType](x, y);
75 | this.datasets.forEach((d: Plottable.Dataset) => this.plot.addDataset(d.metadata()[nameKey], d));
76 | } else {
77 | this.plots = this.datasets.map((d: Plottable.Dataset) => new Plottable.Plot[this.plotType](x, y).addDataset(d));
78 | }
79 | }
80 |
81 | private setType(t: string, isX: boolean) {
82 | t = t.toLowerCase();
83 | if (t === "time" && !isX) throw new Error("Can't use time as y-type");
84 | if (validTypes.indexOf(t) === -1) throw new Error("Unrecognized type" + t);
85 | if (t === "log") t = "modifiedLog";
86 | return t;
87 | }
88 |
89 | private deduceType(accessor: any, dataset: Plottable.Dataset) {
90 | var data = dataset.data();
91 | var a = typeof(accessor) === "string" ? (x) => x[accessor] : accessor;
92 | var d = a(data[0]);
93 | if (d instanceof Date) return "time";
94 | if (typeof(d) === "number") return "linear";
95 | if (typeof(d) === "string") return "ordinal";
96 | console.log("Data type couldn't be deduced; here's an example");
97 | console.log(d);
98 | throw new Error("Unrecognized data type");
99 | }
100 |
101 | private modifyDataForNewStylePlot() {
102 | // This code will disappear once NewStylePlots are universally supported in Plottable
103 | this.datasets.forEach((dataset) => {
104 | var key = dataset.metadata()[nameKey];
105 | dataset.data().forEach((v) => v[nameKey] = key);
106 | });
107 | }
108 |
109 | public getComponents(): ChartComponents {
110 | if (this.isNewStylePlot) this.modifyDataForNewStylePlot();
111 | this._xType || (this._xType = this.deduceType(this._xAccessor, this.datasets[0]));
112 | this._yType || (this._yType = this.deduceType(this._yAccessor, this.datasets[0]));
113 | var xScale = new Plottable.Scale[camelCase(this._xType)]();
114 | var yScale = new Plottable.Scale[camelCase(this._yType)]();
115 | var colorScale = new Plottable.Scale.Color();
116 | if (this.colorRange) colorScale.range(this.colorRange);
117 | // HACKHACK on Plottable-1289 https://github.com/palantir/plottable/issues/1289
118 | var xScaleForGridlines = this._xType === "ordinal" ? null : xScale;
119 | var yScaleForGridlines = this._yType === "ordinal" ? null : yScale;
120 | var gridlines = new Plottable.Component.Gridlines(xScaleForGridlines, yScaleForGridlines);
121 | var legend = colorScale.domain().length > 1 ? new Plottable.Component.HorizontalLegend(colorScale) : null;
122 | this._generatePlots(xScale, yScale);
123 | this._project("x", this._xAccessor, xScale);
124 | this._project("y", this._yAccessor, yScale);
125 | var colorAccessor: any = this.isNewStylePlot ? nameKey : (d,i,m) => m[nameKey];
126 | this._project(this.colorVar, colorAccessor, colorScale);
127 | var center: any = this.plot || new Plottable.Component.Group(this.plots);
128 | center.merge(gridlines);
129 | var xAxis = new Plottable.Axis[type2axis[this._xType]](xScale, "bottom");
130 | var yAxis = new Plottable.Axis[type2axis[this._yType]](yScale, "left");
131 | var titleLabel = this._titleLabel ? new Plottable.Component.TitleLabel(this._titleLabel) : null;
132 | var xLabel = this._xLabel ? new Plottable.Component.AxisLabel(this._xLabel) : null;
133 | var yLabel = this._yLabel ? new Plottable.Component.AxisLabel(this._yLabel, "left") : null;
134 | var table = new Plottable.Component.Table([
135 | [null, null, titleLabel],
136 | [null, null, legend],
137 | [yLabel, yAxis, center],
138 | [null, null, xAxis],
139 | [null, null, xLabel]
140 | ]);
141 | table.classed("chartographer", true);
142 | var chartComponents: ChartComponents = {
143 | xScale: xScale, yScale: yScale, colorScale: colorScale,
144 | gridlines: gridlines, legend: legend, xAxis: xAxis, yAxis: yAxis,
145 | center: center, plot: this.plot, plots: this.plots,
146 | titleLabel: titleLabel, xLabel: xLabel, yLabel: yLabel,
147 | table: table
148 | };
149 | return chartComponents;
150 | }
151 | }
152 |
153 | export class LineChart extends Chart {
154 | public plotType = "Line";
155 | public colorVar = "stroke";
156 | }
157 |
158 | export class ScatterChart extends Chart {
159 | public plotType = "Scatter";
160 | }
161 |
162 | export class BarChart extends Chart {
163 | public plotType = "ClusteredBar";
164 | public isNewStylePlot = true;
165 | }
166 |
167 | export class StackedBarChart extends BarChart {
168 | public plotType = "StackedBar";
169 | public isNewStylePlot = true;
170 | }
171 |
172 | var nameKey = "_chartographer_name";
173 | var makeDataset = (key: string, data: any[]) => new Plottable.Dataset(data, {"_chartographer_name": key});
174 | var validTypes = ["linear", "log", "ordinal", "time"];
175 | var camelCase = (s: string) => s[0].toUpperCase() + s.substring(1);
176 | var type2axis = {linear: "Numeric", modifiedLog: "Numeric", ordinal: "Category", time: "Time"};
177 |
178 | }
179 |
--------------------------------------------------------------------------------
/examples/line.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Line Quicktest
5 |
6 |
11 |
12 |
13 |
14 |
15 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/license_header.txt:
--------------------------------------------------------------------------------
1 | /*!
2 | Chartographer @VERSION (https://github.com/danmane/chartogrpaher)
3 | Copyright 2014 Palantir Technologies
4 | Licensed under MIT (https://github.com/danmane/chartographer/blob/master/LICENSE)
5 |
6 | ************************************************
7 | ** Looking for readable source? **
8 | ** Check out the .ts (typescript) file! **
9 | ************************************************
10 |
11 | */
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "chartographer.js",
3 | "version": "0.1.0",
4 | "description": "A library of simple charts made with Plottable and D3",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/palantir/chartographer.git"
8 | },
9 | "author": "Dan Mané @ Palantir Technologies",
10 | "devDependencies": {
11 | "grunt": "~0.4.2",
12 | "grunt-cli": "0.1.6",
13 | "grunt-contrib-watch": "~0.5.3",
14 | "load-grunt-tasks": "~0.2.0",
15 | "grunt-ts": "~1.11.6",
16 | "grunt-tslint": "~0.4.0",
17 | "grunt-contrib-concat": "~0.3.0",
18 | "grunt-mocha-phantomjs": "~0.4.0",
19 | "grunt-contrib-connect": "~0.6.0",
20 | "grunt-blanket-mocha": "~0.4.0",
21 | "typescript": "1.0.1",
22 | "grunt-sed": "~0.1.1",
23 | "grunt-contrib-clean": "~0.4.0",
24 | "grunt-bump": "0.0.13",
25 | "grunt-contrib-compress": "~0.9.1",
26 | "grunt-contrib-uglify": "~0.4.0",
27 | "grunt-shell": "0.7.0",
28 | "grunt-contrib-jshint": "^0.10.0"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/tsd.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "v1",
3 | "repo": "borisyankov/DefinitelyTyped",
4 | "ref": "master",
5 | "path": "typings",
6 | "installed": {
7 | "d3/d3.d.ts": {
8 | "commit": "3505d15d991ddaa4f5efa13edcd8543bae1e46de"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "class-name": false,
4 | "curly": true,
5 | "eofline": true,
6 | "forin": true,
7 | "indent": [true, 2],
8 | "jsdoc-format": true,
9 | "label-position": true,
10 | "label-undefined": true,
11 | "max-line-length": [true, 140],
12 | "no-arg": true,
13 | "no-bitwise": true,
14 | "no-construct": true,
15 | "no-console": [true,
16 | "log",
17 | "debug",
18 | "info",
19 | "time",
20 | "timeEnd",
21 | "trace",
22 | "warn"
23 | ],
24 | "no-duplicate-key": true,
25 | "no-duplicate-variable": true,
26 | "no-empty": true,
27 | "no-eval": true,
28 | "no-trailing-comma": true,
29 | "no-trailing-whitespace": true,
30 | "no-unused-variable": false,
31 | "no-unreachable": true,
32 | "no-use-before-declare": true,
33 | "one-line": [true,
34 | "check-open-brace",
35 | "check-catch",
36 | "check-else"
37 | ],
38 | "quotemark": [true, "double"],
39 | "radix": true,
40 | "semicolon": true,
41 | "triple-equals": [true, "allow-null-check"],
42 | "variable-name": false,
43 | "whitespace": ["check-branch", "check-decl", "check-type"],
44 | "ban": [true, ["d3", "max"], ["d3", "min"]]
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/typings/d3/d3.d.ts:
--------------------------------------------------------------------------------
1 | // Type definitions for d3JS
2 | // Project: http://d3js.org/
3 | // Definitions by: Boris Yankov
4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped
5 |
6 | declare module D3 {
7 | export interface Selectors {
8 | /**
9 | * Select an element from the current document
10 | */
11 | select: {
12 | /**
13 | * Selects the first element that matches the specified selector string
14 | *
15 | * @param selector Selection String to match
16 | */
17 | (selector: string): Selection;
18 | /**
19 | * Selects the specified node
20 | *
21 | * @param element Node element to select
22 | */
23 | (element: EventTarget): Selection;
24 | };
25 |
26 | /**
27 | * Select multiple elements from the current document
28 | */
29 | selectAll: {
30 | /**
31 | * Selects all elements that match the specified selector
32 | *
33 | * @param selector Selection String to match
34 | */
35 | (selector: string): Selection;
36 | /**
37 | * Selects the specified array of elements
38 | *
39 | * @param elements Array of node elements to select
40 | */
41 | (elements: EventTarget[]): Selection;
42 | };
43 | }
44 |
45 | export interface D3Event extends Event{
46 | dx: number;
47 | dy: number;
48 | clientX: number;
49 | clientY: number;
50 | translate: number[];
51 | scale: number;
52 | sourceEvent: D3Event;
53 | x: number;
54 | y: number;
55 | keyCode: number;
56 | altKey: any;
57 | type: string;
58 | }
59 |
60 | export interface Base extends Selectors {
61 | /**
62 | * Create a behavior
63 | */
64 | behavior: Behavior.Behavior;
65 | /**
66 | * Access the current user event for interaction
67 | */
68 | event: D3Event;
69 |
70 | /**
71 | * Compare two values for sorting.
72 | * Returns -1 if a is less than b, or 1 if a is greater than b, or 0
73 | *
74 | * @param a First value
75 | * @param b Second value
76 | */
77 | ascending(a: T, b: T): number;
78 | /**
79 | * Compare two values for sorting.
80 | * Returns -1 if a is greater than b, or 1 if a is less than b, or 0
81 | *
82 | * @param a First value
83 | * @param b Second value
84 | */
85 | descending(a: T, b: T): number;
86 | /**
87 | * Find the minimum value in an array
88 | *
89 | * @param arr Array to search
90 | * @param map Accsessor function
91 | */
92 | min(arr: T[], map: (v: T) => U): U;
93 | /**
94 | * Find the minimum value in an array
95 | *
96 | * @param arr Array to search
97 | */
98 | min(arr: T[]): T;
99 | /**
100 | * Find the maximum value in an array
101 | *
102 | * @param arr Array to search
103 | * @param map Accsessor function
104 | */
105 | max(arr: T[], map: (v: T) => U): U;
106 | /**
107 | * Find the maximum value in an array
108 | *
109 | * @param arr Array to search
110 | */
111 | max(arr: T[]): T;
112 | /**
113 | * Find the minimum and maximum value in an array
114 | *
115 | * @param arr Array to search
116 | * @param map Accsessor function
117 | */
118 | extent(arr: T[], map: (v: T) => U): U[];
119 | /**
120 | * Find the minimum and maximum value in an array
121 | *
122 | * @param arr Array to search
123 | */
124 | extent(arr: T[]): T[];
125 | /**
126 | * Compute the sum of an array of numbers
127 | *
128 | * @param arr Array to search
129 | * @param map Accsessor function
130 | */
131 | sum(arr: T[], map: (v: T) => number): number;
132 | /**
133 | * Compute the sum of an array of numbers
134 | *
135 | * @param arr Array to search
136 | */
137 | sum(arr: number[]): number;
138 | /**
139 | * Compute the arithmetic mean of an array of numbers
140 | *
141 | * @param arr Array to search
142 | * @param map Accsessor function
143 | */
144 | mean(arr: T[], map: (v: T) => number): number;
145 | /**
146 | * Compute the arithmetic mean of an array of numbers
147 | *
148 | * @param arr Array to search
149 | */
150 | mean(arr: number[]): number;
151 | /**
152 | * Compute the median of an array of numbers (the 0.5-quantile).
153 | *
154 | * @param arr Array to search
155 | * @param map Accsessor function
156 | */
157 | median(arr: T[], map: (v: T) => number): number;
158 | /**
159 | * Compute the median of an array of numbers (the 0.5-quantile).
160 | *
161 | * @param arr Array to search
162 | */
163 | median(arr: number[]): number;
164 | /**
165 | * Compute a quantile for a sorted array of numbers.
166 | *
167 | * @param arr Array to search
168 | * @param p The quantile to return
169 | */
170 | quantile: (arr: number[], p: number) => number;
171 | /**
172 | * Locate the insertion point for x in array to maintain sorted order
173 | *
174 | * @param arr Array to search
175 | * @param x Value to search for insertion point
176 | * @param low Minimum value of array subset
177 | * @param hihg Maximum value of array subset
178 | */
179 | bisect(arr: T[], x: T, low?: number, high?: number): number;
180 | /**
181 | * Locate the insertion point for x in array to maintain sorted order
182 | *
183 | * @param arr Array to search
184 | * @param x Value to serch for insertion point
185 | * @param low Minimum value of array subset
186 | * @param high Maximum value of array subset
187 | */
188 | bisectLeft(arr: T[], x: T, low?: number, high?: number): number;
189 | /**
190 | * Locate the insertion point for x in array to maintain sorted order
191 | *
192 | * @param arr Array to search
193 | * @param x Value to serch for insertion point
194 | * @param low Minimum value of array subset
195 | * @param high Maximum value of array subset
196 | */
197 | bisectRight(arr: T[], x: T, low?: number, high?: number): number;
198 | /**
199 | * Bisect using an accessor.
200 | *
201 | * @param accessor Accessor function
202 | */
203 | bisector(accessor: (data: any, index: number) => any): any;
204 | /**
205 | * Randomize the order of an array.
206 | *
207 | * @param arr Array to randomize
208 | */
209 | shuffle(arr: T[]): T[];
210 | /**
211 | * Reorder an array of elements according to an array of indexes
212 | *
213 | * @param arr Array to reorder
214 | * @param indexes Array containing the order the elements should be returned in
215 | */
216 | permute(arr: any[], indexes: any[]): any[];
217 | /**
218 | * Transpose a variable number of arrays.
219 | *
220 | * @param arrs Arrays to transpose
221 | */
222 | zip(...arrs: any[]): any[];
223 | /**
224 | * Parse the given 2D affine transform string, as defined by SVG's transform attribute.
225 | *
226 | * @param definition 2D affine transform string
227 | */
228 | transform(definition: string): any;
229 | /**
230 | * Transpose an array of arrays.
231 | *
232 | * @param matrix Two dimensional array to transpose
233 | */
234 | transpose(matrix: any[]): any[];
235 | /**
236 | * List the keys of an associative array.
237 | *
238 | * @param map Array of objects to get the key values from
239 | */
240 | keys(map: any): string[];
241 | /**
242 | * List the values of an associative array.
243 | *
244 | * @param map Array of objects to get the values from
245 | */
246 | values(map: any): any[];
247 | /**
248 | * List the key-value entries of an associative array.
249 | *
250 | * @param map Array of objects to get the key-value pairs from
251 | */
252 | entries(map: any): any[];
253 | /**
254 | * merge multiple arrays into one array
255 | *
256 | * @param map Arrays to merge
257 | */
258 | merge(...map: any[]): any[];
259 | /**
260 | * Generate a range of numeric values.
261 | */
262 | range: {
263 | /**
264 | * Generate a range of numeric values from 0.
265 | *
266 | * @param stop Value to generate the range to
267 | * @param step Step between each value
268 | */
269 | (stop: number, step?: number): number[];
270 | /**
271 | * Generate a range of numeric values.
272 | *
273 | * @param start Value to start
274 | * @param stop Value to generate the range to
275 | * @param step Step between each value
276 | */
277 | (start: number, stop?: number, step?: number): number[];
278 | };
279 | /**
280 | * Create new nest operator
281 | */
282 | nest(): Nest;
283 | /**
284 | * Request a resource using XMLHttpRequest.
285 | */
286 | xhr: {
287 | /**
288 | * Creates an asynchronous request for specified url
289 | *
290 | * @param url Url to request
291 | * @param callback Function to invoke when resource is loaded or the request fails
292 | */
293 | (url: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
294 | /**
295 | * Creates an asynchronous request for specified url
296 | *
297 | * @param url Url to request
298 | * @param mime MIME type to request
299 | * @param callback Function to invoke when resource is loaded or the request fails
300 | */
301 | (url: string, mime: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
302 | };
303 | /**
304 | * Request a text file
305 | */
306 | text: {
307 | /**
308 | * Request a text file
309 | *
310 | * @param url Url to request
311 | * @param callback Function to invoke when resource is loaded or the request fails
312 | */
313 | (url: string, callback?: (response: string) => void ): Xhr;
314 | /**
315 | * Request a text file
316 | *
317 | * @param url Url to request
318 | * @param mime MIME type to request
319 | * @param callback Function to invoke when resource is loaded or the request fails
320 | */
321 | (url: string, mime: string, callback?: (response: string) => void ): Xhr;
322 | };
323 | /**
324 | * Request a JSON blob
325 | *
326 | * @param url Url to request
327 | * @param callback Function to invoke when resource is loaded or the request fails
328 | */
329 | json: (url: string, callback?: (error: any, data: any) => void ) => Xhr;
330 | /**
331 | * Request an HTML document fragment.
332 | */
333 | xml: {
334 | /**
335 | * Request an HTML document fragment.
336 | *
337 | * @param url Url to request
338 | * @param callback Function to invoke when resource is loaded or the request fails
339 | */
340 | (url: string, callback?: (response: Document) => void ): Xhr;
341 | /**
342 | * Request an HTML document fragment.
343 | *
344 | * @param url Url to request
345 | * @param mime MIME type to request
346 | * @param callback Function to invoke when resource is loaded or the request fails
347 | */
348 | (url: string, mime: string, callback?: (response: Document) => void ): Xhr;
349 | };
350 | /**
351 | * Request an XML document fragment.
352 | *
353 | * @param url Url to request
354 | * @param callback Function to invoke when resource is loaded or the request fails
355 | */
356 | html: (url: string, callback?: (response: DocumentFragment) => void ) => Xhr;
357 | /**
358 | * Request a comma-separated values (CSV) file.
359 | */
360 | csv: Dsv;
361 | /**
362 | * Request a tab-separated values (TSV) file
363 | */
364 | tsv: Dsv;
365 | /**
366 | * Time Functions
367 | */
368 | time: Time.Time;
369 | /**
370 | * Scales
371 | */
372 | scale: Scale.ScaleBase;
373 | /*
374 | * Interpolate two values
375 | */
376 | interpolate: Transition.BaseInterpolate;
377 | /*
378 | * Interpolate two numbers
379 | */
380 | interpolateNumber: Transition.BaseInterpolate;
381 | /*
382 | * Interpolate two integers
383 | */
384 | interpolateRound: Transition.BaseInterpolate;
385 | /*
386 | * Interpolate two strings
387 | */
388 | interpolateString: Transition.BaseInterpolate;
389 | /*
390 | * Interpolate two RGB colors
391 | */
392 | interpolateRgb: Transition.BaseInterpolate;
393 | /*
394 | * Interpolate two HSL colors
395 | */
396 | interpolateHsl: Transition.BaseInterpolate;
397 | /*
398 | * Interpolate two HCL colors
399 | */
400 | interpolateHcl: Transition.BaseInterpolate;
401 | /*
402 | * Interpolate two L*a*b* colors
403 | */
404 | interpolateLab: Transition.BaseInterpolate;
405 | /*
406 | * Interpolate two arrays of values
407 | */
408 | interpolateArray: Transition.BaseInterpolate;
409 | /*
410 | * Interpolate two arbitary objects
411 | */
412 | interpolateObject: Transition.BaseInterpolate;
413 | /*
414 | * Interpolate two 2D matrix transforms
415 | */
416 | interpolateTransform: Transition.BaseInterpolate;
417 | /*
418 | * The array of built-in interpolator factories
419 | */
420 | interpolators: Transition.InterpolateFactory[];
421 | /**
422 | * Layouts
423 | */
424 | layout: Layout.Layout;
425 | /**
426 | * Svg's
427 | */
428 | svg: Svg.Svg;
429 | /**
430 | * Random number generators
431 | */
432 | random: Random;
433 | /**
434 | * Create a function to format a number as a string
435 | *
436 | * @param specifier The format specifier to use
437 | */
438 | format(specifier: string): (value: number) => string;
439 | /**
440 | * Returns the SI prefix for the specified value at the specified precision
441 | */
442 | formatPrefix(value: number, precision?: number): MetricPrefix;
443 | /**
444 | * The version of the d3 library
445 | */
446 | version: string;
447 | /**
448 | * Returns the root selection
449 | */
450 | selection(): Selection;
451 | ns: {
452 | /**
453 | * The map of registered namespace prefixes
454 | */
455 | prefix: {
456 | svg: string;
457 | xhtml: string;
458 | xlink: string;
459 | xml: string;
460 | xmlns: string;
461 | };
462 | /**
463 | * Qualifies the specified name
464 | */
465 | qualify(name: string): { space: string; local: string; };
466 | };
467 | /**
468 | * Returns a built-in easing function of the specified type
469 | */
470 | ease: (type: string, ...arrs: any[]) => D3.Transition.Transition;
471 | /**
472 | * Constructs a new RGB color.
473 | */
474 | rgb: {
475 | /**
476 | * Constructs a new RGB color with the specified r, g and b channel values
477 | */
478 | (r: number, g: number, b: number): D3.Color.RGBColor;
479 | /**
480 | * Constructs a new RGB color by parsing the specified color string
481 | */
482 | (color: string): D3.Color.RGBColor;
483 | };
484 | /**
485 | * Constructs a new HCL color.
486 | */
487 | hcl: {
488 | /**
489 | * Constructs a new HCL color.
490 | */
491 | (h: number, c: number, l: number): Color.HCLColor;
492 | /**
493 | * Constructs a new HCL color by parsing the specified color string
494 | */
495 | (color: string): Color.HCLColor;
496 | };
497 | /**
498 | * Constructs a new HSL color.
499 | */
500 | hsl: {
501 | /**
502 | * Constructs a new HSL color with the specified hue h, saturation s and lightness l
503 | */
504 | (h: number, s: number, l: number): Color.HSLColor;
505 | /**
506 | * Constructs a new HSL color by parsing the specified color string
507 | */
508 | (color: string): Color.HSLColor;
509 | };
510 | /**
511 | * Constructs a new RGB color.
512 | */
513 | lab: {
514 | /**
515 | * Constructs a new LAB color.
516 | */
517 | (l: number, a: number, b: number): Color.LABColor;
518 | /**
519 | * Constructs a new LAB color by parsing the specified color string
520 | */
521 | (color: string): Color.LABColor;
522 | };
523 | geo: Geo.Geo;
524 | geom: Geom.Geom;
525 | /**
526 | * gets the mouse position relative to a specified container.
527 | */
528 | mouse(container: any): number[];
529 | /**
530 | * gets the touch positions relative to a specified container.
531 | */
532 | touches(container: any): number[][];
533 |
534 | /**
535 | * If the specified value is a function, returns the specified value.
536 | * Otherwise, returns a function that returns the specified value.
537 | */
538 | functor(value: (p : R) => T): (p : R) => T;
539 | functor(value: T): (p : any) => T;
540 |
541 | map(): Map;
542 | set(): Set;
543 | map(object: {[key: string]: T; }): Map;
544 | set(array: T[]): Set;
545 | dispatch(...types: string[]): Dispatch;
546 | rebind(target: any, source: any, ...names: any[]): any;
547 | requote(str: string): string;
548 | timer: {
549 | (funct: () => boolean, delay?: number, mark?: number): void;
550 | flush(): void;
551 | }
552 | transition(): Transition.Transition;
553 |
554 | round(x: number, n: number): number;
555 | }
556 |
557 | export interface Dispatch {
558 | [event: string]: any;
559 | on: {
560 | (type: string): any;
561 | (type: string, listener: any): any;
562 | }
563 | }
564 |
565 | export interface MetricPrefix {
566 | /**
567 | * the scale function, for converting numbers to the appropriate prefixed scale.
568 | */
569 | scale: (d: number) => number;
570 | /**
571 | * the prefix symbol
572 | */
573 | symbol: string;
574 | }
575 |
576 | export interface Xhr {
577 | /**
578 | * Get or set request header
579 | */
580 | header: {
581 | /**
582 | * Get the value of specified request header
583 | *
584 | * @param name Name of header to get the value for
585 | */
586 | (name: string): string;
587 | /**
588 | * Set the value of specified request header
589 | *
590 | * @param name Name of header to set the value for
591 | * @param value Value to set the header to
592 | */
593 | (name: string, value: string): Xhr;
594 | };
595 | /**
596 | * Get or set MIME Type
597 | */
598 | mimeType: {
599 | /**
600 | * Get the current MIME Type
601 | */
602 | (): string;
603 | /**
604 | * Set the MIME Type for the request
605 | *
606 | * @param type The MIME type for the request
607 | */
608 | (type: string): Xhr;
609 | };
610 | /*
611 | * Get or Set the function used to map the response to the associated data value
612 | */
613 | response: {
614 | /**
615 | * Get function used to map the response to the associated data value
616 | */
617 | (): (xhr: XMLHttpRequest) => any;
618 | /**
619 | * Set function used to map the response to the associated data value
620 | *
621 | * @param value The function used to map the response to a data value
622 | */
623 | (value: (xhr: XMLHttpRequest) => any): Xhr;
624 | };
625 | /**
626 | * Issue the request using the GET method
627 | *
628 | * @param callback Function to invoke on completion of request
629 | */
630 | get(callback?: (xhr: XMLHttpRequest) => void ): Xhr;
631 | /**
632 | * Issue the request using the POST method
633 | */
634 | post: {
635 | /**
636 | * Issue the request using the POST method
637 | *
638 | * @param callback Function to invoke on completion of request
639 | */
640 | (callback?: (xhr: XMLHttpRequest) => void ): Xhr;
641 | /**
642 | * Issue the request using the POST method
643 | *
644 | * @param data Data to post back in the request
645 | * @param callback Function to invoke on completion of request
646 | */
647 | (data: any, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
648 | };
649 | /**
650 | * Issues this request using the specified method
651 | */
652 | send: {
653 | /**
654 | * Issues this request using the specified method
655 | *
656 | * @param method Method to use to make the request
657 | * @param callback Function to invoke on completion of request
658 | */
659 | (method: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
660 | /**
661 | * Issues this request using the specified method
662 | *
663 | * @param method Method to use to make the request
664 | * @param data Data to post back in the request
665 | * @param callback Function to invoke on completion of request
666 | */
667 | (method: string, data: any, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
668 | };
669 | /**
670 | * Aborts this request, if it is currently in-flight
671 | */
672 | abort(): Xhr;
673 | /**
674 | * Registers a listener to receive events
675 | *
676 | * @param type Enent name to attach the listener to
677 | * @param listener Function to attach to event
678 | */
679 | on: (type: string, listener: (data: any, index?: number) => any) => Xhr;
680 | }
681 |
682 | export interface Dsv {
683 | /**
684 | * Request a delimited values file
685 | *
686 | * @param url Url to request
687 | * @param callback Function to invoke when resource is loaded or the request fails
688 | */
689 | (url: string, callback?: (error: any, response: any[]) => void ): Xhr;
690 | /**
691 | * Parse a delimited string into objects using the header row.
692 | *
693 | * @param string delimited formatted string to parse
694 | */
695 | parse(string: string): any[];
696 | /**
697 | * Parse a delimited string into tuples, ignoring the header row.
698 | *
699 | * @param string delimited formatted string to parse
700 | */
701 | parseRows(string: string, accessor: (row: any[], index: number) => any): any;
702 | /**
703 | * Format an array of tuples into a delimited string.
704 | *
705 | * @param rows Array to convert to a delimited string
706 | */
707 | format(rows: any[]): string;
708 | }
709 |
710 | export interface Selection extends Selectors, Array {
711 | attr: {
712 | (name: string): string;
713 | (name: string, value: any): Selection;
714 | (name: string, valueFunction: (data: any, index: number) => any): Selection;
715 | (attrValueMap : Object): Selection;
716 | };
717 |
718 | classed: {
719 | (name: string): string;
720 | (name: string, value: any): Selection;
721 | (name: string, valueFunction: (data: any, index: number) => any): Selection;
722 | };
723 |
724 | style: {
725 | (name: string): string;
726 | (name: string, value: any, priority?: string): Selection;
727 | (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Selection;
728 | (styleValueMap : Object): Selection;
729 | };
730 |
731 | property: {
732 | (name: string): void;
733 | (name: string, value: any): Selection;
734 | (name: string, valueFunction: (data: any, index: number) => any): Selection;
735 | (propertyValueMap : Object): Selection;
736 | };
737 |
738 | text: {
739 | (): string;
740 | (value: any): Selection;
741 | (valueFunction: (data: any, index: number) => any): Selection;
742 | };
743 |
744 | html: {
745 | (): string;
746 | (value: any): Selection;
747 | (valueFunction: (data: any, index: number) => any): Selection;
748 | };
749 |
750 | append: (name: string) => Selection;
751 | insert: (name: string, before: string) => Selection;
752 | remove: () => Selection;
753 | empty: () => boolean;
754 |
755 | data: {
756 | (values: (data: any, index?: number) => any[], key?: (data: any, index?: number) => any): UpdateSelection;
757 | (values: any[], key?: (data: any, index?: number) => any): UpdateSelection;
758 | (): any[];
759 | };
760 |
761 | datum: {
762 | (values: (data: any, index: number) => any): UpdateSelection;
763 | (values: any): UpdateSelection;
764 | () : any;
765 | };
766 |
767 | filter: {
768 | (filter: (data: any, index: number) => boolean, thisArg?: any): UpdateSelection;
769 | //(filter: string): UpdateSelection;
770 | };
771 |
772 | call(callback: (selection: Selection, ...args: any[]) => void, ...args: any[]): Selection;
773 | each(eachFunction: (data: any, index: number) => any): Selection;
774 | on: {
775 | (type: string): (data: any, index: number) => any;
776 | (type: string, listener: (data: any, index: number) => any, capture?: boolean): Selection;
777 | };
778 |
779 | /**
780 | * Returns the total number of elements in the current selection.
781 | */
782 | size(): number;
783 |
784 | /**
785 | * Starts a transition for the current selection. Transitions behave much like selections,
786 | * except operators animate smoothly over time rather than applying instantaneously.
787 | */
788 | transition(): Transition.Transition;
789 |
790 | /**
791 | * Sorts the elements in the current selection according to the specified comparator
792 | * function.
793 | *
794 | * @param comparator a comparison function, which will be passed two data elements a and b
795 | * to compare, and should return either a negative, positive, or zero value to indicate
796 | * their relative order.
797 | */
798 | sort(comparator?: (a: T, b: T) => number): Selection;
799 |
800 | /**
801 | * Re-inserts elements into the document such that the document order matches the selection
802 | * order. This is equivalent to calling sort() if the data is already sorted, but much
803 | * faster.
804 | */
805 | order: () => Selection;
806 |
807 | /**
808 | * Returns the first non-null element in the current selection. If the selection is empty,
809 | * returns null.
810 | */
811 | node: () => Element;
812 | }
813 |
814 | export interface EnterSelection {
815 | append: (name: string) => Selection;
816 | insert: (name: string, before?: string) => Selection;
817 | select: (selector: string) => Selection;
818 | empty: () => boolean;
819 | node: () => Element;
820 | call: (callback: (selection: EnterSelection) => void) => EnterSelection;
821 | size: () => number;
822 | }
823 |
824 | export interface UpdateSelection extends Selection {
825 | enter: () => EnterSelection;
826 | update: () => Selection;
827 | exit: () => Selection;
828 | }
829 |
830 | export interface NestKeyValue {
831 | key: string;
832 | values: any;
833 | }
834 |
835 | export interface Nest {
836 | key(keyFunction: (data: any, index: number) => string): Nest;
837 | sortKeys(comparator: (d1: any, d2: any) => number): Nest;
838 | sortValues(comparator: (d1: any, d2: any) => number): Nest;
839 | rollup(rollupFunction: (data: any, index: number) => any): Nest;
840 | map(values: any[]): any;
841 | entries(values: any[]): NestKeyValue[];
842 | }
843 |
844 | export interface Map {
845 | has(key: string): boolean;
846 | get(key: string): T;
847 | set(key: string, value: T): T;
848 | remove(key: string): boolean;
849 | keys(): string[];
850 | values(): T[];
851 | entries(): any[][]; // Actually of form [key: string, val: T][], but this is inexpressible in Typescript
852 | forEach(func: (key: string, value: T) => void ): void;
853 | empty(): boolean;
854 | size(): number;
855 | }
856 |
857 | export interface Set {
858 | has(value: T): boolean;
859 | add(value: T): T;
860 | remove(value: T): boolean;
861 | values(): string[];
862 | forEach(func: (value: string) => void ): void;
863 | empty(): boolean;
864 | size(): number;
865 | }
866 |
867 | export interface Random {
868 | /**
869 | * Returns a function for generating random numbers with a normal distribution
870 | *
871 | * @param mean The expected value of the generated pseudorandom numbers
872 | * @param deviation The given standard deviation
873 | */
874 | normal(mean?: number, deviation?: number): () => number;
875 | /**
876 | * Returns a function for generating random numbers with a log-normal distribution
877 | *
878 | * @param mean The expected value of the generated pseudorandom numbers
879 | * @param deviation The given standard deviation
880 | */
881 | logNormal(mean?: number, deviation?: number): () => number;
882 | /**
883 | * Returns a function for generating random numbers with an Irwin-Hall distribution
884 | *
885 | * @param count The number of independent variables
886 | */
887 | irwinHall(count: number): () => number;
888 | }
889 |
890 | // Transitions
891 | export module Transition {
892 | export interface Transition {
893 | duration: {
894 | (duration: number): Transition;
895 | (duration: (data: any, index: number) => any): Transition;
896 | };
897 | delay: {
898 | (delay: number): Transition;
899 | (delay: (data: any, index: number) => any): Transition;
900 | };
901 | attr: {
902 | (name: string): string;
903 | (name: string, value: any): Transition;
904 | (name: string, valueFunction: (data: any, index: number) => any): Transition;
905 | (attrValueMap : any): Transition;
906 | };
907 | style: {
908 | (name: string): string;
909 | (name: string, value: any, priority?: string): Transition;
910 | (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Transition;
911 | };
912 | call(callback: (selection: Selection) => void ): Transition;
913 | /**
914 | * Select an element from the current document
915 | */
916 | select: {
917 | /**
918 | * Selects the first element that matches the specified selector string
919 | *
920 | * @param selector Selection String to match
921 | */
922 | (selector: string): Transition;
923 | /**
924 | * Selects the specified node
925 | *
926 | * @param element Node element to select
927 | */
928 | (element: EventTarget): Transition;
929 | };
930 |
931 | /**
932 | * Select multiple elements from the current document
933 | */
934 | selectAll: {
935 | /**
936 | * Selects all elements that match the specified selector
937 | *
938 | * @param selector Selection String to match
939 | */
940 | (selector: string): Transition;
941 | /**
942 | * Selects the specified array of elements
943 | *
944 | * @param elements Array of node elements to select
945 | */
946 | (elements: EventTarget[]): Transition;
947 | }
948 | each: (type?: string, eachFunction?: (data: any, index: number) => any) => Transition;
949 | transition: () => Transition;
950 | ease: (value: string, ...arrs: any[]) => Transition;
951 | attrTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate): Transition;
952 | styleTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate, priority?: string): Transition;
953 | text: {
954 | (text: string): Transition;
955 | (text: (d: any, i: number) => string): Transition;
956 | }
957 | tween(name: string, factory: InterpolateFactory): Transition;
958 | filter: {
959 | (selector: string): Transition;
960 | (selector: (data: any, index: number) => boolean): Transition;
961 | };
962 | remove(): Transition;
963 | }
964 |
965 | export interface InterpolateFactory {
966 | (a?: any, b?: any): BaseInterpolate;
967 | }
968 |
969 | export interface BaseInterpolate {
970 | (a: any, b?: any): any;
971 | }
972 |
973 | export interface Interpolate {
974 | (t: any): any;
975 | }
976 | }
977 |
978 | //Time
979 | export module Time {
980 | export interface Time {
981 | second: Interval;
982 | minute: Interval;
983 | hour: Interval;
984 | day: Interval;
985 | week: Interval;
986 | sunday: Interval;
987 | monday: Interval;
988 | tuesday: Interval;
989 | wednesday: Interval;
990 | thursday: Interval;
991 | friday: Interval;
992 | saturday: Interval;
993 | month: Interval;
994 | year: Interval;
995 |
996 | seconds: Range;
997 | minutes: Range;
998 | hours: Range;
999 | days: Range;
1000 | weeks: Range;
1001 | months: Range;
1002 | years: Range;
1003 |
1004 | sundays: Range;
1005 | mondays: Range;
1006 | tuesdays: Range;
1007 | wednesdays: Range;
1008 | thursdays: Range;
1009 | fridays: Range;
1010 | saturdays: Range;
1011 | format: {
1012 | /**
1013 | * Constructs a new local time formatter using the given specifier.
1014 | */
1015 | (specifier: string): TimeFormat;
1016 | /**
1017 | * Returns a new multi-resolution time format given the specified array of predicated formats.
1018 | */
1019 | multi: (formats: any[][]) => TimeFormat;
1020 |
1021 | utc: {
1022 | /**
1023 | * Constructs a new local time formatter using the given specifier.
1024 | */
1025 | (specifier: string): TimeFormat;
1026 | /**
1027 | * Returns a new multi-resolution UTC time format given the specified array of predicated formats.
1028 | */
1029 | multi: (formats: any[][]) => TimeFormat;
1030 | };
1031 |
1032 | /**
1033 | * The full ISO 8601 UTC time format: "%Y-%m-%dT%H:%M:%S.%LZ".
1034 | */
1035 | iso: TimeFormat;
1036 | };
1037 |
1038 | scale: {
1039 | /**
1040 | * Constructs a new time scale with the default domain and range;
1041 | * the ticks and tick format are configured for local time.
1042 | */
1043 | (): Scale.TimeScale;
1044 | /**
1045 | * Constructs a new time scale with the default domain and range;
1046 | * the ticks and tick format are configured for UTC time.
1047 | */
1048 | utc(): Scale.TimeScale;
1049 | };
1050 | }
1051 |
1052 | export interface Range {
1053 | (start: Date, end: Date, step?: number): Date[];
1054 | }
1055 |
1056 | export interface Interval {
1057 | (date: Date): Date;
1058 | floor: (date: Date) => Date;
1059 | round: (date: Date) => Date;
1060 | ceil: (date: Date) => Date;
1061 | range: Range;
1062 | offset: (date: Date, step: number) => Date;
1063 | utc?: Interval;
1064 | }
1065 |
1066 | export interface TimeFormat {
1067 | (date: Date): string;
1068 | parse: (string: string) => Date;
1069 | }
1070 | }
1071 |
1072 | // Layout
1073 | export module Layout {
1074 | export interface Layout {
1075 | /**
1076 | * Creates a new Stack layout
1077 | */
1078 | stack(): StackLayout;
1079 | /**
1080 | * Creates a new pie layout
1081 | */
1082 | pie(): PieLayout;
1083 | /**
1084 | * Creates a new force layout
1085 | */
1086 | force(): ForceLayout;
1087 | /**
1088 | * Creates a new tree layout
1089 | */
1090 | tree(): TreeLayout;
1091 | bundle(): BundleLayout;
1092 | chord(): ChordLayout;
1093 | cluster(): ClusterLayout;
1094 | hierarchy(): HierarchyLayout;
1095 | histogram(): HistogramLayout;
1096 | pack(): PackLayout;
1097 | partition(): PartitionLayout;
1098 | treemap(): TreeMapLayout;
1099 | }
1100 |
1101 | export interface StackLayout {
1102 | (layers: T[], index?: number): T[];
1103 | values(accessor?: (d: any) => any): StackLayout;
1104 | offset(offset: string): StackLayout;
1105 | }
1106 |
1107 | export interface TreeLayout {
1108 | /**
1109 | * Gets or sets the sort order of sibling nodes for the layout using the specified comparator function
1110 | */
1111 | sort: {
1112 | /**
1113 | * Gets the sort order function of sibling nodes for the layout
1114 | */
1115 | (): (d1: any, d2: any) => number;
1116 | /**
1117 | * Sets the sort order of sibling nodes for the layout using the specified comparator function
1118 | */
1119 | (comparator: (d1: any, d2: any) => number): TreeLayout;
1120 | };
1121 | /**
1122 | * Gets or sets the specified children accessor function
1123 | */
1124 | children: {
1125 | /**
1126 | * Gets the children accessor function
1127 | */
1128 | (): (d: any) => any;
1129 | /**
1130 | * Sets the specified children accessor function
1131 | */
1132 | (children: (d: any) => any): TreeLayout;
1133 | };
1134 | /**
1135 | * Runs the tree layout
1136 | */
1137 | nodes(root: GraphNode): GraphNode[];
1138 | /**
1139 | * Given the specified array of nodes, such as those returned by nodes, returns an array of objects representing the links from parent to child for each node
1140 | */
1141 | links(nodes: GraphNode[]): GraphLink[];
1142 | /**
1143 | * If separation is specified, uses the specified function to compute separation between neighboring nodes. If separation is not specified, returns the current separation function
1144 | */
1145 | seperation: {
1146 | /**
1147 | * Gets the current separation function
1148 | */
1149 | (): (a: GraphNode, b: GraphNode) => number;
1150 | /**
1151 | * Sets the specified function to compute separation between neighboring nodes
1152 | */
1153 | (seperation: (a: GraphNode, b: GraphNode) => number): TreeLayout;
1154 | };
1155 | /**
1156 | * Gets or sets the available layout size
1157 | */
1158 | size: {
1159 | /**
1160 | * Gets the available layout size
1161 | */
1162 | (): number[];
1163 | /**
1164 | * Sets the available layout size
1165 | */
1166 | (size: number[]): TreeLayout;
1167 | };
1168 | /**
1169 | * Gets or sets the available node size
1170 | */
1171 | nodeSize: {
1172 | /**
1173 | * Gets the available node size
1174 | */
1175 | (): number[];
1176 | /**
1177 | * Sets the available node size
1178 | */
1179 | (size: number[]): TreeLayout;
1180 | };
1181 | }
1182 |
1183 | export interface PieLayout {
1184 | (values: any[], index?: number): ArcDescriptor[];
1185 | value: {
1186 | (): (d: any, index: number) => number;
1187 | (accessor: (d: any, index: number) => number): PieLayout;
1188 | };
1189 | sort: {
1190 | (): (d1: any, d2: any) => number;
1191 | (comparator: (d1: any, d2: any) => number): PieLayout;
1192 | };
1193 | startAngle: {
1194 | (): number;
1195 | (angle: number): PieLayout;
1196 | (angle: () => number): PieLayout;
1197 | (angle: (d : any) => number): PieLayout;
1198 | (angle: (d : any, i: number) => number): PieLayout;
1199 | };
1200 | endAngle: {
1201 | (): number;
1202 | (angle: number): PieLayout;
1203 | (angle: () => number): PieLayout;
1204 | (angle: (d : any) => number): PieLayout
1205 | (angle: (d : any, i: number) => number): PieLayout;
1206 | };
1207 | }
1208 |
1209 | export interface ArcDescriptor {
1210 | value: any;
1211 | data: any;
1212 | startAngle: number;
1213 | endAngle: number;
1214 | index: number;
1215 | }
1216 |
1217 | export interface GraphNode {
1218 | id: number;
1219 | index: number;
1220 | name: string;
1221 | px: number;
1222 | py: number;
1223 | size: number;
1224 | weight: number;
1225 | x: number;
1226 | y: number;
1227 | subindex: number;
1228 | startAngle: number;
1229 | endAngle: number;
1230 | value: number;
1231 | fixed: boolean;
1232 | children: GraphNode[];
1233 | _children: GraphNode[];
1234 | parent: GraphNode;
1235 | depth: number;
1236 | }
1237 |
1238 | export interface GraphLink {
1239 | source: GraphNode;
1240 | target: GraphNode;
1241 | }
1242 |
1243 | export interface GraphNodeForce {
1244 | index?: number;
1245 | x?: number;
1246 | y?: number;
1247 | px?: number;
1248 | py?: number;
1249 | fixed?: boolean;
1250 | weight?: number;
1251 | }
1252 |
1253 | export interface GraphLinkForce {
1254 | source: GraphNodeForce;
1255 | target: GraphNodeForce;
1256 | }
1257 |
1258 | export interface ForceLayout {
1259 | (): ForceLayout;
1260 | size: {
1261 | (): number;
1262 | (mysize: number[]): ForceLayout;
1263 | (accessor: (d: any, index: number) => {}): ForceLayout;
1264 |
1265 | };
1266 | linkDistance: {
1267 | (): number;
1268 | (number:number): ForceLayout;
1269 | (accessor: (d: any, index: number) => number): ForceLayout;
1270 | };
1271 | linkStrength:
1272 | {
1273 | (): number;
1274 | (number:number): ForceLayout;
1275 | (accessor: (d: any, index: number) => number): ForceLayout;
1276 | };
1277 | friction:
1278 | {
1279 | (): number;
1280 | (number:number): ForceLayout;
1281 | (accessor: (d: any, index: number) => number): ForceLayout;
1282 | };
1283 | alpha: {
1284 | (): number;
1285 | (number:number): ForceLayout;
1286 | (accessor: (d: any, index: number) => number): ForceLayout;
1287 | };
1288 | charge: {
1289 | (): number;
1290 | (number:number): ForceLayout;
1291 | (accessor: (d: any, index: number) => number): ForceLayout;
1292 | };
1293 |
1294 | theta: {
1295 | (): number;
1296 | (number:number): ForceLayout;
1297 | (accessor: (d: any, index: number) => number): ForceLayout;
1298 | };
1299 |
1300 | gravity: {
1301 | (): number;
1302 | (number:number): ForceLayout;
1303 | (accessor: (d: any, index: number) => number): ForceLayout;
1304 | };
1305 |
1306 | links: {
1307 | (): GraphLinkForce[];
1308 | (arLinks: GraphLinkForce[]): ForceLayout;
1309 |
1310 | };
1311 | nodes:
1312 | {
1313 | (): GraphNodeForce[];
1314 | (arNodes: GraphNodeForce[]): ForceLayout;
1315 |
1316 | };
1317 | start(): ForceLayout;
1318 | resume(): ForceLayout;
1319 | stop(): ForceLayout;
1320 | tick(): ForceLayout;
1321 | on(type: string, listener: () => void ): ForceLayout;
1322 | drag(): ForceLayout;
1323 | }
1324 |
1325 | export interface BundleLayout{
1326 | (links: GraphLink[]): GraphNode[][];
1327 | }
1328 |
1329 | export interface ChordLayout {
1330 | matrix: {
1331 | (): number[][];
1332 | (matrix: number[][]): ChordLayout;
1333 | }
1334 | padding: {
1335 | (): number;
1336 | (padding: number): ChordLayout;
1337 | }
1338 | sortGroups: {
1339 | (): (a: number, b: number) => number;
1340 | (comparator: (a: number, b: number) => number): ChordLayout;
1341 | }
1342 | sortSubgroups: {
1343 | (): (a: number, b: number) => number;
1344 | (comparator: (a: number, b: number) => number): ChordLayout;
1345 | }
1346 | sortChords: {
1347 | (): (a: number, b: number) => number;
1348 | (comparator: (a: number, b: number) => number): ChordLayout;
1349 | }
1350 | chords(): GraphLink[];
1351 | groups(): ArcDescriptor[];
1352 | }
1353 |
1354 | export interface ClusterLayout{
1355 | sort: {
1356 | (): (a: GraphNode, b: GraphNode) => number;
1357 | (comparator: (a: GraphNode, b: GraphNode) => number): ClusterLayout;
1358 | }
1359 | children: {
1360 | (): (d: any, i?: number) => GraphNode[];
1361 | (children: (d: any, i?: number) => GraphNode[]): ClusterLayout;
1362 | }
1363 | nodes(root: GraphNode): GraphNode[];
1364 | links(nodes: GraphNode[]): GraphLink[];
1365 | seperation: {
1366 | (): (a: GraphNode, b: GraphNode) => number;
1367 | (seperation: (a: GraphNode, b: GraphNode) => number): ClusterLayout;
1368 | }
1369 | size: {
1370 | (): number[];
1371 | (size: number[]): ClusterLayout;
1372 | }
1373 | value: {
1374 | (): (node: GraphNode) => number;
1375 | (value: (node: GraphNode) => number): ClusterLayout;
1376 | }
1377 | }
1378 |
1379 | export interface HierarchyLayout {
1380 | sort: {
1381 | (): (a: GraphNode, b: GraphNode) => number;
1382 | (comparator: (a: GraphNode, b: GraphNode) => number): HierarchyLayout;
1383 | }
1384 | children: {
1385 | (): (d: any, i?: number) => GraphNode[];
1386 | (children: (d: any, i?: number) => GraphNode[]): HierarchyLayout;
1387 | }
1388 | nodes(root: GraphNode): GraphNode[];
1389 | links(nodes: GraphNode[]): GraphLink[];
1390 | value: {
1391 | (): (node: GraphNode) => number;
1392 | (value: (node: GraphNode) => number): HierarchyLayout;
1393 | }
1394 | reValue(root: GraphNode): HierarchyLayout;
1395 | }
1396 |
1397 | export interface Bin extends Array {
1398 | x: number;
1399 | dx: number;
1400 | y: number;
1401 | }
1402 |
1403 | export interface HistogramLayout {
1404 | (values: any[], index?: number): Bin[];
1405 | value: {
1406 | (): (value: any) => any;
1407 | (accessor: (value: any) => any): HistogramLayout
1408 | }
1409 | range: {
1410 | (): (value: any, index: number) => number[];
1411 | (range: (value: any, index: number) => number[]): HistogramLayout;
1412 | (range: number[]): HistogramLayout;
1413 | }
1414 | bins: {
1415 | (): (range: any[], index: number) => number[];
1416 | (bins: (range: any[], index: number) => number[]): HistogramLayout;
1417 | (bins: number): HistogramLayout;
1418 | (bins: number[]): HistogramLayout;
1419 | }
1420 | frequency: {
1421 | (): boolean;
1422 | (frequency: boolean): HistogramLayout;
1423 | }
1424 | }
1425 |
1426 | export interface PackLayout {
1427 | sort: {
1428 | (): (a: GraphNode, b: GraphNode) => number;
1429 | (comparator: (a: GraphNode, b: GraphNode) => number): PackLayout;
1430 | }
1431 | children: {
1432 | (): (d: any, i?: number) => GraphNode[];
1433 | (children: (d: any, i?: number) => GraphNode[]): PackLayout;
1434 | }
1435 | nodes(root: GraphNode): GraphNode[];
1436 | links(nodes: GraphNode[]): GraphLink[];
1437 | value: {
1438 | (): (node: GraphNode) => number;
1439 | (value: (node: GraphNode) => number): PackLayout;
1440 | }
1441 | size: {
1442 | (): number[];
1443 | (size: number[]): PackLayout;
1444 | }
1445 | padding: {
1446 | (): number;
1447 | (padding: number): PackLayout;
1448 | }
1449 | }
1450 |
1451 | export interface PartitionLayout {
1452 | sort: {
1453 | (): (a: GraphNode, b: GraphNode) => number;
1454 | (comparator: (a: GraphNode, b: GraphNode) => number): PackLayout;
1455 | }
1456 | children: {
1457 | (): (d: any, i?: number) => GraphNode[];
1458 | (children: (d: any, i?: number) => GraphNode[]): PackLayout;
1459 | }
1460 | nodes(root: GraphNode): GraphNode[];
1461 | links(nodes: GraphNode[]): GraphLink[];
1462 | value: {
1463 | (): (node: GraphNode) => number;
1464 | (value: (node: GraphNode) => number): PackLayout;
1465 | }
1466 | size: {
1467 | (): number[];
1468 | (size: number[]): PackLayout;
1469 | }
1470 | }
1471 |
1472 | export interface TreeMapLayout {
1473 | sort: {
1474 | (): (a: GraphNode, b: GraphNode) => number;
1475 | (comparator: (a: GraphNode, b: GraphNode) => number): TreeMapLayout;
1476 | }
1477 | children: {
1478 | (): (d: any, i?: number) => GraphNode[];
1479 | (children: (d: any, i?: number) => GraphNode[]): TreeMapLayout;
1480 | }
1481 | nodes(root: GraphNode): GraphNode[];
1482 | links(nodes: GraphNode[]): GraphLink[];
1483 | value: {
1484 | (): (node: GraphNode) => number;
1485 | (value: (node: GraphNode) => number): TreeMapLayout;
1486 | }
1487 | size: {
1488 | (): number[];
1489 | (size: number[]): TreeMapLayout;
1490 | }
1491 | padding: {
1492 | (): number;
1493 | (padding: number): TreeMapLayout;
1494 | }
1495 | round: {
1496 | (): boolean;
1497 | (round: boolean): TreeMapLayout;
1498 | }
1499 | sticky: {
1500 | (): boolean;
1501 | (sticky: boolean): TreeMapLayout;
1502 | }
1503 | mode: {
1504 | (): string;
1505 | (mode: string): TreeMapLayout;
1506 | }
1507 | }
1508 | }
1509 |
1510 | // Color
1511 | export module Color {
1512 | export interface Color {
1513 | /**
1514 | * increase lightness by some exponential factor (gamma)
1515 | */
1516 | brighter(k?: number): Color;
1517 | /**
1518 | * decrease lightness by some exponential factor (gamma)
1519 | */
1520 | darker(k?: number): Color;
1521 | /**
1522 | * convert the color to a string.
1523 | */
1524 | toString(): string;
1525 | }
1526 |
1527 | export interface RGBColor extends Color{
1528 | /**
1529 | * the red color channel.
1530 | */
1531 | r: number;
1532 | /**
1533 | * the green color channel.
1534 | */
1535 | g: number;
1536 | /**
1537 | * the blue color channel.
1538 | */
1539 | b: number;
1540 | /**
1541 | * convert from RGB to HSL.
1542 | */
1543 | hsl(): HSLColor;
1544 | }
1545 |
1546 | export interface HSLColor extends Color{
1547 | /**
1548 | * hue
1549 | */
1550 | h: number;
1551 | /**
1552 | * saturation
1553 | */
1554 | s: number;
1555 | /**
1556 | * lightness
1557 | */
1558 | l: number;
1559 | /**
1560 | * convert from HSL to RGB.
1561 | */
1562 | rgb(): RGBColor;
1563 | }
1564 |
1565 | export interface LABColor extends Color{
1566 | /**
1567 | * lightness
1568 | */
1569 | l: number;
1570 | /**
1571 | * a-dimension
1572 | */
1573 | a: number;
1574 | /**
1575 | * b-dimension
1576 | */
1577 | b: number;
1578 | /**
1579 | * convert from LAB to RGB.
1580 | */
1581 | rgb(): RGBColor;
1582 | }
1583 |
1584 | export interface HCLColor extends Color{
1585 | /**
1586 | * hue
1587 | */
1588 | h: number;
1589 | /**
1590 | * chroma
1591 | */
1592 | c: number;
1593 | /**
1594 | * luminance
1595 | */
1596 | l: number;
1597 | /**
1598 | * convert from HCL to RGB.
1599 | */
1600 | rgb(): RGBColor;
1601 | }
1602 | }
1603 |
1604 | // SVG
1605 | export module Svg {
1606 | export interface Svg {
1607 | /**
1608 | * Create a new symbol generator
1609 | */
1610 | symbol(): Symbol;
1611 | /**
1612 | * Create a new axis generator
1613 | */
1614 | axis(): Axis;
1615 | /**
1616 | * Create a new arc generator
1617 | */
1618 | arc(): Arc;
1619 | /**
1620 | * Create a new line generator
1621 | */
1622 | line: {
1623 | (): Line;
1624 | radial(): LineRadial;
1625 | }
1626 | /**
1627 | * Create a new area generator
1628 | */
1629 | area: {
1630 | (): Area;
1631 | radial(): AreaRadial;
1632 | }
1633 | /**
1634 | * Create a new brush generator
1635 | */
1636 | brush(): Brush;
1637 | /**
1638 | * Create a new chord generator
1639 | */
1640 | chord(): Chord;
1641 | /**
1642 | * Create a new diagonal generator
1643 | */
1644 | diagonal: {
1645 | (): Diagonal;
1646 | radial(): Diagonal;
1647 | }
1648 | /**
1649 | * The array of supported symbol types.
1650 | */
1651 | symbolTypes: string[];
1652 | }
1653 |
1654 | export interface Symbol {
1655 | type: (string:string) => Symbol;
1656 | size: (number:number) => Symbol;
1657 | (datum:any, index:number): string;
1658 | }
1659 |
1660 | export interface Brush {
1661 | /**
1662 | * Draws or redraws this brush into the specified selection of elements
1663 | */
1664 | (selection: Selection): void;
1665 | /**
1666 | * Gets or sets the x-scale associated with the brush
1667 | */
1668 | x: {
1669 | /**
1670 | * Gets the x-scale associated with the brush
1671 | */
1672 | (): D3.Scale.Scale;
1673 | /**
1674 | * Sets the x-scale associated with the brush
1675 | *
1676 | * @param accessor The new Scale
1677 | */
1678 | (scale: D3.Scale.Scale): Brush;
1679 | };
1680 | /**
1681 | * Gets or sets the x-scale associated with the brush
1682 | */
1683 | y: {
1684 | /**
1685 | * Gets the x-scale associated with the brush
1686 | */
1687 | (): D3.Scale.Scale;
1688 | /**
1689 | * Sets the x-scale associated with the brush
1690 | *
1691 | * @param accessor The new Scale
1692 | */
1693 | (scale: D3.Scale.Scale): Brush;
1694 | };
1695 | /**
1696 | * Gets or sets the current brush extent
1697 | */
1698 | extent: {
1699 | /**
1700 | * Gets the current brush extent
1701 | */
1702 | (): any[];
1703 | /**
1704 | * Sets the current brush extent
1705 | */
1706 | (values: any[]): Brush;
1707 | };
1708 | /**
1709 | * Clears the extent, making the brush extent empty.
1710 | */
1711 | clear(): Brush;
1712 | /**
1713 | * Returns true if and only if the brush extent is empty
1714 | */
1715 | empty(): boolean;
1716 | /**
1717 | * Gets or sets the listener for the specified event type
1718 | */
1719 | on: {
1720 | /**
1721 | * Gets the listener for the specified event type
1722 | */
1723 | (type: string): (data: any, index: number) => any;
1724 | /**
1725 | * Sets the listener for the specified event type
1726 | */
1727 | (type: string, listener: (data: any, index: number) => any, capture?: boolean): Brush;
1728 | };
1729 | }
1730 |
1731 | export interface Axis {
1732 | (selection: Selection): void;
1733 | scale: {
1734 | (): any;
1735 | (scale: any): Axis;
1736 | };
1737 |
1738 | orient: {
1739 | (): string;
1740 | (orientation: string): Axis;
1741 | };
1742 |
1743 | ticks: {
1744 | (): any[];
1745 | (...arguments: any[]): Axis;
1746 | };
1747 |
1748 | tickPadding: {
1749 | (): number;
1750 | (padding: number): Axis;
1751 | };
1752 |
1753 | tickValues: {
1754 | (): any[];
1755 | (values: any[]): Axis;
1756 | };
1757 | tickSubdivide(count: number): Axis;
1758 | tickSize: {
1759 | (): number;
1760 | (inner: number, outer?: number): Axis;
1761 | }
1762 | innerTickSize: {
1763 | (): number;
1764 | (value: number): Axis;
1765 | }
1766 | outerTickSize: {
1767 | (): number;
1768 | (value: number): Axis;
1769 | }
1770 | tickFormat(formatter: (value: any) => string): Axis;
1771 | nice(count?: number): Axis;
1772 | }
1773 |
1774 | export interface Arc {
1775 | /**
1776 | * Returns the path data string
1777 | *
1778 | * @param data Array of data elements
1779 | * @param index Optional index
1780 | */
1781 | (data: any, index?: number): string;
1782 | innerRadius: {
1783 | (): (data: any, index?: number) => number;
1784 | (radius: number): Arc;
1785 | (radius: () => number): Arc;
1786 | (radius: (data: any) => number): Arc;
1787 | (radius: (data: any, index: number) => number): Arc;
1788 | };
1789 | outerRadius: {
1790 | (): (data: any, index?: number) => number;
1791 | (radius: number): Arc;
1792 | (radius: () => number): Arc;
1793 | (radius: (data: any) => number): Arc;
1794 | (radius: (data: any, index: number) => number): Arc;
1795 | };
1796 | startAngle: {
1797 | (): (data: any, index?: number) => number;
1798 | (angle: number): Arc;
1799 | (angle: () => number): Arc;
1800 | (angle: (data: any) => number): Arc;
1801 | (angle: (data: any, index: number) => number): Arc;
1802 | };
1803 | endAngle: {
1804 | (): (data: any, index?: number) => number;
1805 | (angle: number): Arc;
1806 | (angle: () => number): Arc;
1807 | (angle: (data: any) => number): Arc;
1808 | (angle: (data: any, index: number) => number): Arc;
1809 | };
1810 | centroid(data: any, index?: number): number[];
1811 | }
1812 |
1813 | export interface Line {
1814 | /**
1815 | * Returns the path data string
1816 | *
1817 | * @param data Array of data elements
1818 | * @param index Optional index
1819 | */
1820 | (data: any[], index?: number): string;
1821 | /**
1822 | * Get or set the x-coordinate accessor.
1823 | */
1824 | x: {
1825 | /**
1826 | * Get the x-coordinate accessor.
1827 | */
1828 | (): (data: any, index ?: number) => number;
1829 | /**
1830 | * Set the x-coordinate accessor.
1831 | *
1832 | * @param accessor The new accessor function
1833 | */
1834 | (accessor: (data: any) => number): Line;
1835 | (accessor: (data: any, index: number) => number): Line;
1836 | /**
1837 | * Set the x-coordinate to a constant.
1838 | *
1839 | * @param cnst The new constant value.
1840 | */
1841 | (cnst: number): Line;
1842 | };
1843 | /**
1844 | * Get or set the y-coordinate accessor.
1845 | */
1846 | y: {
1847 | /**
1848 | * Get the y-coordinate accessor.
1849 | */
1850 | (): (data: any, index ?: number) => number;
1851 | /**
1852 | * Set the y-coordinate accessor.
1853 | *
1854 | * @param accessor The new accessor function
1855 | */
1856 | (accessor: (data: any) => number): Line;
1857 | (accessor: (data: any, index: number) => number): Line;
1858 | /**
1859 | * Set the y-coordinate to a constant.
1860 | *
1861 | * @param cnst The new constant value.
1862 | */
1863 | (cnst: number): Line;
1864 | };
1865 | /**
1866 | * Get or set the interpolation mode.
1867 | */
1868 | interpolate: {
1869 | /**
1870 | * Get the interpolation accessor.
1871 | */
1872 | (): string;
1873 | /**
1874 | * Set the interpolation accessor.
1875 | *
1876 | * @param interpolate The interpolation mode
1877 | */
1878 | (interpolate: string): Line;
1879 | };
1880 | /**
1881 | * Get or set the cardinal spline tension.
1882 | */
1883 | tension: {
1884 | /**
1885 | * Get the cardinal spline accessor.
1886 | */
1887 | (): number;
1888 | /**
1889 | * Set the cardinal spline accessor.
1890 | *
1891 | * @param tension The Cardinal spline interpolation tension
1892 | */
1893 | (tension: number): Line;
1894 | };
1895 | /**
1896 | * Control whether the line is defined at a given point.
1897 | */
1898 | defined: {
1899 | /**
1900 | * Get the accessor function that controls where the line is defined.
1901 | */
1902 | (): (data: any, index ?: number) => boolean;
1903 | /**
1904 | * Set the accessor function that controls where the area is defined.
1905 | *
1906 | * @param defined The new accessor function
1907 | */
1908 | (defined: (data: any) => boolean): Line;
1909 | };
1910 | }
1911 |
1912 | export interface LineRadial {
1913 | /**
1914 | * Returns the path data string
1915 | *
1916 | * @param data Array of data elements
1917 | * @param index Optional index
1918 | */
1919 | (data: any[], index?: number): string;
1920 | /**
1921 | * Get or set the x-coordinate accessor.
1922 | */
1923 | x: {
1924 | /**
1925 | * Get the x-coordinate accessor.
1926 | */
1927 | (): (data: any, index ?: number) => number;
1928 | /**
1929 | * Set the x-coordinate accessor.
1930 | *
1931 | * @param accessor The new accessor function
1932 | */
1933 | (accessor: (data: any) => number): LineRadial;
1934 | (accessor: (data: any, index: number) => number): LineRadial;
1935 |
1936 | /**
1937 | * Set the x-coordinate to a constant.
1938 | *
1939 | * @param cnst The new constant value.
1940 | */
1941 | (cnst: number): LineRadial;
1942 | };
1943 | /**
1944 | * Get or set the y-coordinate accessor.
1945 | */
1946 | y: {
1947 | /**
1948 | * Get the y-coordinate accessor.
1949 | */
1950 | (): (data: any, index ?: number) => number;
1951 | /**
1952 | * Set the y-coordinate accessor.
1953 | *
1954 | * @param accessor The new accessor function
1955 | */
1956 | (accessor: (data: any) => number): LineRadial;
1957 | (accessor: (data: any, index: number) => number): LineRadial;
1958 | /**
1959 | * Set the y-coordinate to a constant.
1960 | *
1961 | * @param cnst The new constant value.
1962 | */
1963 | (cnst: number): LineRadial;
1964 | };
1965 | /**
1966 | * Get or set the interpolation mode.
1967 | */
1968 | interpolate: {
1969 | /**
1970 | * Get the interpolation accessor.
1971 | */
1972 | (): string;
1973 | /**
1974 | * Set the interpolation accessor.
1975 | *
1976 | * @param interpolate The interpolation mode
1977 | */
1978 | (interpolate: string): LineRadial;
1979 | };
1980 | /**
1981 | * Get or set the cardinal spline tension.
1982 | */
1983 | tension: {
1984 | /**
1985 | * Get the cardinal spline accessor.
1986 | */
1987 | (): number;
1988 | /**
1989 | * Set the cardinal spline accessor.
1990 | *
1991 | * @param tension The Cardinal spline interpolation tension
1992 | */
1993 | (tension: number): LineRadial;
1994 | };
1995 | /**
1996 | * Control whether the line is defined at a given point.
1997 | */
1998 | defined: {
1999 | /**
2000 | * Get the accessor function that controls where the line is defined.
2001 | */
2002 | (): (data: any) => any;
2003 | /**
2004 | * Set the accessor function that controls where the area is defined.
2005 | *
2006 | * @param defined The new accessor function
2007 | */
2008 | (defined: (data: any) => any): LineRadial;
2009 | };
2010 | radius: {
2011 | (): (d: any, i?: number) => number;
2012 | (radius: number): LineRadial;
2013 | (radius: (d: any) => number): LineRadial;
2014 | (radius: (d: any, i: number) => number): LineRadial;
2015 | }
2016 | angle: {
2017 | (): (d: any, i?: any) => number;
2018 | (angle: number): LineRadial;
2019 | (angle: (d: any) => number): LineRadial;
2020 | (angle: (d: any, i: any) => number): LineRadial;
2021 | }
2022 | }
2023 |
2024 | export interface Area {
2025 | /**
2026 | * Generate a piecewise linear area, as in an area chart.
2027 | */
2028 | (data: any[], index?: number): string;
2029 | /**
2030 | * Get or set the x-coordinate accessor.
2031 | */
2032 | x: {
2033 | /**
2034 | * Get the x-coordinate accessor.
2035 | */
2036 | (): (data: any, index ?: number) => number;
2037 | /**
2038 | * Set the x-coordinate accessor.
2039 | *
2040 | * @param accessor The new accessor function
2041 | */
2042 | (accessor: (data: any) => number): Area;
2043 | (accessor: (data: any, index: number) => number): Area;
2044 | /**
2045 | * Set the x-coordinate to a constant.
2046 | *
2047 | * @param cnst The new constant value.
2048 | */
2049 | (cnst: number): Area;
2050 | };
2051 | /**
2052 | * Get or set the x0-coordinate (baseline) accessor.
2053 | */
2054 | x0: {
2055 | /**
2056 | * Get the x0-coordinate (baseline) accessor.
2057 | */
2058 | (): (data: any, index ?: number) => number;
2059 | /**
2060 | * Set the x0-coordinate (baseline) accessor.
2061 | *
2062 | * @param accessor The new accessor function
2063 | */
2064 | (accessor: (data: any) => number): Area;
2065 | (accessor: (data: any, index: number) => number): Area;
2066 | /**
2067 | * Set the x0-coordinate (baseline) to a constant.
2068 | *
2069 | * @param cnst The new constant value.
2070 | */
2071 | (cnst: number): Area;
2072 | };
2073 | /**
2074 | * Get or set the x1-coordinate (topline) accessor.
2075 | */
2076 | x1: {
2077 | /**
2078 | * Get the x1-coordinate (topline) accessor.
2079 | */
2080 | (): (data: any, index ?: number) => number;
2081 | /**
2082 | * Set the x1-coordinate (topline) accessor.
2083 | *
2084 | * @param accessor The new accessor function
2085 | */
2086 | (accessor: (data: any) => number): Area;
2087 | (accessor: (data: any, index: number) => number): Area;
2088 | /**
2089 | * Set the x1-coordinate (topline) to a constant.
2090 | *
2091 | * @param cnst The new constant value.
2092 | */
2093 | (cnst: number): Area;
2094 | };
2095 | /**
2096 | * Get or set the y-coordinate accessor.
2097 | */
2098 | y: {
2099 | /**
2100 | * Get the y-coordinate accessor.
2101 | */
2102 | (): (data: any, index ?: number) => number;
2103 | /**
2104 | * Set the y-coordinate accessor.
2105 | *
2106 | * @param accessor The new accessor function
2107 | */
2108 | (accessor: (data: any) => number): Area;
2109 | (accessor: (data: any, index: number) => number): Area;
2110 | /**
2111 | * Set the y-coordinate to a constant.
2112 | *
2113 | * @param cnst The constant value
2114 | */
2115 | (cnst: number): Area;
2116 | };
2117 | /**
2118 | * Get or set the y0-coordinate (baseline) accessor.
2119 | */
2120 | y0: {
2121 | /**
2122 | * Get the y0-coordinate (baseline) accessor.
2123 | */
2124 | (): (data: any, index ?: number) => number;
2125 | /**
2126 | * Set the y0-coordinate (baseline) accessor.
2127 | *
2128 | * @param accessor The new accessor function
2129 | */
2130 | (accessor: (data: any) => number): Area;
2131 | (accessor: (data: any, index: number) => number): Area;
2132 | /**
2133 | * Set the y0-coordinate (baseline) to a constant.
2134 | *
2135 | * @param cnst The constant value
2136 | */
2137 | (cnst: number): Area;
2138 | };
2139 | /**
2140 | * Get or set the y1-coordinate (topline) accessor.
2141 | */
2142 | y1: {
2143 | /**
2144 | * Get the y1-coordinate (topline) accessor.
2145 | */
2146 | (): (data: any, index ?: number) => number;
2147 | /**
2148 | * Set the y1-coordinate (topline) accessor.
2149 | *
2150 | * @param accessor The new accessor function
2151 | */
2152 | (accessor: (data: any) => number): Area;
2153 | (accessor: (data: any, index: number) => number): Area;
2154 | /**
2155 | * Set the y1-coordinate (baseline) to a constant.
2156 | *
2157 | * @param cnst The constant value
2158 | */
2159 | (cnst: number): Area;
2160 | };
2161 | /**
2162 | * Get or set the interpolation mode.
2163 | */
2164 | interpolate: {
2165 | /**
2166 | * Get the interpolation accessor.
2167 | */
2168 | (): string;
2169 | /**
2170 | * Set the interpolation accessor.
2171 | *
2172 | * @param interpolate The interpolation mode
2173 | */
2174 | (interpolate: string): Area;
2175 | };
2176 | /**
2177 | * Get or set the cardinal spline tension.
2178 | */
2179 | tension: {
2180 | /**
2181 | * Get the cardinal spline accessor.
2182 | */
2183 | (): number;
2184 | /**
2185 | * Set the cardinal spline accessor.
2186 | *
2187 | * @param tension The Cardinal spline interpolation tension
2188 | */
2189 | (tension: number): Area;
2190 | };
2191 | /**
2192 | * Control whether the area is defined at a given point.
2193 | */
2194 | defined: {
2195 | /**
2196 | * Get the accessor function that controls where the area is defined.
2197 | */
2198 | (): (data: any) => any;
2199 | /**
2200 | * Set the accessor function that controls where the area is defined.
2201 | *
2202 | * @param defined The new accessor function
2203 | */
2204 | (defined: (data: any) => any): Area;
2205 | };
2206 | }
2207 |
2208 | export interface AreaRadial {
2209 | /**
2210 | * Generate a piecewise linear area, as in an area chart.
2211 | */
2212 | (data: any[], index?: number): string;
2213 | /**
2214 | * Get or set the x-coordinate accessor.
2215 | */
2216 | x: {
2217 | /**
2218 | * Get the x-coordinate accessor.
2219 | */
2220 | (): (data: any, index ?: number) => number;
2221 | /**
2222 | * Set the x-coordinate accessor.
2223 | *
2224 | * @param accessor The new accessor function
2225 | */
2226 | (accessor: (data: any) => number): AreaRadial;
2227 | (accessor: (data: any, index: number) => number): AreaRadial;
2228 | /**
2229 | * Set the x-coordinate to a constant.
2230 | *
2231 | * @param cnst The new constant value.
2232 | */
2233 | (cnst: number): AreaRadial;
2234 | };
2235 | /**
2236 | * Get or set the x0-coordinate (baseline) accessor.
2237 | */
2238 | x0: {
2239 | /**
2240 | * Get the x0-coordinate (baseline) accessor.
2241 | */
2242 | (): (data: any, index ?: number) => number;
2243 | /**
2244 | * Set the x0-coordinate (baseline) accessor.
2245 | *
2246 | * @param accessor The new accessor function
2247 | */
2248 | (accessor: (data: any) => number): AreaRadial;
2249 | (accessor: (data: any, index: number) => number): AreaRadial;
2250 | /**
2251 | * Set the x0-coordinate to a constant.
2252 | *
2253 | * @param cnst The new constant value.
2254 | */
2255 | (cnst: number): AreaRadial;
2256 | };
2257 | /**
2258 | * Get or set the x1-coordinate (topline) accessor.
2259 | */
2260 | x1: {
2261 | /**
2262 | * Get the x1-coordinate (topline) accessor.
2263 | */
2264 | (): (data: any, index ?: number) => number;
2265 | /**
2266 | * Set the x1-coordinate (topline) accessor.
2267 | *
2268 | * @param accessor The new accessor function
2269 | */
2270 | (accessor: (data: any) => number): AreaRadial;
2271 | (accessor: (data: any, index: number) => number): AreaRadial;
2272 | /**
2273 | * Set the x1-coordinate to a constant.
2274 | *
2275 | * @param cnst The new constant value.
2276 | */
2277 | (cnst: number): AreaRadial;
2278 | };
2279 | /**
2280 | * Get or set the y-coordinate accessor.
2281 | */
2282 | y: {
2283 | /**
2284 | * Get the y-coordinate accessor.
2285 | */
2286 | (): (data: any, index ?: number) => number;
2287 | /**
2288 | * Set the y-coordinate accessor.
2289 | *
2290 | * @param accessor The new accessor function
2291 | */
2292 | (accessor: (data: any) => number): AreaRadial;
2293 | (accessor: (data: any, index: number) => number): AreaRadial;
2294 | /**
2295 | * Set the y-coordinate to a constant.
2296 | *
2297 | * @param cnst The new constant value.
2298 | */
2299 | (cnst: number): AreaRadial;
2300 | };
2301 | /**
2302 | * Get or set the y0-coordinate (baseline) accessor.
2303 | */
2304 | y0: {
2305 | /**
2306 | * Get the y0-coordinate (baseline) accessor.
2307 | */
2308 | (): (data: any, index ?: number) => number;
2309 | /**
2310 | * Set the y0-coordinate (baseline) accessor.
2311 | *
2312 | * @param accessor The new accessor function
2313 | */
2314 | (accessor: (data: any) => number): AreaRadial;
2315 | (accessor: (data: any, index: number) => number): AreaRadial;
2316 | /**
2317 | * Set the y0-coordinate to a constant.
2318 | *
2319 | * @param cnst The new constant value.
2320 | */
2321 | (cnst: number): AreaRadial;
2322 | };
2323 | /**
2324 | * Get or set the y1-coordinate (topline) accessor.
2325 | */
2326 | y1: {
2327 | /**
2328 | * Get the y1-coordinate (topline) accessor.
2329 | */
2330 | (): (data: any, index ?: number) => number;
2331 | /**
2332 | * Set the y1-coordinate (topline) accessor.
2333 | *
2334 | * @param accessor The new accessor function
2335 | */
2336 | (accessor: (data: any) => number): AreaRadial;
2337 | (accessor: (data: any, index: number) => number): AreaRadial;
2338 | /**
2339 | * Set the y1-coordinate to a constant.
2340 | *
2341 | * @param cnst The new constant value.
2342 | */
2343 | (cnst: number): AreaRadial;
2344 | };
2345 | /**
2346 | * Get or set the interpolation mode.
2347 | */
2348 | interpolate: {
2349 | /**
2350 | * Get the interpolation accessor.
2351 | */
2352 | (): string;
2353 | /**
2354 | * Set the interpolation accessor.
2355 | *
2356 | * @param interpolate The interpolation mode
2357 | */
2358 | (interpolate: string): AreaRadial;
2359 | };
2360 | /**
2361 | * Get or set the cardinal spline tension.
2362 | */
2363 | tension: {
2364 | /**
2365 | * Get the cardinal spline accessor.
2366 | */
2367 | (): number;
2368 | /**
2369 | * Set the cardinal spline accessor.
2370 | *
2371 | * @param tension The Cardinal spline interpolation tension
2372 | */
2373 | (tension: number): AreaRadial;
2374 | };
2375 | /**
2376 | * Control whether the area is defined at a given point.
2377 | */
2378 | defined: {
2379 | /**
2380 | * Get the accessor function that controls where the area is defined.
2381 | */
2382 | (): (data: any) => any;
2383 | /**
2384 | * Set the accessor function that controls where the area is defined.
2385 | *
2386 | * @param defined The new accessor function
2387 | */
2388 | (defined: (data: any) => any): AreaRadial;
2389 | };
2390 | radius: {
2391 | (): number;
2392 | (radius: number): AreaRadial;
2393 | (radius: () => number): AreaRadial;
2394 | (radius: (data: any) => number): AreaRadial;
2395 | (radius: (data: any, index: number) => number): AreaRadial;
2396 | };
2397 | innerRadius: {
2398 | (): number;
2399 | (radius: number): AreaRadial;
2400 | (radius: () => number): AreaRadial;
2401 | (radius: (data: any) => number): AreaRadial;
2402 | (radius: (data: any, index: number) => number): AreaRadial;
2403 | };
2404 | outerRadius: {
2405 | (): number;
2406 | (radius: number): AreaRadial;
2407 | (radius: () => number): AreaRadial;
2408 | (radius: (data: any) => number): AreaRadial;
2409 | (radius: (data: any, index: number) => number): AreaRadial;
2410 | };
2411 | angle: {
2412 | (): number;
2413 | (angle: number): AreaRadial;
2414 | (angle: () => number): AreaRadial;
2415 | (angle: (data: any) => number): AreaRadial;
2416 | (angle: (data: any, index: number) => number): AreaRadial;
2417 | };
2418 | startAngle: {
2419 | (): number;
2420 | (angle: number): AreaRadial;
2421 | (angle: () => number): AreaRadial;
2422 | (angle: (data: any) => number): AreaRadial;
2423 | (angle: (data: any, index: number) => number): AreaRadial;
2424 | };
2425 | endAngle: {
2426 | (): number;
2427 | (angle: number): AreaRadial;
2428 | (angle: () => number): AreaRadial;
2429 | (angle: (data: any) => number): AreaRadial;
2430 | (angle: (data: any, index: number) => number): AreaRadial;
2431 | };
2432 | }
2433 |
2434 | export interface Chord {
2435 | (datum: any, index?: number): string;
2436 | radius: {
2437 | (): number;
2438 | (radius: number): Chord;
2439 | (radius: () => number): Chord;
2440 | };
2441 | startAngle: {
2442 | (): number;
2443 | (angle: number): Chord;
2444 | (angle: () => number): Chord;
2445 | };
2446 | endAngle: {
2447 | (): number;
2448 | (angle: number): Chord;
2449 | (angle: () => number): Chord;
2450 | };
2451 | source: {
2452 | (): any;
2453 | (angle: any): Chord;
2454 | (angle: (d: any, i?: number) => any): Chord;
2455 | };
2456 | target: {
2457 | (): any;
2458 | (angle: any): Chord;
2459 | (angle: (d: any, i?: number) => any): Chord;
2460 | };
2461 | }
2462 |
2463 | export interface Diagonal {
2464 | (datum: any, index?: number): string;
2465 | projection: {
2466 | (): (datum: any, index?: number) => number[];
2467 | (proj: (datum: any) => number[]): Diagonal;
2468 | (proj: (datum: any, index: number) => number[]): Diagonal;
2469 | };
2470 | source: {
2471 | (): (datum: any, index?: number) => any;
2472 | (src: (datum: any) => any): Diagonal;
2473 | (src: (datum: any, index: number) => any): Diagonal;
2474 | (src: any): Diagonal;
2475 | };
2476 | target: {
2477 | (): (datum: any, index?: number) => any;
2478 | (target: (d: any) => any): Diagonal;
2479 | (target: (d: any, i: number) => any): Diagonal;
2480 | (target: any): Diagonal;
2481 | };
2482 | }
2483 | }
2484 |
2485 | // Scales
2486 | export module Scale {
2487 | export interface ScaleBase {
2488 | /**
2489 | * Construct a linear quantitative scale.
2490 | */
2491 | linear(): LinearScale;
2492 | /*
2493 | * Construct an ordinal scale.
2494 | */
2495 | ordinal(): OrdinalScale;
2496 | /**
2497 | * Construct a linear quantitative scale with a discrete output range.
2498 | */
2499 | quantize(): QuantizeScale;
2500 | /*
2501 | * Construct an ordinal scale with ten categorical colors.
2502 | */
2503 | category10(): OrdinalScale;
2504 | /*
2505 | * Construct an ordinal scale with twenty categorical colors
2506 | */
2507 | category20(): OrdinalScale;
2508 | /*
2509 | * Construct an ordinal scale with twenty categorical colors
2510 | */
2511 | category20b(): OrdinalScale;
2512 | /*
2513 | * Construct an ordinal scale with twenty categorical colors
2514 | */
2515 | category20c(): OrdinalScale;
2516 | /*
2517 | * Construct a linear identity scale.
2518 | */
2519 | identity(): IdentityScale;
2520 | /*
2521 | * Construct a quantitative scale with an logarithmic transform.
2522 | */
2523 | log(): LogScale;
2524 | /*
2525 | * Construct a quantitative scale with an exponential transform.
2526 | */
2527 | pow(): PowScale;
2528 | /*
2529 | * Construct a quantitative scale mapping to quantiles.
2530 | */
2531 | quantile(): QuantileScale;
2532 | /*
2533 | * Construct a quantitative scale with a square root transform.
2534 | */
2535 | sqrt(): SqrtScale;
2536 | /*
2537 | * Construct a threshold scale with a discrete output range.
2538 | */
2539 | threshold(): ThresholdScale;
2540 | }
2541 |
2542 | export interface GenericScale {
2543 | (value: any): any;
2544 | domain: {
2545 | (values: any[]): S;
2546 | (): any[];
2547 | };
2548 | range: {
2549 | (values: any[]): S;
2550 | (): any[];
2551 | };
2552 | invertExtent?(y: any): any[];
2553 | copy(): S;
2554 | }
2555 |
2556 | export interface Scale extends GenericScale { }
2557 |
2558 | export interface GenericQuantitativeScale extends GenericScale {
2559 | /**
2560 | * Get the range value corresponding to a given domain value.
2561 | *
2562 | * @param value Domain Value
2563 | */
2564 | (value: number): number;
2565 | /**
2566 | * Get the domain value corresponding to a given range value.
2567 | *
2568 | * @param value Range Value
2569 | */
2570 | invert(value: number): number;
2571 | /**
2572 | * Set the scale's output range, and enable rounding.
2573 | *
2574 | * @param value The output range.
2575 | */
2576 | rangeRound: (values: any[]) => S;
2577 | /**
2578 | * get or set the scale's output interpolator.
2579 | */
2580 | interpolate: {
2581 | (): D3.Transition.Interpolate;
2582 | (factory: D3.Transition.Interpolate): S;
2583 | };
2584 | /**
2585 | * enable or disable clamping of the output range.
2586 | *
2587 | * @param clamp Enable or disable
2588 | */
2589 | clamp: {
2590 | (): boolean;
2591 | (clamp: boolean): S;
2592 | }
2593 | /**
2594 | * extend the scale domain to nice round numbers.
2595 | *
2596 | * @param count Optional number of ticks to exactly fit the domain
2597 | */
2598 | nice(count?: number): S;
2599 | /**
2600 | * get representative values from the input domain.
2601 | *
2602 | * @param count Aproximate representative values to return.
2603 | */
2604 | ticks(count: number): any[];
2605 | /**
2606 | * get a formatter for displaying tick values
2607 | *
2608 | * @param count Aproximate representative values to return
2609 | */
2610 | tickFormat(count: number, format?: string): (n: number) => string;
2611 | }
2612 |
2613 | export interface QuantitativeScale extends GenericQuantitativeScale { }
2614 |
2615 | export interface LinearScale extends GenericQuantitativeScale { }
2616 |
2617 | export interface IdentityScale extends GenericScale {
2618 | /**
2619 | * Get the range value corresponding to a given domain value.
2620 | *
2621 | * @param value Domain Value
2622 | */
2623 | (value: number): number;
2624 | /**
2625 | * Get the domain value corresponding to a given range value.
2626 | *
2627 | * @param value Range Value
2628 | */
2629 | invert(value: number): number;
2630 | /**
2631 | * get representative values from the input domain.
2632 | *
2633 | * @param count Aproximate representative values to return.
2634 | */
2635 | ticks(count: number): any[];
2636 | /**
2637 | * get a formatter for displaying tick values
2638 | *
2639 | * @param count Aproximate representative values to return
2640 | */
2641 | tickFormat(count: number): (n: number) => string;
2642 | }
2643 |
2644 | export interface SqrtScale extends GenericQuantitativeScale { }
2645 |
2646 | export interface PowScale extends GenericQuantitativeScale { }
2647 |
2648 | export interface LogScale extends GenericQuantitativeScale { }
2649 |
2650 | export interface OrdinalScale extends GenericScale {
2651 | rangePoints(interval: any[], padding?: number): OrdinalScale;
2652 | rangeBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale;
2653 | rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale;
2654 | rangeBand(): number;
2655 | rangeExtent(): any[];
2656 | }
2657 |
2658 | export interface QuantizeScale extends GenericScale { }
2659 |
2660 | export interface ThresholdScale extends GenericScale { }
2661 |
2662 | export interface QuantileScale extends GenericScale {
2663 | quantiles(): any[];
2664 | }
2665 |
2666 | export interface TimeScale extends GenericScale {
2667 | (value: Date): number;
2668 | invert(value: number): Date;
2669 | rangeRound: (values: any[]) => TimeScale;
2670 | interpolate: {
2671 | (): D3.Transition.Interpolate;
2672 | (factory: D3.Transition.InterpolateFactory): TimeScale;
2673 | };
2674 | clamp(clamp: boolean): TimeScale;
2675 | ticks: {
2676 | (count: number): any[];
2677 | (range: D3.Time.Range, count: number): any[];
2678 | };
2679 | tickFormat(count: number): (n: number) => string;
2680 | nice(count?: number): TimeScale;
2681 | }
2682 | }
2683 |
2684 | // Behaviour
2685 | export module Behavior {
2686 | export interface Behavior{
2687 | /**
2688 | * Constructs a new drag behaviour
2689 | */
2690 | drag(): Drag;
2691 | /**
2692 | * Constructs a new zoom behaviour
2693 | */
2694 | zoom(): Zoom;
2695 | }
2696 |
2697 | export interface Zoom {
2698 | /**
2699 | * Applies the zoom behavior to the specified selection,
2700 | * registering the necessary event listeners to support
2701 | * panning and zooming.
2702 | */
2703 | (selection: Selection): void;
2704 |
2705 | /**
2706 | * Registers a listener to receive events
2707 | *
2708 | * @param type Enent name to attach the listener to
2709 | * @param listener Function to attach to event
2710 | */
2711 | on: (type: string, listener: (data: any, index?: number) => any) => Zoom;
2712 |
2713 | /**
2714 | * Gets or set the current zoom scale
2715 | */
2716 | scale: {
2717 | /**
2718 | * Get the current current zoom scale
2719 | */
2720 | (): number;
2721 | /**
2722 | * Set the current current zoom scale
2723 | *
2724 | * @param origin Zoom scale
2725 | */
2726 | (scale: number): Zoom;
2727 | };
2728 |
2729 | /**
2730 | * Gets or set the current zoom translation vector
2731 | */
2732 | translate: {
2733 | /**
2734 | * Get the current zoom translation vector
2735 | */
2736 | (): number[];
2737 | /**
2738 | * Set the current zoom translation vector
2739 | *
2740 | * @param translate Tranlation vector
2741 | */
2742 | (translate: number[]): Zoom;
2743 | };
2744 |
2745 | /**
2746 | * Gets or set the allowed scale range
2747 | */
2748 | scaleExtent: {
2749 | /**
2750 | * Get the current allowed zoom range
2751 | */
2752 | (): number[];
2753 | /**
2754 | * Set the allowable zoom range
2755 | *
2756 | * @param extent Allowed zoom range
2757 | */
2758 | (extent: number[]): Zoom;
2759 | };
2760 |
2761 | /**
2762 | * Gets or set the X-Scale that should be adjusted when zooming
2763 | */
2764 | x: {
2765 | /**
2766 | * Get the X-Scale
2767 | */
2768 | (): D3.Scale.Scale;
2769 | /**
2770 | * Set the X-Scale to be adjusted
2771 | *
2772 | * @param x The X Scale
2773 | */
2774 | (x: D3.Scale.Scale): Zoom;
2775 |
2776 | };
2777 |
2778 | /**
2779 | * Gets or set the Y-Scale that should be adjusted when zooming
2780 | */
2781 | y: {
2782 | /**
2783 | * Get the Y-Scale
2784 | */
2785 | (): D3.Scale.Scale;
2786 | /**
2787 | * Set the Y-Scale to be adjusted
2788 | *
2789 | * @param y The Y Scale
2790 | */
2791 | (y: D3.Scale.Scale): Zoom;
2792 | };
2793 | }
2794 |
2795 | export interface Drag {
2796 | /**
2797 | * Execute drag method
2798 | */
2799 | (): any;
2800 |
2801 | /**
2802 | * Registers a listener to receive events
2803 | *
2804 | * @param type Enent name to attach the listener to
2805 | * @param listener Function to attach to event
2806 | */
2807 | on: (type: string, listener: (data: any, index?: number) => any) => Drag;
2808 |
2809 | /**
2810 | * Gets or set the current origin accessor function
2811 | */
2812 | origin: {
2813 | /**
2814 | * Get the current origin accessor function
2815 | */
2816 | (): any;
2817 | /**
2818 | * Set the origin accessor function
2819 | *
2820 | * @param origin Accessor function
2821 | */
2822 | (origin?: any): Drag;
2823 | };
2824 | }
2825 | }
2826 |
2827 | // Geography
2828 | export module Geo {
2829 | export interface Geo {
2830 | /**
2831 | * create a new geographic path generator
2832 | */
2833 | path(): Path;
2834 | /**
2835 | * create a circle generator.
2836 | */
2837 | circle(): Circle;
2838 | /**
2839 | * compute the spherical area of a given feature.
2840 | */
2841 | area(feature: any): number;
2842 | /**
2843 | * compute the latitude-longitude bounding box for a given feature.
2844 | */
2845 | bounds(feature: any): number[][];
2846 | /**
2847 | * compute the spherical centroid of a given feature.
2848 | */
2849 | centroid(feature: any): number[];
2850 | /**
2851 | * compute the great-arc distance between two points.
2852 | */
2853 | distance(a: number[], b: number[]): number;
2854 | /**
2855 | * interpolate between two points along a great arc.
2856 | */
2857 | interpolate(a: number[], b: number[]): (t: number) => number[];
2858 | /**
2859 | * compute the length of a line string or the circumference of a polygon.
2860 | */
2861 | length(feature: any): number;
2862 | /**
2863 | * create a standard projection from a raw projection.
2864 | */
2865 | projection(raw: RawProjection): Projection;
2866 | /**
2867 | * create a standard projection from a mutable raw projection.
2868 | */
2869 | projectionMutator(rawFactory: RawProjection): ProjectionMutator;
2870 | /**
2871 | * the Albers equal-area conic projection.
2872 | */
2873 | albers(): Projection;
2874 | /**
2875 | * a composite Albers projection for the United States.
2876 | */
2877 | albersUsa(): Projection;
2878 | /**
2879 | * the azimuthal equal-area projection.
2880 | */
2881 | azimuthalEqualArea: {
2882 | (): Projection;
2883 | raw: RawProjection;
2884 | }
2885 | /**
2886 | * the azimuthal equidistant projection.
2887 | */
2888 | azimuthalEquidistant: {
2889 | (): Projection;
2890 | raw: RawProjection;
2891 | }
2892 | /**
2893 | * the conic conformal projection.
2894 | */
2895 | conicConformal: {
2896 | (): Projection;
2897 | raw(phi1:number, phi2:number): RawProjection;
2898 | }
2899 | /**
2900 | * the conic equidistant projection.
2901 | */
2902 | conicEquidistant: {
2903 | (): Projection;
2904 | raw(phi1:number, phi2:number): RawProjection;
2905 | }
2906 | /**
2907 | * the conic equal-area (a.k.a. Albers) projection.
2908 | */
2909 | conicEqualArea: {
2910 | (): Projection;
2911 | raw(phi1:number, phi2:number): RawProjection;
2912 | }
2913 | /**
2914 | * the equirectangular (plate carreé) projection.
2915 | */
2916 | equirectangular: {
2917 | (): Projection;
2918 | raw: RawProjection;
2919 | }
2920 | /**
2921 | * the gnomonic projection.
2922 | */
2923 | gnomonic: {
2924 | (): Projection;
2925 | raw: RawProjection;
2926 | }
2927 | /**
2928 | * the spherical Mercator projection.
2929 | */
2930 | mercator: {
2931 | (): Projection;
2932 | raw: RawProjection;
2933 | }
2934 | /**
2935 | * the azimuthal orthographic projection.
2936 | */
2937 | orthographic: {
2938 | (): Projection;
2939 | raw: RawProjection;
2940 | }
2941 | /**
2942 | * the azimuthal stereographic projection.
2943 | */
2944 | stereographic: {
2945 | (): Projection;
2946 | raw: RawProjection;
2947 | }
2948 | /**
2949 | * the transverse Mercator projection.
2950 | */
2951 | transverseMercator: {
2952 | (): Projection;
2953 | raw: RawProjection;
2954 | }
2955 | /**
2956 | * convert a GeoJSON object to a geometry stream.
2957 | */
2958 | stream(object: GeoJSON, listener: Stream): void;
2959 | /**
2960 | *
2961 | */
2962 | graticule(): Graticule;
2963 | /**
2964 | *
2965 | */
2966 | greatArc(): GreatArc;
2967 | /**
2968 | *
2969 | */
2970 | rotation(rotation: number[]): Rotation;
2971 | }
2972 |
2973 | export interface Path {
2974 | /**
2975 | * Returns the path data string for the given feature
2976 | */
2977 | (feature: any, index?: any): string;
2978 | /**
2979 | * get or set the geographic projection.
2980 | */
2981 | projection: {
2982 | /**
2983 | * get the geographic projection.
2984 | */
2985 | (): Projection;
2986 | /**
2987 | * set the geographic projection.
2988 | */
2989 | (projection: Projection): Path;
2990 | }
2991 | /**
2992 | * get or set the render context.
2993 | */
2994 | context: {
2995 | /**
2996 | * return an SVG path string invoked on the given feature.
2997 | */
2998 | (): string;
2999 | /**
3000 | * sets the render context and returns the path generator
3001 | */
3002 | (context: Context): Path;
3003 | }
3004 | /**
3005 | * Computes the projected area
3006 | */
3007 | area(feature: any): any;
3008 | /**
3009 | * Computes the projected centroid
3010 | */
3011 | centroid(feature: any): any;
3012 | /**
3013 | * Computes the projected bounding box
3014 | */
3015 | bounds(feature: any): any;
3016 | /**
3017 | * get or set the radius to display point features.
3018 | */
3019 | pointRadius: {
3020 | /**
3021 | * returns the current radius
3022 | */
3023 | (): number;
3024 | /**
3025 | * sets the radius used to display Point and MultiPoint features to the specified number
3026 | */
3027 | (radius: number): Path;
3028 | /**
3029 | * sets the radius used to display Point and MultiPoint features to the specified number
3030 | */
3031 | (radius: (feature: any, index: number) => number): Path;
3032 | }
3033 | }
3034 |
3035 | export interface Context {
3036 | beginPath(): any;
3037 | moveTo(x: number, y: number): any;
3038 | lineTo(x: number, y: number): any;
3039 | arc(x: number, y: number, radius: number, startAngle: number, endAngle: number): any;
3040 | closePath(): any;
3041 | }
3042 |
3043 | export interface Circle {
3044 | (...args: any[]): GeoJSON;
3045 | origin: {
3046 | (): number[];
3047 | (origin: number[]): Circle;
3048 | (origin: (...args: any[]) => number[]): Circle;
3049 | }
3050 | angle: {
3051 | (): number;
3052 | (angle: number): Circle;
3053 | }
3054 | precision: {
3055 | (): number;
3056 | (precision: number): Circle;
3057 | }
3058 | }
3059 |
3060 | export interface Graticule{
3061 | (): GeoJSON;
3062 | lines(): GeoJSON[];
3063 | outline(): GeoJSON;
3064 | extent: {
3065 | (): number[][];
3066 | (extent: number[][]): Graticule;
3067 | }
3068 | minorExtent: {
3069 | (): number[][];
3070 | (extent: number[][]): Graticule;
3071 | }
3072 | majorExtent: {
3073 | (): number[][];
3074 | (extent: number[][]): Graticule;
3075 | }
3076 | step: {
3077 | (): number[][];
3078 | (extent: number[][]): Graticule;
3079 | }
3080 | minorStep: {
3081 | (): number[][];
3082 | (extent: number[][]): Graticule;
3083 | }
3084 | majorStep: {
3085 | (): number[][];
3086 | (extent: number[][]): Graticule;
3087 | }
3088 | precision: {
3089 | (): number;
3090 | (precision: number): Graticule;
3091 | }
3092 | }
3093 |
3094 | export interface GreatArc {
3095 | (): GeoJSON;
3096 | distance(): number;
3097 | source: {
3098 | (): any;
3099 | (source: any): GreatArc;
3100 | }
3101 | target: {
3102 | (): any;
3103 | (target: any): GreatArc;
3104 | }
3105 | precision: {
3106 | (): number;
3107 | (precision: number): GreatArc;
3108 | }
3109 | }
3110 |
3111 | export interface GeoJSON {
3112 | coordinates: number[][];
3113 | type: string;
3114 | }
3115 |
3116 | export interface RawProjection {
3117 | (lambda: number, phi: number): number[];
3118 | invert?(x: number, y: number): number[];
3119 | }
3120 |
3121 | export interface Projection {
3122 | (coordinates: number[]): number[];
3123 | invert?(point: number[]): number[];
3124 | rotate: {
3125 | (): number[];
3126 | (rotation: number[]): Projection;
3127 | };
3128 | center: {
3129 | (): number[];
3130 | (location: number[]): Projection;
3131 | };
3132 | parallels: {
3133 | (): number[];
3134 | (location: number[]): Projection;
3135 | };
3136 | translate: {
3137 | (): number[];
3138 | (point: number[]): Projection;
3139 | };
3140 | scale: {
3141 | (): number;
3142 | (scale: number): Projection;
3143 | };
3144 | clipAngle: {
3145 | (): number;
3146 | (angle: number): Projection;
3147 | };
3148 | clipExtent: {
3149 | (): number[][];
3150 | (extent: number[][]): Projection;
3151 | };
3152 | precision: {
3153 | (): number;
3154 | (precision: number): Projection;
3155 | };
3156 | stream(listener?: Stream): Stream;
3157 | }
3158 |
3159 | export interface Stream {
3160 | point(x: number, y: number, z?: number): void;
3161 | lineStart(): void;
3162 | lineEnd(): void;
3163 | polygonStart(): void;
3164 | polygonEnd(): void;
3165 | sphere(): void;
3166 | }
3167 |
3168 | export interface Rotation extends Array {
3169 | (location: number[]): Rotation;
3170 | invert(location: number[]): Rotation;
3171 | }
3172 |
3173 | export interface ProjectionMutator {
3174 | (lambda: number, phi: number): Projection;
3175 | }
3176 | }
3177 |
3178 | // Geometry
3179 | export module Geom {
3180 | export interface Geom {
3181 | voronoi(): Voronoi;
3182 | /**
3183 | * compute the Voronoi diagram for the specified points.
3184 | */
3185 | voronoi(vertices: Vertice[]): Polygon[];
3186 | /**
3187 | * compute the Delaunay triangulation for the specified points.
3188 | */
3189 | delaunay(vertices?: Vertice[]): Polygon[];
3190 | /**
3191 | * constructs a quadtree for an array of points.
3192 | */
3193 | quadtree(): QuadtreeFactory;
3194 | /**
3195 | * Constructs a new quadtree for the specified array of points.
3196 | */
3197 | quadtree(points: Point[], x1: number, y1: number, x2: number, y2: number): Quadtree;
3198 | /**
3199 | * Constructs a new quadtree for the specified array of points.
3200 | */
3201 | quadtree(points: Point[], width: number, height: number): Quadtree;
3202 | /**
3203 | * Returns the input array of vertices with additional methods attached
3204 | */
3205 | polygon(vertices:Vertice[]): Polygon;
3206 | /**
3207 | * creates a new hull layout with the default settings.
3208 | */
3209 | hull(): Hull;
3210 |
3211 | hull(vertices:Vertice[]): Vertice[];
3212 | }
3213 |
3214 | export interface Vertice extends Array {
3215 | /**
3216 | * Returns the angle of the vertice
3217 | */
3218 | angle?: number;
3219 | }
3220 |
3221 | export interface Polygon extends Array {
3222 | /**
3223 | * Returns the signed area of this polygon
3224 | */
3225 | area(): number;
3226 | /**
3227 | * Returns a two-element array representing the centroid of this polygon.
3228 | */
3229 | centroid(): number[];
3230 | /**
3231 | * Clips the subject polygon against this polygon
3232 | */
3233 | clip(subject: Polygon): Polygon;
3234 | }
3235 |
3236 | export interface QuadtreeFactory {
3237 | /**
3238 | * Constructs a new quadtree for the specified array of points.
3239 | */
3240 | (): Quadtree;
3241 | /**
3242 | * Constructs a new quadtree for the specified array of points.
3243 | */
3244 | (points: Point[], x1: number, y1: number, x2: number, y2: number): Quadtree;
3245 | /**
3246 | * Constructs a new quadtree for the specified array of points.
3247 | */
3248 | (points: Point[], width: number, height: number): Quadtree;
3249 |
3250 | x: {
3251 | (): (d: any) => any;
3252 | (accesor: (d: any) => any): QuadtreeFactory;
3253 |
3254 | }
3255 | y: {
3256 | (): (d: any) => any;
3257 | (accesor: (d: any) => any): QuadtreeFactory;
3258 |
3259 | }
3260 | size(): number[];
3261 | size(size: number[]): QuadtreeFactory;
3262 | extent(): number[][];
3263 | extent(points: number[][]): QuadtreeFactory;
3264 | }
3265 |
3266 | export interface Quadtree {
3267 | /**
3268 | * Adds a new point to the quadtree.
3269 | */
3270 | add(point: Point): void;
3271 | visit(callback: any): void;
3272 | }
3273 |
3274 | export interface Point {
3275 | x: number;
3276 | y: number;
3277 | }
3278 |
3279 | export interface Voronoi {
3280 | /**
3281 | * Compute the Voronoi diagram for the specified data.
3282 | */
3283 | (data: T[]): Polygon[];
3284 | /**
3285 | * Compute the graph links for the Voronoi diagram for the specified data.
3286 | */
3287 | links(data: T[]): Layout.GraphLink[];
3288 | /**
3289 | * Compute the triangles for the Voronoi diagram for the specified data.
3290 | */
3291 | triangles(data: T[]): number[][];
3292 | x: {
3293 | /**
3294 | * Get the x-coordinate accessor.
3295 | */
3296 | (): (data: T, index ?: number) => number;
3297 |
3298 | /**
3299 | * Set the x-coordinate accessor.
3300 | *
3301 | * @param accessor The new accessor function
3302 | */
3303 | (accessor: (data: T, index: number) => number): Voronoi;
3304 |
3305 | /**
3306 | * Set the x-coordinate to a constant.
3307 | *
3308 | * @param constant The new constant value.
3309 | */
3310 | (constant: number): Voronoi;
3311 | }
3312 | y: {
3313 | /**
3314 | * Get the y-coordinate accessor.
3315 | */
3316 | (): (data: T, index ?: number) => number;
3317 |
3318 | /**
3319 | * Set the y-coordinate accessor.
3320 | *
3321 | * @param accessor The new accessor function
3322 | */
3323 | (accessor: (data: T, index: number) => number): Voronoi;
3324 |
3325 | /**
3326 | * Set the y-coordinate to a constant.
3327 | *
3328 | * @param constant The new constant value.
3329 | */
3330 | (constant: number): Voronoi;
3331 | }
3332 | clipExtent: {
3333 | /**
3334 | * Get the clip extent.
3335 | */
3336 | (): number[][];
3337 | /**
3338 | * Set the clip extent.
3339 | *
3340 | * @param extent The new clip extent.
3341 | */
3342 | (extent: number[][]): Voronoi;
3343 | }
3344 | size: {
3345 | /**
3346 | * Get the size.
3347 | */
3348 | (): number[];
3349 | /**
3350 | * Set the size, equivalent to a clip extent starting from (0,0).
3351 | *
3352 | * @param size The new size.
3353 | */
3354 | (size: number[]): Voronoi;
3355 | }
3356 | }
3357 |
3358 | export interface Hull {
3359 | (vertices: Vertice[]): Vertice[];
3360 | x: {
3361 | (): (d: any) => any;
3362 | (accesor: (d: any) => any): any;
3363 | }
3364 | y: {
3365 | (): (d: any) => any;
3366 | (accesor: (d: any) => any): any;
3367 | }
3368 | }
3369 | }
3370 | }
3371 |
3372 | declare var d3: D3.Base;
3373 |
3374 | declare module "d3" {
3375 | export = d3;
3376 | }
3377 |
--------------------------------------------------------------------------------