Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3fc plugin #420

Merged
merged 256 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
256 commits
Select commit Hold shift + click to select a range
a83b4ed
circle keys in legend AKA jacob
jburton-scottlogic Jan 11, 2019
96ad8f4
Legend (jacob) hide bars
jburton-scottlogic Jan 11, 2019
f408729
styling corrections
redbearsam Jan 15, 2019
bfe0242
d3fcChart.js structural refactor
redbearsam Jan 16, 2019
757330e
replace Math.max with d3.max and correct dsfc version
Jan 16, 2019
684cb75
data interpretation all occurs in a single location.
redbearsam Jan 16, 2019
015fc25
Add field name(s) to x/y axis
Jan 17, 2019
0c1d56c
Bar positions are now adjusted when visibility is toggled with the key
Ro4052 Jan 17, 2019
897fdbe
Toggled bars now persist after data updates
Ro4052 Jan 17, 2019
a0c291c
Fixed array equality function
Ro4052 Jan 18, 2019
a4627a0
Implemented re-size method for d3fc bar charts
Ro4052 Jan 18, 2019
213ae62
Created new toggleElements function for greater clarity
Ro4052 Jan 18, 2019
d3917b2
made styling axis agnostic.
redbearsam Jan 17, 2019
0b5c516
corrected isSplitBy assessment logic.
redbearsam Jan 17, 2019
708fc4a
removed extraneous logging
redbearsam Jan 17, 2019
f7cf1ac
styling corrections
redbearsam Jan 17, 2019
8357b3b
hide index labeling bars on axis when there is no actual data label
redbearsam Jan 17, 2019
487935b
set padding correctly to make bars equidistant.
redbearsam Jan 18, 2019
d75525a
Fixed formatting errors for d3fc plugin files
Ro4052 Jan 21, 2019
dad36db
delete canvas element that obstructs element-inspection-selection
redbearsam Jan 21, 2019
51c964c
[IPJS-10] - fix legend circle issue
Jan 22, 2019
4078f53
Removed gap between chart and x-axis
Ro4052 Jan 24, 2019
f655304
Added basic support for light and dark themes
Ro4052 Jan 24, 2019
2182425
Fixed cropping issue for axis extents
Ro4052 Jan 24, 2019
46444f6
removed unused references, method, and test data file
redbearsam Jan 22, 2019
deea280
read multiple groups/categories.
redbearsam Jan 24, 2019
bb6fbb2
convert labels to arrays instead of a comma separated string
redbearsam Jan 24, 2019
57992a9
rename groups to groupBys for clarity
redbearsam Jan 25, 2019
e35f05c
refactor discrete functionality into discrete js files
redbearsam Jan 25, 2019
344e53b
styling made compatible with firefox also
redbearsam Jan 25, 2019
3e5a38f
IPJS-2 add non breaking space to main label to stop it wrapping
Jan 29, 2019
caec966
Added D3FC example page
Jan 29, 2019
ac38fd2
Groups can now have a value of "group"
Ro4052 Jan 30, 2019
3cb4ec7
Use labels variable for cross labels instead of config
Ro4052 Jan 30, 2019
7da1742
Add interpretKeysAndColor
Jan 28, 2019
0d0c7a8
Add Multi-Column support
Jan 28, 2019
80d6047
Use series.stack to check for multiple columns/stacks
Jan 28, 2019
81a6a81
make dataset more consistent. Add logging
Jan 28, 2019
eeae9de
Update packages/perspective-viewer-d3fc/src/js/chartConfig.js
Ro4052 Jan 30, 2019
634bd9c
Update packages/perspective-viewer-d3fc/src/js/dataInterpretation.js
Ro4052 Jan 30, 2019
fc21380
Add interpretKeysAndColor
Jan 28, 2019
ee93f22
Add Multi-Column support
Jan 28, 2019
a4f9da9
Use series.stack to check for multiple columns/stacks
Jan 28, 2019
17278a1
make dataset more consistent. Add logging
Jan 28, 2019
3c04508
Add interpretKeysAndColor
Jan 28, 2019
2cf9d17
Add Multi-Column support
Jan 28, 2019
31bb225
Use series.stack to check for multiple columns/stacks
Jan 28, 2019
958c12e
make dataset more consistent. Add logging
Jan 28, 2019
1be361e
Update packages/perspective-viewer-d3fc/src/js/chartConfig.js
Ro4052 Jan 30, 2019
c5d7ba8
Update packages/perspective-viewer-d3fc/src/js/dataInterpretation.js
Ro4052 Jan 30, 2019
3645ca4
Fixed overwritten changes from previous merge
Ro4052 Jan 30, 2019
b31b60d
Added placeholder test html so tests run
Jan 29, 2019
836db63
Fix toggle issue for multi column charts
Jan 31, 2019
e2ec353
post rebase cleanup
redbearsam Feb 6, 2019
3d3be52
Added basic tooltip rectangle on hover
Ro4052 Jan 22, 2019
6ace440
Styling changes for tooltip div
Ro4052 Jan 23, 2019
f211ce5
Tooltip now supports both light and dark themes
Ro4052 Jan 23, 2019
22b73ff
Linted d3fc less file
Ro4052 Jan 23, 2019
16128b6
Fixed bug for graphs without splitBy
Ro4052 Jan 25, 2019
6748382
Tooltip shows group bys for charts without split bys
Ro4052 Jan 28, 2019
ca90ffd
Tooltip groups now work for split by charts
Ro4052 Jan 28, 2019
c9a7abf
Tooltip now also shows split bys
Ro4052 Jan 28, 2019
cc305dd
Fixed axis gap removal for Edge
Ro4052 Jan 29, 2019
101116f
Fixed split bys for grouped data
Ro4052 Jan 30, 2019
209cfd7
Fixed groups tooltip for new data structure
Ro4052 Jan 30, 2019
54e729d
Moved containerRect instantiation to fix div position on toggle config
Ro4052 Jan 30, 2019
fe03007
Fixed tooltip positioning to work for Edge
Ro4052 Jan 30, 2019
9c40c5b
Fixed data interpretation for split by charts with no groups
Ro4052 Jan 31, 2019
6b97df1
Changed "config" references to "labels" references
Ro4052 Jan 31, 2019
ba6c18f
Tooltip now shows bar value for single series data
Ro4052 Jan 31, 2019
cdc089b
Prevent tooltip page overflow
Ro4052 Feb 1, 2019
6edc322
Fixed value display for charts without splits
Ro4052 Feb 5, 2019
a32db62
multi level subdivision of y-bar-graph labels functioning.
redbearsam Jan 31, 2019
669e455
refactored styling into seperate folder and divided into two js files.
redbearsam Feb 1, 2019
4990a35
encapsulate styling modifications in functions to make code self docu…
redbearsam Feb 1, 2019
1d945ff
functional for x_bar graph also.
redbearsam Feb 1, 2019
f870fd4
ticks as part of axes svg lines set correctly (removed or correct len…
redbearsam Feb 1, 2019
55299cb
post rebase cleanup
redbearsam Feb 5, 2019
8d6f31d
made group by labeling compatible with splitBy.
redbearsam Feb 5, 2019
7e689c2
remove superfluous console logs
redbearsam Feb 5, 2019
c53e061
re-added constant for the non line breaking space
redbearsam Feb 6, 2019
c2de1d6
linting issues fixed - specifically, unused variables
redbearsam Feb 6, 2019
a4d5cd9
Added basic d3 x bar chart and d3fc y bar chart
redbearsam Jan 22, 2019
6c7e545
Y barchart implementation
jburton-scottlogic Jan 9, 2019
b2d31f9
legend added
redbearsam Jan 22, 2019
f988aad
added stacked bars
jburton-scottlogic Jan 10, 2019
2a7e4c9
x bar chart stacked mode working also.
redbearsam Jan 10, 2019
2f35284
refactored render bar chart methods to share code instead of a method…
redbearsam Jan 10, 2019
5dae694
circle keys in legend AKA jacob
jburton-scottlogic Jan 11, 2019
b242ed2
Legend (jacob) hide bars
jburton-scottlogic Jan 11, 2019
72bde62
styling corrections
redbearsam Jan 15, 2019
b08bcd8
d3fcChart.js structural refactor
redbearsam Jan 16, 2019
652774b
replace Math.max with d3.max and correct dsfc version
Jan 16, 2019
a086da7
data interpretation all occurs in a single location.
redbearsam Jan 16, 2019
6132f1f
Add field name(s) to x/y axis
Jan 17, 2019
31392ef
Bar positions are now adjusted when visibility is toggled with the key
Ro4052 Jan 17, 2019
006f75c
Toggled bars now persist after data updates
Ro4052 Jan 17, 2019
1e7f533
Fixed array equality function
Ro4052 Jan 18, 2019
da246fd
Implemented re-size method for d3fc bar charts
Ro4052 Jan 18, 2019
967dae9
Created new toggleElements function for greater clarity
Ro4052 Jan 18, 2019
a1915df
made styling axis agnostic.
redbearsam Jan 17, 2019
daeb2d8
corrected isSplitBy assessment logic.
redbearsam Jan 17, 2019
f2c802c
removed extraneous logging
redbearsam Jan 17, 2019
529ac13
styling corrections
redbearsam Jan 17, 2019
517a4fc
hide index labeling bars on axis when there is no actual data label
redbearsam Jan 17, 2019
c94bfc0
set padding correctly to make bars equidistant.
redbearsam Jan 18, 2019
830992a
Fixed formatting errors for d3fc plugin files
Ro4052 Jan 21, 2019
edf0d91
delete canvas element that obstructs element-inspection-selection
redbearsam Jan 21, 2019
3f6dc17
[IPJS-10] - fix legend circle issue
Jan 22, 2019
893effd
Removed gap between chart and x-axis
Ro4052 Jan 24, 2019
2d88b46
Added basic support for light and dark themes
Ro4052 Jan 24, 2019
8fccf0b
Fixed cropping issue for axis extents
Ro4052 Jan 24, 2019
4f570c5
removed unused references, method, and test data file
redbearsam Jan 22, 2019
cdec9ac
read multiple groups/categories.
redbearsam Jan 24, 2019
d168ed5
convert labels to arrays instead of a comma separated string
redbearsam Jan 24, 2019
b639ea1
rename groups to groupBys for clarity
redbearsam Jan 25, 2019
da21951
refactor discrete functionality into discrete js files
redbearsam Jan 25, 2019
918c925
styling made compatible with firefox also
redbearsam Jan 25, 2019
3ac074c
IPJS-2 add non breaking space to main label to stop it wrapping
Jan 29, 2019
c99283f
Added D3FC example page
Jan 29, 2019
f31f919
Groups can now have a value of "group"
Ro4052 Jan 30, 2019
2a709a9
Use labels variable for cross labels instead of config
Ro4052 Jan 30, 2019
bfafc8e
Add interpretKeysAndColor
Jan 28, 2019
819e3d1
Add Multi-Column support
Jan 28, 2019
f853f00
Use series.stack to check for multiple columns/stacks
Jan 28, 2019
41d3df8
make dataset more consistent. Add logging
Jan 28, 2019
52dc4ce
Update packages/perspective-viewer-d3fc/src/js/chartConfig.js
Ro4052 Jan 30, 2019
78e9528
Update packages/perspective-viewer-d3fc/src/js/dataInterpretation.js
Ro4052 Jan 30, 2019
9ba48c3
Add interpretKeysAndColor
Jan 28, 2019
7d49923
Add Multi-Column support
Jan 28, 2019
ee0a80e
Use series.stack to check for multiple columns/stacks
Jan 28, 2019
1e4456c
make dataset more consistent. Add logging
Jan 28, 2019
83ad241
Add interpretKeysAndColor
Jan 28, 2019
e00403f
Add Multi-Column support
Jan 28, 2019
031e243
Use series.stack to check for multiple columns/stacks
Jan 28, 2019
14b70af
make dataset more consistent. Add logging
Jan 28, 2019
74da71c
Update packages/perspective-viewer-d3fc/src/js/chartConfig.js
Ro4052 Jan 30, 2019
6d655bf
Update packages/perspective-viewer-d3fc/src/js/dataInterpretation.js
Ro4052 Jan 30, 2019
8eb0b43
Fixed overwritten changes from previous merge
Ro4052 Jan 30, 2019
cdecb4e
Added placeholder test html so tests run
Jan 29, 2019
a0ce12e
Fix toggle issue for multi column charts
Jan 31, 2019
db59f72
post rebase cleanup
redbearsam Feb 6, 2019
3b364b5
Added basic tooltip rectangle on hover
Ro4052 Jan 22, 2019
7bfefe7
Styling changes for tooltip div
Ro4052 Jan 23, 2019
51a41fb
Tooltip now supports both light and dark themes
Ro4052 Jan 23, 2019
a1abce6
Linted d3fc less file
Ro4052 Jan 23, 2019
ca92059
Fixed bug for graphs without splitBy
Ro4052 Jan 25, 2019
926321a
Tooltip shows group bys for charts without split bys
Ro4052 Jan 28, 2019
83e2ddd
Tooltip groups now work for split by charts
Ro4052 Jan 28, 2019
39ebfa2
Tooltip now also shows split bys
Ro4052 Jan 28, 2019
43cf655
Fixed axis gap removal for Edge
Ro4052 Jan 29, 2019
94677cb
Fixed split bys for grouped data
Ro4052 Jan 30, 2019
0c91a09
Fixed groups tooltip for new data structure
Ro4052 Jan 30, 2019
c083333
Moved containerRect instantiation to fix div position on toggle config
Ro4052 Jan 30, 2019
1498605
Fixed tooltip positioning to work for Edge
Ro4052 Jan 30, 2019
5df7a46
Fixed data interpretation for split by charts with no groups
Ro4052 Jan 31, 2019
6293866
Changed "config" references to "labels" references
Ro4052 Jan 31, 2019
b927fd3
Tooltip now shows bar value for single series data
Ro4052 Jan 31, 2019
7271eed
Prevent tooltip page overflow
Ro4052 Feb 1, 2019
29ae578
Fixed value display for charts without splits
Ro4052 Feb 5, 2019
a23dd18
multi level subdivision of y-bar-graph labels functioning.
redbearsam Jan 31, 2019
bad4d63
refactored styling into seperate folder and divided into two js files.
redbearsam Feb 1, 2019
800d77d
encapsulate styling modifications in functions to make code self docu…
redbearsam Feb 1, 2019
4303bd4
functional for x_bar graph also.
redbearsam Feb 1, 2019
c5d6b16
ticks as part of axes svg lines set correctly (removed or correct len…
redbearsam Feb 1, 2019
95858ee
post rebase cleanup
redbearsam Feb 5, 2019
2125b61
made group by labeling compatible with splitBy.
redbearsam Feb 5, 2019
f920715
remove superfluous console logs
redbearsam Feb 5, 2019
210eb8d
re-added constant for the non line breaking space
redbearsam Feb 6, 2019
3cbe217
linting issues fixed - specifically, unused variables
redbearsam Feb 6, 2019
1124277
Initial restructure into modules
Feb 5, 2019
e2f3feb
Bar colouring
Feb 5, 2019
88abc78
Fixed data filter
Feb 5, 2019
f821b1b
Simplified data load
Feb 5, 2019
5e78a6d
Added simple legend
Feb 5, 2019
e6b4e66
Redraw fix
Feb 5, 2019
7f18845
Data fixes
Feb 5, 2019
c43ec40
Improved split-data function
Feb 6, 2019
3a1aeae
Simplify barColours
Feb 7, 2019
44b3195
Fix splitting data when there are negatve values
Feb 7, 2019
d539c60
Clicking legend items filters data view
Feb 7, 2019
0ab3a31
Linted restructured code
Ro4052 Feb 7, 2019
1ef0641
Fixed css visibility and sizing around axis and labels
Feb 8, 2019
2b5d7db
Fixed a couple of Edge issues
Feb 8, 2019
a572a8f
Remove hidden data before render
Feb 7, 2019
46ba771
Fixed mistake
Feb 7, 2019
e630858
Merge pull request #28 from redbearsam/feature/fix-labels-css
matt-hooper Feb 8, 2019
295b1c2
Updated to [email protected]
Feb 8, 2019
e8de23b
Prettify less
Feb 8, 2019
6c496c8
Updated D3FC style fix with alternative workaround
Feb 8, 2019
828bd49
Include other D3FC style blocks too
Feb 8, 2019
30f01ad
Include d3fc styles in template
Feb 8, 2019
a8323c8
Add date/time and linear cross-axis scales
Feb 8, 2019
2af6aa3
Better domain data access
Feb 8, 2019
3959eac
Use "sequential" domain when no cross-axis
Feb 11, 2019
9f04ee8
Fixed some cross-axis issues
Feb 11, 2019
0303687
Merge pull request #30 from redbearsam/feature/other-cross-scales
matt-hooper Feb 11, 2019
efc3af4
Fix data filter for multiple GroupBy
Feb 11, 2019
4194561
Minimum 1-pixel bandwidth
Feb 11, 2019
b5cee45
Merge pull request #31 from redbearsam/feature/fix-data-filter
matt-hooper Feb 12, 2019
8b64de9
Fixed issue for data with splits and no groups
Ro4052 Feb 12, 2019
8d98438
Merge pull request #32 from redbearsam/feature/min-bandwidth
matt-hooper Feb 12, 2019
8611a98
Added line chart
Feb 12, 2019
9a9c5b8
Add gridlines
Feb 12, 2019
5592c38
Elements remain hidden when the perspective table is updated
Ro4052 Feb 8, 2019
17cda48
Removed underscore dependency
Ro4052 Feb 12, 2019
02940bd
DOM only removed if settings have changed
Ro4052 Feb 12, 2019
b52236a
refactor to make withGridlines more d3fc style
Feb 12, 2019
439cad2
Moved the getChartElement helper into a new module
Feb 12, 2019
9a76f08
Removed old code (and references to it) from before restructure
Ro4052 Feb 12, 2019
bf6773a
Fix legend/hide bug
Feb 12, 2019
c457917
Merge pull request #35 from redbearsam/feature/line-chart
matt-hooper Feb 12, 2019
1e9ffb7
Merge pull request #38 from redbearsam/feature/move-root-helper
matt-hooper Feb 12, 2019
9682db4
Merge pull request #39 from redbearsam/cleanup
matt-hooper Feb 12, 2019
df96ccf
rename '[d3fc] Y Line Chart 2' to '[d3fc] Y Line Chart'
Feb 12, 2019
54941c6
Merge pull request #40 from redbearsam/rename_y_line
matt-hooper Feb 12, 2019
dff2c81
Merge pull request #36 from redbearsam/add_gridlines
matt-hooper Feb 13, 2019
78d120d
Added function to generate html for tooltip
Ro4052 Feb 12, 2019
99dd016
Re-added tooltip functionality
Ro4052 Feb 12, 2019
52ad1dc
Use template getContainer instead of passing down
Ro4052 Feb 12, 2019
9926877
Updated getChartElement import location
Ro4052 Feb 13, 2019
da12fec
Switched from html string to template
Ro4052 Feb 13, 2019
bc57609
Made tooltip values bold to match HighCharts
Ro4052 Feb 13, 2019
3b1c392
Replaced span tag with b tag
Ro4052 Feb 13, 2019
2b86c96
Switched to .each function to reduce loops over data
Ro4052 Feb 13, 2019
bdee255
Moved .each implementation into new function
Ro4052 Feb 13, 2019
0e21a5e
Implemented X-Y chart
Feb 13, 2019
8f75a6b
Use "x" and "y" properties for data position
Feb 13, 2019
bef5740
Added Tooltip for Points
Feb 13, 2019
e070d93
Fixed issue with toggling legend with multiple values and splitBy
Feb 14, 2019
03bee04
Added legend scrolling functionality
Ro4052 Feb 13, 2019
47f8a53
Refactored legend scrolling code into new function
Ro4052 Feb 13, 2019
5f1fb4f
Added styling to legend scrolling
Ro4052 Feb 14, 2019
47df712
Refactored legendScrolling function
Ro4052 Feb 14, 2019
158b604
Fixed legend toggling with legend scrolling
Ro4052 Feb 14, 2019
b5e9468
Retrieve domain from colour function rather than passing down
Ro4052 Feb 14, 2019
6348cf7
Added getOrCreateElement function
Ro4052 Feb 14, 2019
d73ad04
Refactored getOrCreateElement function
Ro4052 Feb 14, 2019
86fad80
Moved scrollable-legend into a standalone component
Feb 14, 2019
af8aab0
Legend container retrieved via utils function
Ro4052 Feb 14, 2019
137fe50
Merge branch 'develop' into feature/xy-charts
Feb 14, 2019
f9e5450
Merge pull request #41 from redbearsam/feature/xy-charts
Feb 14, 2019
2ecbbfd
Fixed merge error
Feb 14, 2019
a5c3b89
Added grid lines to x/y and line charts
Feb 14, 2019
f9be12b
Fixed legend label not showing main value for multiple main values
Ro4052 Feb 15, 2019
4b4358b
Some styling and tooltip hover changes
Feb 18, 2019
fbbb2e6
Merge pull request #51 from redbearsam/feature/axis-tip-styles
matt-hooper Feb 19, 2019
696ef14
Merge remote-tracking branch 'remotes/origin/develop' into d3fc_plugin
redbearsam Feb 19, 2019
1070b79
remove files un-needed post merge
redbearsam Feb 19, 2019
0474191
Merge branch 'master' into d3fc_plugin
redbearsam Feb 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/simple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<a href="streaming.html">High-frequency streaming random data example</a>
<a href="citibike.html">NYC Citibike inventory example</a>
<a href="csv.html">User-provided CSV example</a>
<a href="superstore-d3fc.html">Superstore example using D3FC Bar/Column charts</a>
</div>

</body>
Expand Down
50 changes: 50 additions & 0 deletions examples/simple/superstore-d3fc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--

Copyright (c) 2017, the Perspective Authors.

This file is part of the Perspective library, distributed under the terms of
the Apache License 2.0. The full license can be found in the LICENSE file.

-->

<!DOCTYPE html>
<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">

<script src="perspective.view.js"></script>
<script src="hypergrid.plugin.js"></script>
<script src="d3fc.plugin.js"></script>

<script src="perspective.js"></script>

<link rel='stylesheet' href="index.css">
<link rel='stylesheet' href="material.css" is="custom-style">

</head>

<body>

<perspective-viewer view="d3_y_bar" row-pivots='["Sub-Category"]' sort='[["Profit", "desc"]]' columns='["Profit"]'>

</perspective-viewer>

<script>
window.addEventListener('WebComponentsReady', function() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'superstore.arrow', true);
xhr.responseType = "arraybuffer"
xhr.onload = function() {
var el = document.getElementsByTagName('perspective-viewer')[0];
el.load(xhr.response);
el.toggleConfig();
}
xhr.send(null);
});
</script>

