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 #498

Merged
merged 172 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
c28a0da
legend resizes dynamically to content, and crops text beyond max limit
redbearsam Mar 14, 2019
fcbcc85
legend draggable, and has borderbox animation on hover
redbearsam Mar 14, 2019
b36a8ac
legend has tooltip on hover to expand text (useful when text is cropeed)
redbearsam Mar 14, 2019
3e33926
draw the borderbox
redbearsam Mar 14, 2019
3b1f4f9
add postprocessing (for cropping) when scrolling through legend
redbearsam Mar 14, 2019
b89a400
legend width set absolute
redbearsam Mar 14, 2019
46045f0
use css to draw legend borderbox on hover
redbearsam Mar 14, 2019
ba5dd9a
remove unnecessary css
redbearsam Mar 14, 2019
4352864
use native d3 drag functionality, and ensure legend never goes off sc…
redbearsam Mar 18, 2019
1d81039
dry out repetitive code
redbearsam Mar 18, 2019
6726583
ensure legend remains onscreen on resize events
redbearsam Mar 18, 2019
10d8b5f
refactor cropCellContents for concision
redbearsam Mar 18, 2019
2becba0
Fixed bug in CSV parsing which caused number-like columns declared st…
texodus Mar 6, 2019
c3d9baa
Refactor get_data in emscripten.cpp
sc1f Feb 28, 2019
0da33b9
refactor get_data to return t_data_slice struct, remote get_data_two_…
sc1f Mar 1, 2019
d0903f4
Add t_data_slice class, begin to abstract data serialization process
sc1f Mar 3, 2019
2b5f1d8
Add column_only to context constructors for later use in data slice
sc1f Mar 3, 2019
639b620
Make get_column_extents an independent file away from context_common
sc1f Mar 4, 2019
8ae5c70
Fixed bubble charts
texodus Mar 7, 2019
8650ea2
Fixed line chart colours
texodus Mar 7, 2019
2e043b2
Enabled D3FC tests in Travis/default
texodus Mar 7, 2019
41e49a2
Added ‘not in’ filter to `perspective-viewer` defaults
texodus Mar 7, 2019
1e58291
Fixed calls to `update()` with empty list from throwing exception
texodus Mar 6, 2019
eed7269
Fixed “not in” filter to array conversion in viewer
texodus Mar 7, 2019
e128439
Fixed windows build error
texodus Mar 7, 2019
a1a1478
v0.2.20
texodus Mar 7, 2019
7ed8790
Expose date filter issue in a unit test
JHawk Mar 7, 2019
9df7e36
Fix date filtering and add another test on <
JHawk Mar 7, 2019
f64fb1f
Re-implemented multi-level axis using potential d3fc components
Mar 1, 2019
f835841
Fixed console error when resizing
Mar 1, 2019
d1fddae
Support different sizes for the different levels of the axis labels
Mar 1, 2019
d7dac1b
Implemented x-axis label rotation when required
Mar 1, 2019
8212a7c
correct css for line chart
redbearsam Mar 4, 2019
55f3bdf
XY chart size needs to use updated version of mainAxis domain functio…
Mar 4, 2019
a86e0da
XY chart displays shapes as well as colour
Mar 4, 2019
84ae797
Make legend more d3 component-like
Mar 4, 2019
8c4db27
console no longer logs (InSplitData(...)), and y axis line hidden usi…
redbearsam Mar 4, 2019
6bf0af5
Apply XY point colour based on mainValue (#73)
Mar 5, 2019
ffa614b
Set back to reference "cjs" dependency, with yarn focus (#74)
Mar 5, 2019
096463c
Make sure colour-scale points still have semi-transparent fill (#75)
Mar 5, 2019
c996451
Initial implementation of the interpolated legend
Ro4052 Mar 4, 2019
3a808e8
Updated padding to be more universal across data ranges
Ro4052 Mar 4, 2019
12d9603
Fixed element replication issues
Ro4052 Mar 5, 2019
0857b0b
Slight refactor to legend axis creation
Ro4052 Mar 5, 2019
e9810fd
Made legend cross-theme compatible
Ro4052 Mar 5, 2019
e90b2fb
Removed unnecessary svg creation
Ro4052 Mar 5, 2019
acfb1e8
Fixed legend padding issue
Ro4052 Mar 5, 2019
e90a786
Added right pad to chart for interpolated legend
Ro4052 Mar 5, 2019
d13a198
Refactored colour range legend function
Ro4052 Mar 5, 2019
90b500d
Removed legend axis domain line
Ro4052 Mar 5, 2019
50b747c
Fixed number formatting function
Ro4052 Mar 5, 2019
4220268
Fixed upper padding issue
Ro4052 Mar 5, 2019
3eeec51
Fixed copying mistake
Ro4052 Mar 5, 2019
85d95c5
Implemented basic mouse-wheel zooming on XY chart
Mar 5, 2019
157e967
Reset zoom button
Mar 5, 2019
3243901
Added limited zooming to other charts
Mar 5, 2019
fe5c142
Show zoom button if drag without zooming
Mar 6, 2019
f86c901
Watch command needs to use babel-enabled webpack config
Mar 6, 2019
877fdd9
Fix re-order bug when using splitBy on column/bar charts
Mar 6, 2019
49d070c
Implemented simple canvas xy scatter plot
Ro4052 Mar 6, 2019
edced86
Added default fill/stroke colour for canvas xy scatter
Ro4052 Mar 6, 2019
36536b9
Added legend to xy scatter canvas
Ro4052 Mar 6, 2019
5a2b1da
Added potential d3fc fix for seriesCanvasPoint size function
Ro4052 Mar 6, 2019
52e45bc
Updated to new d3fc with seriesCanvasPoint fix
Ro4052 Mar 7, 2019
0276a1f
Renamed variable for consistency
Ro4052 Mar 7, 2019
48822bb
Fixed zoomableChart for canvas
Mar 7, 2019
9f75d4f
Updated how canvas and svg charts are shown and hidden
Ro4052 Mar 7, 2019
af496a9
Fixed default canvas strokeStyle
Ro4052 Mar 7, 2019
05e790e
Fixed zoomableChart (for canvas and svg this time)
Mar 7, 2019
b1b16ef
Inverted y-axis domain for x-bar and heatmap to match highcharts (#79)
Mar 7, 2019
a34770b
added y scatter chart
redbearsam Mar 1, 2019
73db153
y_scatter makes use of d3 shapes for points
redbearsam Mar 6, 2019
45ce414
y_scatter chart made zoomable
redbearsam Mar 6, 2019
161df0b
order doesn't change when adding a splitby
redbearsam Mar 6, 2019
2faf6ac
move common symbols const and function into separate file (seriesSymb…
redbearsam Mar 6, 2019
1483182
refactored groupAndStackData and groupData files to dry out code
redbearsam Mar 6, 2019
befdd67
explicitly set opacity on y_scatter points' fill
redbearsam Mar 7, 2019
84bbe6d
tooltips redraw themselves if they calculate that they exceed the cha…
redbearsam Mar 7, 2019
b25cbd3
cleaner html node access & remove a parameter mutation
redbearsam Mar 7, 2019
df374ca
Added seriesCanvasMutli with alternative decorate implementation
Ro4052 Mar 7, 2019
2ec0109
Added basic canvas gridlines using potential d3fc component
Ro4052 Mar 7, 2019
c137fe9
Corrected gridlines decorate
Ro4052 Mar 7, 2019
434272a
Fixed yTick scaling
Ro4052 Mar 7, 2019
a3f14ee
Fixed import errors from watch command
Ro4052 Mar 7, 2019
7a06534
Update d3fc test snapshots
Mar 8, 2019
9547f6e
fixes #423
Mar 9, 2019
031aea9
Fix typo
freebroccolo Mar 11, 2019
32720e1
Use signed t_index, use shared_ptr only for the slice
sc1f Mar 7, 2019
49a7317
Working data slice for zero-sides
sc1f Mar 10, 2019
d9d6d71
Working data slice for one-side
sc1f Mar 12, 2019
56de4fb
Added __ROW_PATH__ to t_data_slice.m_column_names, removed clean_data…
texodus Mar 14, 2019
5548e9f
remove duplicate withOutOpacity method from seriesColours
Mar 8, 2019
f75ea27
Tooltips for line charts
Mar 8, 2019
2139877
Refactored tooltips into cartesian-chart component
Mar 11, 2019
eb5ed7f
Only apply XY colour for category colours
Mar 12, 2019
9739d07
Default highlight colour
Mar 12, 2019
2d78932
Updated d3fc and replaced local cartesianSvgChart
Mar 11, 2019
b117d38
Fixed problem with non-rotated labels
Mar 12, 2019
b3d317a
Fix non-category axis bug
Mar 12, 2019
9c418b3
Updated test results
Mar 12, 2019
e3ffdc6
Fixed merge error
Mar 12, 2019
b84a792
Removed old SVG X/Y chart and replace with the Canvas one (#88)
Mar 12, 2019
38cd726
Fixed some MS-Edge issues (#90)
Mar 12, 2019
746eef1
Add tooltips for Area charts
Mar 12, 2019
8d8cb4c
replace colour references with color
Mar 12, 2019
54117f8
Use extentLinear to pad domain
Ro4052 Mar 12, 2019
e3e495a
Improved and simplified nearby-tooltip code and used on y-scatter
Mar 12, 2019
4306406
Refactored tooltip html generation
Ro4052 Mar 13, 2019
992ad6a
Converted formatNumber to arrow function
Ro4052 Mar 13, 2019
b0607ca
Removed unused filter
Ro4052 Mar 13, 2019
8c915f6
Fixed tooltip for line charts
Ro4052 Mar 13, 2019
5306e85
Slight refactor to generateHtml
Ro4052 Mar 13, 2019
11928e7
Fixed tooltip for data values
Ro4052 Mar 13, 2019
51539f8
Fixed tooltip for xy with split
Ro4052 Mar 13, 2019
3b4506f
update scatter.html/displays visible columns screenshot
Mar 14, 2019
097a92e
1-sided contexts cannot be column_only
texodus Mar 14, 2019
3049941
Fixed 0-sided schema
texodus Mar 15, 2019
ace4c69
Fixed lint_cpp script
texodus Mar 15, 2019
ce14f08
Added window support to `to_arrow()`
texodus Mar 15, 2019
33148b2
always append title to legend cells
redbearsam Mar 18, 2019
0e95c9c
enable pinning and unpinning of legend
redbearsam Mar 19, 2019
f8e1145
Update d3fc to use new seriesCanvasMulti
Ro4052 Mar 19, 2019
728bf63
add fuzzy factor to cropCellContents to ensure we always hit the char…
redbearsam Mar 19, 2019
f5c6631
converted draggable function to use a more d3-like structure
redbearsam Mar 19, 2019
7e99b49
Refactored shared svg/canvas gridlines
Ro4052 Mar 20, 2019
fd1814b
Merge pull request #98 from redbearsam/feature/legend_draggable_and_k…
redbearsam Mar 20, 2019
0dbe178
Switch to more component-like model
Ro4052 Mar 20, 2019
3155e0b
Changed `mode` string to `canvas` boolean
Ro4052 Mar 20, 2019
8d4680e
Merge pull request #109 from redbearsam/refactor/gridlines
Ro4052 Mar 20, 2019
e775cb4
Switched ohlc and candlestick charts to canvas
Ro4052 Mar 20, 2019
a488259
Fixed tooltip for ohlc and candlestick
Ro4052 Mar 20, 2019
240e94e
Merge pull request #110 from redbearsam/feature/ohlc-canvas
Ro4052 Mar 20, 2019
1ab6060
Implemented fix for missing final date value
Ro4052 Mar 20, 2019
55e9bc5
More generic date padding approach
Ro4052 Mar 21, 2019
52c2f1d
Change bar alignment when not using an ordinal scale
andy-lee-eng Mar 21, 2019
7fcbda1
Support single data value edge case
Ro4052 Mar 21, 2019
ec00be8
Implemented more robust bar width calculation
Ro4052 Mar 21, 2019
90007e9
Merge pull request #112 from redbearsam/fix/data-extents
Ro4052 Mar 22, 2019
16c25e2
Added bollinger bands and moving average to candle/ohlc (#111)
andy-lee-eng Mar 22, 2019
52d929a
Merge remote-tracking branch 'origin/master'
andy-lee-eng Mar 22, 2019
73799b0
Merge branch 'master' into develop
andy-lee-eng Mar 22, 2019
2019d04
Implemented selection events from d3fc plugin
andy-lee-eng Mar 22, 2019
716e88e
Raising events with correctly typed values for numbers and dates
andy-lee-eng Mar 22, 2019
4868088
Merge pull request #113 from redbearsam/feature/selection-events
matt-hooper Mar 22, 2019
5e7ff57
Theme chart series from CSS and theme file (#114)
andy-lee-eng Mar 25, 2019
85e3a40
Added integration screenshot tests for more d3fc charts
andy-lee-eng Mar 25, 2019
2a18683
Added Candlestick and OHLC tests
andy-lee-eng Mar 25, 2019
0816f45
Merge branch 'master' of https://github.com/jpmorganchase/perspective…
matt-hooper Mar 26, 2019
46c762d
Merge branch 'jpmorganchase-master' into develop
matt-hooper Mar 26, 2019
f1b6b42
Merge pull request #116 from redbearsam/merge/jpmorganchase-master
matt-hooper Mar 26, 2019
25af799
Fixed legend when only one series
andy-lee-eng Mar 26, 2019
6d86def
Merge pull request #118 from redbearsam/feature/fix-legend
matt-hooper Mar 26, 2019
f78d1e7
Merge pull request #117 from redbearsam/feature/test-more-charts
matt-hooper Mar 26, 2019
9ada6aa
refresh screenshots and update shares-template
matt-hooper Mar 26, 2019
76a6944
Merge pull request #120 from redbearsam/develop
matt-hooper Mar 26, 2019
4058fb1
restore original packages/perspective-viewer-highcharts/test/results/…
matt-hooper Mar 26, 2019
5b04105
Merge pull request #119 from redbearsam/refresh_screenshots
matt-hooper Mar 26, 2019
30fdb82
Merge pull request #121 from redbearsam/develop
matt-hooper Mar 26, 2019
dd77cd5
merge results.json
matt-hooper Mar 26, 2019
0248167
Merge branch 'jpmorganchase-master' into develop
matt-hooper Mar 26, 2019
325e935
Merge pull request #123 from redbearsam/add_GIT_COMMIT
matt-hooper Mar 26, 2019
8cb9602
Merge pull request #124 from redbearsam/develop
matt-hooper Mar 26, 2019
76447ce
Switched to new d3fc canvas gridline component
Ro4052 Mar 27, 2019
cad5882
Add missing comma and fully qualify build path
matt-hooper Mar 27, 2019
fe52f06
Merge pull request #127 from redbearsam/feature/canvas-gridlines
Ro4052 Mar 27, 2019
4aee480
merge latest master
matt-hooper Mar 27, 2019
2fb2182
Merge branch 'jpmorganchase-master' into develop
matt-hooper Mar 27, 2019
49dfa23
Merge branch 'fix/qualify_build_path' into merge/master
matt-hooper Mar 27, 2019
f29b4e3
move integration tests into integration folder
matt-hooper Mar 27, 2019
525e04e
merge yarn.lock
matt-hooper Mar 27, 2019
6443c5f
Merge pull request #130 from redbearsam/merge/master
matt-hooper Mar 27, 2019
859f03b
Merge pull request #132 from redbearsam/develop
matt-hooper Mar 27, 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
2 changes: 1 addition & 1 deletion packages/perspective-viewer-d3fc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"chroma-js": "^1.3.4",
"d3": "^5.7.0",
"d3-svg-legend": "^2.25.6",
"d3fc": "^14.0.31",
"d3fc": "^14.0.34",
"gradient-parser": "0.1.5"
},
"devDependencies": {
Expand Down
15 changes: 13 additions & 2 deletions packages/perspective-viewer-d3fc/src/js/axis/crossAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,28 @@ const flattenArray = array => {
}
};

const getMinimumGap = (data, dataMap) =>
data
.map(dataMap)
.sort((a, b) => a - b)
.filter((d, i, a) => i === 0 || d !== a[i - 1])
.reduce((acc, d, i, src) => (i === 0 || acc <= d - src[i - 1] ? acc : d - src[i - 1]));

export const domain = settings => {
let valueName = "crossValue";
let settingName = "crossValues";

const extentTime = fc.extentTime().accessors([d => new Date(d[valueName])]);
const extentTime = fc
.extentTime()
.accessors([d => new Date(d[valueName])])
.padUnit("domain");

const _domain = function(data) {
const flattenedData = flattenArray(data);
switch (axisType(settings, settingName)) {
case AXIS_TYPES.time:
return extentTime(flattenedData);
const dataWidth = getMinimumGap(flattenedData, d => new Date(d[valueName]).getTime());
return extentTime.pad([dataWidth / 2, dataWidth / 2])(flattenedData);
default:
return [...new Set(flattenedData.map(d => d[valueName]))];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective-viewer-d3fc/src/js/charts/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {seriesColors} from "../series/seriesColors";
import {splitAndBaseData} from "../data/splitAndBaseData";
import {colorLegend} from "../legend/legend";
import {filterData} from "../legend/filter";
import {withGridLines} from "../gridlines/gridlines";
import withGridLines from "../gridlines/gridlines";

import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero";
import zoomableChart from "../zoom/zoomableChart";
Expand Down
18 changes: 8 additions & 10 deletions packages/perspective-viewer-d3fc/src/js/charts/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {seriesColors} from "../series/seriesColors";
import {groupAndStackData} from "../data/groupData";
import {colorLegend} from "../legend/legend";
import {filterData} from "../legend/filter";
import {withGridLines} from "../gridlines/gridlines";
import withGridLines from "../gridlines/gridlines";

import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero";
import zoomableChart from "../zoom/zoomableChart";
Expand All @@ -27,16 +27,11 @@ function barChart(container, settings) {
.settings(settings)
.scale(color);

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

const yDomain = crossAxis
.domain(settings)(data)
Expand Down Expand Up @@ -68,8 +63,11 @@ function barChart(container, settings) {
.xNice()
.plotArea(withGridLines(series).orient("horizontal"));

chart.yPaddingInner && chart.yPaddingInner(0.5);
chart.yPaddingOuter && chart.yPaddingOuter(0.25);
if (chart.yPaddingInner) {
chart.yPaddingInner(0.5);
chart.yPaddingOuter(0.25);
bars.align("left");
}

const zoomChart = zoomableChart()
.chart(chart)
Expand Down
4 changes: 2 additions & 2 deletions packages/perspective-viewer-d3fc/src/js/charts/candlestick.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import {seriesSvgCandlestick} from "d3fc";
import {seriesCanvasCandlestick} from "d3fc";
import ohlcCandle from "./ohlcCandle";

const candlestick = ohlcCandle(seriesSvgCandlestick);
const candlestick = ohlcCandle(seriesCanvasCandlestick);
candlestick.plugin = {
type: "d3_candlestick",
name: "[d3fc] Candlestick Chart",
Expand Down
18 changes: 8 additions & 10 deletions packages/perspective-viewer-d3fc/src/js/charts/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {seriesColors} from "../series/seriesColors";
import {groupAndStackData} from "../data/groupData";
import {colorLegend} from "../legend/legend";
import {filterData} from "../legend/filter";
import {withGridLines} from "../gridlines/gridlines";
import withGridLines from "../gridlines/gridlines";
import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero";
import zoomableChart from "../zoom/zoomableChart";

Expand All @@ -26,16 +26,11 @@ function columnChart(container, settings) {
.settings(settings)
.scale(color);

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

const xDomain = crossAxis.domain(settings)(data);
const xScale = crossAxis.scale(settings);
Expand All @@ -62,8 +57,11 @@ function columnChart(container, settings) {
.yNice()
.plotArea(withGridLines(series).orient("vertical"));

chart.xPaddingInner && chart.xPaddingInner(0.5);
chart.xPaddingOuter && chart.xPaddingOuter(0.25);
if (chart.xPaddingInner) {
chart.xPaddingInner(0.5);
chart.xPaddingOuter(0.25);
bars.align("left");
}

const zoomChart = zoomableChart()
.chart(chart)
Expand Down
16 changes: 11 additions & 5 deletions packages/perspective-viewer-d3fc/src/js/charts/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {heatmapSeries} from "../series/heatmapSeries";
import {seriesColorRange} from "../series/seriesRange";
import {heatmapData} from "../data/heatmapData";
import {filterData} from "../legend/filter";
import {withGridLines} from "../gridlines/gridlines";
import withGridLines from "../gridlines/gridlines";
import {colorRangeLegend} from "../legend/colorRangeLegend";
import zoomableChart from "../zoom/zoomableChart";

Expand Down Expand Up @@ -58,10 +58,16 @@ function heatmapChart(container, settings) {
.yOrient("left")
.plotArea(withGridLines(series));

chart.xPaddingInner && chart.xPaddingInner(0);
chart.xPaddingOuter && chart.xPaddingOuter(0);
chart.yPaddingInner && chart.yPaddingInner(0);
chart.yPaddingOuter && chart.yPaddingOuter(0);
if (chart.xPaddingInner) {
chart.xPaddingInner(0);
chart.xPaddingOuter(0);
series.xAlign("right");
}
if (chart.yPaddingInner) {
chart.yPaddingInner(0);
chart.yPaddingOuter(0);
series.yAlign("top");
}

const zoomChart = zoomableChart()
.chart(chart)
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective-viewer-d3fc/src/js/charts/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {lineSeries} from "../series/lineSeries";
import {splitData} from "../data/splitData";
import {colorLegend} from "../legend/legend";
import {filterData} from "../legend/filter";
import {withGridLines} from "../gridlines/gridlines";
import withGridLines from "../gridlines/gridlines";

import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero";
import zoomableChart from "../zoom/zoomableChart";
Expand Down
4 changes: 2 additions & 2 deletions packages/perspective-viewer-d3fc/src/js/charts/ohlc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
import {seriesSvgOhlc} from "d3fc";
import {seriesCanvasOhlc} from "d3fc";
import ohlcCandle from "./ohlcCandle";

const ohlc = ohlcCandle(seriesSvgOhlc);
const ohlc = ohlcCandle(seriesCanvasOhlc);
ohlc.plugin = {
type: "d3_ohlc",
name: "[d3fc] OHLC Chart",
Expand Down
52 changes: 28 additions & 24 deletions packages/perspective-viewer-d3fc/src/js/charts/ohlcCandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,42 @@ import * as crossAxis from "../axis/crossAxis";
import * as mainAxis from "../axis/mainAxis";
import {ohlcData} from "../data/ohlcData";
import {filterDataByGroup} from "../legend/filter";
import {withGridLines} from "../gridlines/gridlines";
import withGridLines from "../gridlines/gridlines";

import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero";
import zoomableChart from "../zoom/zoomableChart";
import nearbyTip from "../tooltip/nearbyTip";
import {seriesUpColors, seriesDownColors} from "../series/seriesColors";
import {ohlcCandleSeries} from "../series/ohlcCandleSeries";
import {colorScale, setOpacity} from "../series/seriesColors";
import {colorLegend} from "../legend/legend";

const isUp = d => d.closeValue >= d.openValue;

function ohlcCandle(seriesSvg) {
function ohlcCandle(seriesCanvas) {
return function(container, settings) {
const data = ohlcData(settings, filterDataByGroup(settings));
const srcData = ohlcData(settings, filterDataByGroup(settings));

const bollinger = fc.indicatorBollingerBands().value(d => d.openValue);
const data = srcData.map(seriesData => {
const bollingerData = bollinger(seriesData);
return seriesData.map((d, i) => Object.assign({bollinger: bollingerData[i]}, d));
});

const keys = data
const keys = srcData
.map(k => k.key)
.concat(settings.hideKeys ? settings.hideKeys : [])
.sort();

const upColor = seriesUpColors(keys);
const downColor = seriesDownColors(keys);
const upColor = colorScale()
.domain(keys)
.mapFunction(setOpacity(1))();

const legend = colorLegend()
.settings(settings)
.scale(keys.length > 1 ? upColor : null);

const series = seriesSvg()
.crossValue(d => d.crossValue)
.openValue(d => d.openValue)
.highValue(d => d.highValue)
.lowValue(d => d.lowValue)
.closeValue(d => d.closeValue)
.decorate(selection => {
selection.style("fill", d => (isUp(d) ? upColor(d.key) : downColor(d.key)));
selection.style("stroke", d => (isUp(d) ? upColor(d.key) : downColor(d.key)));
});
const series = ohlcCandleSeries(settings, seriesCanvas, upColor);

const multi = fc
.seriesSvgMulti()
.seriesCanvasMulti()
.mapping((data, index) => data[index])
.series(data.map(() => series));

Expand All @@ -63,7 +60,7 @@ function ohlcCandle(seriesSvg) {
const yScale = mainAxis.scale(settings);

const chart = fc
.chartSvgCartesian({
.chartCanvasCartesian({
xScale,
yScale,
xAxis
Expand All @@ -81,7 +78,11 @@ function ohlcCandle(seriesSvg) {
.yLabel(mainAxis.label(settings))
.yOrient("left")
.yNice()
.plotArea(withGridLines(multi).orient("vertical"));
.plotArea(
withGridLines(multi)
.orient("vertical")
.canvas(true)
);

chart.xPaddingInner && chart.xPaddingInner(1);
chart.xPaddingOuter && chart.xPaddingOuter(0.5);
Expand All @@ -90,14 +91,17 @@ function ohlcCandle(seriesSvg) {
.chart(chart)
.settings(settings)
.xScale(xScale)
.yScale(yScale);
.yScale(yScale)
.canvas(true);

const toolTip = nearbyTip()
.settings(settings)
.xScale(xScale)
.yScale(yScale)
.yValueName("closeValue")
.data(data);
.color(upColor)
.data(data)
.canvas(true);

// render
container.datum(data).call(zoomChart);
Expand Down
4 changes: 2 additions & 2 deletions packages/perspective-viewer-d3fc/src/js/charts/xy-scatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {seriesLinearRange, seriesColorRange} from "../series/seriesRange";
import {symbolLegend} from "../legend/legend";
import {colorRangeLegend} from "../legend/colorRangeLegend";
import {filterDataByGroup} from "../legend/filter";
import {withCanvasGridLines} from "../gridlines/gridlines";
import withGridLines from "../gridlines/gridlines";
import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero";
import zoomableChart from "../zoom/zoomableChart";
import nearbyTip from "../tooltip/nearbyTip";
Expand Down Expand Up @@ -60,7 +60,7 @@ function xyScatter(container, settings) {
.yOrient("left")
.yNice()
.xNice()
.plotArea(withCanvasGridLines(series));
.plotArea(withGridLines(series).canvas(true));

const zoomChart = zoomableChart()
.chart(chart)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {categoryPointSeries, symbolType} from "../series/categoryPointSeries";
import {groupData} from "../data/groupData";
import {symbolLegend} from "../legend/legend";
import {filterData} from "../legend/filter";
import {withGridLines} from "../gridlines/gridlines";
import withGridLines from "../gridlines/gridlines";
import {hardLimitZeroPadding} from "../d3fc/padding/hardLimitZero";
import zoomableChart from "../zoom/zoomableChart";
import nearbyTip from "../tooltip/nearbyTip";
Expand Down
Loading