</body>

</html>
22 changes: 22 additions & 0 deletions packages/perspective-viewer-d3fc/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage"
}
]
],
"sourceType": "unambiguous",
"plugins": [
["@babel/plugin-proposal-decorators", {"legacy": true}],
"transform-custom-element-classes",
"@babel/plugin-transform-runtime",
[
"@babel/plugin-transform-for-of",
{
"loose": true
}
]
]
};
51 changes: 51 additions & 0 deletions packages/perspective-viewer-d3fc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@jpmorganchase/perspective-viewer-d3fc",
"version": "0.2.10",
"description": "Perspective.js",
"main": "src/js/plugin/plugin.js",
"files": [
"build/**/*",
"src/**/*",
"babel.config.js"
],
"scripts": {
"bench": "npm-run-all bench:build bench:run",
"bench:build": "echo \"No Benchmarks\"",
"bench:run": "echo \"No Benchmarks\"",
"build": "webpack --color --config src/config/d3fc.plugin.config.js",
"test:build": "cp test/html/* build",
"watch": "webpack --color --watch --config src/config/d3fc.plugin.config.js",
"test:run": "jest --silent --color 2>&1",
"test": "npm-run-all test:build test:run",
"clean": "find build -mindepth 1 -delete",
"clean:screenshots": "find screenshots/ \\( -name *.diff.png -o -name *.failed.png \\) -mindepth 1 -delete"
},
"jest": {
"roots": [
"test/js"
],
"verbose": true,
"testURL": "http://localhost/",
"transform": {},
"automock": false
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/jpmorganchase/perspective"
},
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@jpmorganchase/perspective": "^0.2.10",
"@jpmorganchase/perspective-viewer": "^0.2.10",
"babel-runtime": "^6.26.0",
"chroma-js": "^1.3.4",
"d3": "^5.7.0",
"d3-svg-legend": "^2.25.6",
"d3fc": "^14.0.25",
"gradient-parser": "0.1.5"
}
}
12 changes: 12 additions & 0 deletions packages/perspective-viewer-d3fc/src/config/d3fc.plugin.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const path = require("path");
const common = require("@jpmorganchase/perspective/src/config/common.config.js");

module.exports = Object.assign({}, common(), {
entry: "./src/js/plugin/plugin.js",
output: {
filename: "d3fc.plugin.js",
library: "perspective-view-d3fc",
libraryTarget: "umd",
path: path.resolve(__dirname, "../../build")
}
});
4 changes: 4 additions & 0 deletions packages/perspective-viewer-d3fc/src/html/d3fc-chart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template id="perspective-d3fc-chart">
<div id="container" class="chart">
</div>
</template>
5 changes: 5 additions & 0 deletions packages/perspective-viewer-d3fc/src/html/d3fc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template id="perspective-d3fc">
<div id="container">

</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<span id="up-arrow">&#9650;</span>
<span id="page-text"></span>
<span id="down-arrow">&#9660;</span>
3 changes: 3 additions & 0 deletions packages/perspective-viewer-d3fc/src/html/tooltip.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ul id="cross-values"></ul>
<ul id="split-values"></ul>
<ul id="data-values"></ul>
74 changes: 74 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/axis/crossAxis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import * as d3 from "d3";
import * as fc from "d3fc";
import minBandwidth from "./minBandwidth";
import withoutTicks from "./withoutTicks";

const AXIS_TYPES = {
none: "none",
ordinal: "ordinal",
time: "time",
linear: "linear"
};

export const scale = settings => {
switch (axisType(settings)) {
case AXIS_TYPES.none:
return withoutTicks(defaultScaleBand());
case AXIS_TYPES.time:
return d3.scaleTime();
case AXIS_TYPES.linear:
return d3.scaleLinear();
default:
return defaultScaleBand();
}
};

const defaultScaleBand = () => minBandwidth(d3.scaleBand());

export const domain = settings => {
const accessData = extent => {
return extent.accessors([labelFunction(settings)])(settings.data);
};
switch (axisType(settings)) {
case AXIS_TYPES.time:
return accessData(fc.extentTime());
case AXIS_TYPES.linear:
return accessData(fc.extentLinear());
default:
return settings.data.map(labelFunction(settings));
}
};

export const labelFunction = settings => {
switch (axisType(settings)) {
case AXIS_TYPES.none:
return d => d.__ROW_PATH__[0];
case AXIS_TYPES.time:
return d => new Date(d.__ROW_PATH__[0]);
case AXIS_TYPES.linear:
return d => d.__ROW_PATH__[0];
default:
return d => d.__ROW_PATH__.join(",");
}
};

export const label = settings => settings.crossValues.map(v => v.name).join(", ");

const axisType = settings => {
if (settings.crossValues.length === 0) {
return AXIS_TYPES.none;
} else if (settings.crossValues.length === 1) {
if (settings.crossValues[0].type === "datetime") {
return AXIS_TYPES.time;
}
}
return AXIS_TYPES.ordinal;
};
40 changes: 40 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/axis/mainAxis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import * as d3 from "d3";

export const scale = () => d3.scaleLinear();

export const domain = (settings, data, valueName = "mainValue") => {
const extent = getDataExtentFromArray(data, valueName);
return [extent[0] > 0 ? 0 : extent[0] * 1.1, extent[1] < 0 ? 0 : extent[1] * 1.1];
};

const getDataExtentFromArray = (array, valueName) => {
const dataExtent = array.map(v => getDataExtentFromValue(v, valueName));
const extent = flattenExtent(dataExtent);
return extent;
};

const getDataExtentFromValue = (value, valueName) => {
if (Array.isArray(value)) {
return getDataExtentFromArray(value, valueName);
}
return [value[valueName], value[valueName]];
};

export const label = settings => settings.mainValues.map(v => v.name).join(", ");

function flattenExtent(array) {
const withUndefined = fn => (a, b) => {
if (a === undefined) return b;
if (b === undefined) return a;
return fn(a, b);
};
return array.reduce((r, v) => [withUndefined(Math.min)(r[0], v[0]), withUndefined(Math.max)(r[1], v[1])], [undefined, undefined]);
}
29 changes: 29 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/axis/minBandwidth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import {rebindAll} from "d3fc";

const MIN_BANDWIDTH = 1;

export default adaptee => {
const minBandwidth = arg => {
return adaptee(arg);
};

rebindAll(minBandwidth, adaptee);

minBandwidth.bandwidth = (...args) => {
if (!args.length) {
return Math.max(adaptee.bandwidth(), MIN_BANDWIDTH);
}
adaptee.bandwidth(...args);
return minBandwidth;
};

return minBandwidth;
};
23 changes: 23 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/axis/withoutTicks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import {rebindAll} from "d3fc";

export default adaptee => {
const withoutTicks = arg => {
return adaptee(arg);
};

rebindAll(withoutTicks, adaptee);

withoutTicks.ticks = function() {
return [];
};

return withoutTicks;
};
54 changes: 54 additions & 0 deletions packages/perspective-viewer-d3fc/src/js/charts/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import * as fc from "d3fc";
import * as crossAxis from "../axis/crossAxis";
import * as mainAxis from "../axis/mainAxis";
import {barSeries} from "../series/barSeries";
import {seriesColours} from "../series/seriesColours";
import {groupAndStackData} from "../data/groupAndStackData";
import {legend, filterData} from "../legend/legend";
import {withGridLines} from "../gridlines/gridlines";

function barChart(container, settings) {
const data = groupAndStackData(settings, filterData(settings));
const colour = seriesColours(settings);
legend(container, settings, colour);

const series = fc
.seriesSvgMulti()
.mapping((data, index) => data[index])
.series(
data.map(() =>
barSeries(settings, colour)
.align("left")
.orient("horizontal")
)
);

const chart = fc
.chartSvgCartesian(mainAxis.scale(settings), crossAxis.scale(settings))
.xDomain(mainAxis.domain(settings, data))
.xLabel(mainAxis.label(settings))
.yDomain(crossAxis.domain(settings, data))
.yOrient("left")
.yLabel(crossAxis.label(settings))
.plotArea(withGridLines(series).orient("horizontal"));

chart.yPadding && chart.yPadding(0.5);

// render
container.datum(data).call(chart);
}
barChart.plugin = {
type: "d3_x_bar",
name: "[d3fc] X Bar Chart",
max_size: 25000
};

export default barChart;
Loading