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

Update plugin #120

Merged
merged 184 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
f23b3e2
Use signed t_index, use shared_ptr only for the slice
sc1f Mar 7, 2019
b934aff
Working data slice for zero-sides
sc1f Mar 10, 2019
bd05c37
Working data slice for one-side
sc1f Mar 12, 2019
6986ed2
Added __ROW_PATH__ to t_data_slice.m_column_names, removed clean_data…
texodus Mar 14, 2019
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
0b06ac5
1-sided contexts cannot be column_only
texodus Mar 14, 2019
6aae31b
Merge pull request #483 from jpmorganchase/data-slice
texodus Mar 14, 2019
ba5dd9a
remove unnecessary css
redbearsam Mar 14, 2019
49dd654
Fixed 0-sided schema
texodus Mar 15, 2019
9ab6283
Fixed lint_cpp script
texodus Mar 15, 2019
cb62fbf
Merge pull request #486 from jpmorganchase/schema-fix
texodus Mar 15, 2019
3d625fa
Merge pull request #487 from jpmorganchase/lint-fix
texodus Mar 15, 2019
a315342
Added window support to `to_arrow()`
texodus Mar 15, 2019
f8e537d
Merge pull request #485 from jpmorganchase/arraybuffer-range
texodus Mar 16, 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
9ed7f20
Merge pull request #484 from redbearsam/d3fc_plugin
texodus 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
0bc44a9
Add sort indicators to data grid headers
zemeolotu Mar 15, 2019
bbfda36
Added sort indicator tests
texodus Mar 18, 2019
09d296a
Merge pull request #489 from jpmorganchase/header-sort-indicator
texodus 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
1d3304a
Ensure that filter column stays active when filtering
JHawk Mar 20, 2019
e7b380c
Merge pull request #490 from jpmorganchase/keep-filter-col-in-grid
texodus Mar 20, 2019
1ab6060
Implemented fix for missing final date value
Ro4052 Mar 20, 2019
f0ee538
Update the load path to find perspective
JHawk Mar 20, 2019
20da41a
Add both options
JHawk 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
50d4ba7
Do not show number on the header indicator if only one column is sorted
zemeolotu 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
cf5ed47
Merge pull request #491 from jpmorganchase/fix-webpack-config-load-path
texodus 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
9c99ba9
Fix sum abs agg
JHawk Mar 22, 2019
0e9f8ae
Ensure null label is correct for tree charts
JHawk Mar 22, 2019
ac60c79
Test that exposes the duplicate null pivot
JHawk Mar 22, 2019
40647d4
Skip failing null update pivot test
JHawk 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
5fc64b6
Merge pull request #493 from jpmorganchase/fix-sum-abs
texodus Mar 25, 2019
60693e3
Merge pull request #492 from zemeolotu/header-sort-indicator-fix
texodus Mar 25, 2019
389356d
Merge pull request #488 from redbearsam/d3fc_plugin
texodus Mar 25, 2019
c225a8e
`on_update` delta calculations are now lazy
texodus Mar 26, 2019
ba2b5d9
Merge pull request #495 from jpmorganchase/new-update-api
texodus Mar 26, 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
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 cpp/perspective/src/cpp/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ str_to_aggtype(std::string str) {
return t_aggtype::AGGTYPE_HIGH_WATER_MARK;
} else if (str == "low" || str == "low_water_mark") {
return t_aggtype::AGGTYPE_LOW_WATER_MARK;
} else if (str == "sub abs") {
} else if (str == "sum abs") {
return t_aggtype::AGGTYPE_SUM_ABS;
} else if (str == "sum not null" || str == "sum_not_null") {
return t_aggtype::AGGTYPE_SUM_NOT_NULL;
Expand Down
3 changes: 1 addition & 2 deletions cpp/perspective/src/cpp/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ t_config::t_config(const std::vector<std::string>& row_pivots, const t_aggspec&

t_config::t_config(const std::vector<t_pivot>& row_pivots,
const std::vector<t_aggspec>& aggregates, t_filter_op combiner,
const std::vector<t_fterm>& fterms, bool column_only)
const std::vector<t_fterm>& fterms)
: m_row_pivots(row_pivots)
, m_column_only(column_only)
, m_aggregates(aggregates)
, m_totals(TOTALS_BEFORE)
, m_combiner(combiner)
Expand Down
77 changes: 44 additions & 33 deletions cpp/perspective/src/cpp/data_slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,32 @@ namespace perspective {
template <typename CTX_T>
t_data_slice<CTX_T>::t_data_slice(std::shared_ptr<CTX_T> ctx, t_uindex start_row,
t_uindex end_row, t_uindex start_col, t_uindex end_col,
std::shared_ptr<std::vector<t_tscalar>> slice,
std::shared_ptr<std::vector<std::string>> column_names)
const std::shared_ptr<std::vector<t_tscalar>>& slice, std::vector<std::string> column_names)
: m_ctx(ctx)
, m_start_row(start_row)
, m_end_row(end_row)
, m_start_col(start_col)
, m_end_col(end_col)
, m_slice(slice)
, m_column_names(column_names) {}
, m_column_names(column_names) {
m_stride = m_end_col - m_start_col;
}

template <typename CTX_T>
t_data_slice<CTX_T>::t_data_slice(std::shared_ptr<CTX_T> ctx, t_uindex start_row,
t_uindex end_row, t_uindex start_col, t_uindex end_col,
std::shared_ptr<std::vector<t_tscalar>> slice,
std::shared_ptr<std::vector<std::string>> column_names,
std::shared_ptr<std::vector<t_uindex>> column_indices)
const std::shared_ptr<std::vector<t_tscalar>>& slice, std::vector<std::string> column_names,
std::vector<t_uindex> column_indices)
: m_ctx(ctx)
, m_start_row(start_row)
, m_end_row(end_row)
, m_start_col(start_col)
, m_end_col(end_col)
, m_slice(slice)
, m_column_names(column_names)
, m_column_indices(column_indices) {}
, m_column_indices(column_indices) {
m_stride = m_end_col - m_start_col;
}

template <typename CTX_T>
t_data_slice<CTX_T>::~t_data_slice() {}
Expand All @@ -53,34 +55,30 @@ t_data_slice<CTX_T>::~t_data_slice() {}
* @return t_tscalar a valid scalar containing the underlying data, or a new
* t_tscalar initialized with an invalid flag.
*/
template <>
t_tscalar
t_data_slice<t_ctx0>::get(t_uindex ridx, t_uindex col) const {
t_tscalar rv;
rv.clear();
return rv;
}

template <>
template <typename CTX_T>
t_tscalar
t_data_slice<t_ctx1>::get(t_uindex ridx, t_uindex cidx) const {
t_data_slice<CTX_T>::get(t_uindex ridx, t_uindex cidx) const {
t_uindex idx = get_slice_idx(ridx, cidx);
t_tscalar rv;
rv.clear();
if (idx >= m_slice->size()) {
rv.clear();
} else {
rv = m_slice->at(idx);
}
return rv;
}

template <>
t_tscalar
t_data_slice<t_ctx2>::get(t_uindex ridx, t_uindex cidx) const {
t_tscalar rv;
rv.clear();
return rv;
}
t_uindex idx = get_slice_idx(ridx, cidx);
t_tscalar rv = m_slice->operator[](idx);
/* if (m_column_indices.size() > 0) {
t_uindex idx_skip_headers;
} else {

template <>
std::vector<t_tscalar>
t_data_slice<t_ctx0>::get_row_path(t_uindex idx) const {
return std::vector<t_tscalar>();
} */
return rv;
}

template <typename CTX_T>
Expand All @@ -89,6 +87,13 @@ t_data_slice<CTX_T>::get_row_path(t_uindex idx) const {
return m_ctx->unity_get_row_path(idx);
}

template <typename CTX_T>
t_uindex
t_data_slice<CTX_T>::get_slice_idx(t_uindex ridx, t_uindex cidx) const {
t_uindex idx = (ridx - m_start_row) * m_stride + (cidx - m_start_col);
return idx;
}

// Getters
template <typename CTX_T>
std::shared_ptr<CTX_T>
Expand All @@ -103,28 +108,34 @@ t_data_slice<CTX_T>::get_slice() const {
}

template <typename CTX_T>
std::shared_ptr<std::vector<std::string>>
const std::vector<std::string>&
t_data_slice<CTX_T>::get_column_names() const {
return m_column_names;
}

template <typename CTX_T>
std::shared_ptr<std::vector<t_uindex>>
const std::vector<t_uindex>&
t_data_slice<CTX_T>::get_column_indices() const {
return m_column_indices;
}

template <typename CTX_T>
bool
t_data_slice<CTX_T>::is_column_only() const {
auto config = m_ctx->get_config();
return config.is_column_only();
return false;
}

template <>
bool
t_data_slice<t_ctx0>::is_column_only() const {
return false;
t_data_slice<t_ctx2>::is_column_only() const {
auto config = m_ctx->get_config();
return config.is_column_only();
}

template <typename CTX_T>
t_uindex
t_data_slice<CTX_T>::get_stride() const {
return m_stride;
}

template <typename CTX_T>
Expand All @@ -141,4 +152,4 @@ t_data_slice<CTX_T>::get_data_extents() const {
template class t_data_slice<t_ctx0>;
template class t_data_slice<t_ctx1>;
template class t_data_slice<t_ctx2>;
} // end namespace perspective
} // end namespace perspective
91 changes: 73 additions & 18 deletions cpp/perspective/src/cpp/emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,10 @@ namespace binding {
// Given a column index, serialize data to TypedArray
template <typename T>
val
col_to_js_typed_array(std::shared_ptr<View<T>> view, t_index idx, bool column_pivot_only) {
col_to_js_typed_array(std::shared_ptr<View<T>> view, t_index idx, bool column_pivot_only,
t_uindex start_row, t_uindex end_row) {
std::shared_ptr<T> ctx = view->get_context();
std::vector<t_tscalar> data = ctx->get_data(0, ctx->get_row_count(), idx, idx + 1);
std::vector<t_tscalar> data = ctx->get_data(start_row, end_row, idx, idx + 1);
auto dtype = ctx->get_column_dtype(idx);

switch (dtype) {
Expand Down Expand Up @@ -1663,7 +1664,6 @@ namespace binding {
auto schema = gnode->get_tblschema();
t_config view_config = make_view_config<val>(schema, separator, date_parser, config);

bool column_only = view_config.is_column_only();
auto aggregates = view_config.get_aggregates();
auto row_pivots = view_config.get_row_pivots();
auto filter_op = view_config.get_combiner();
Expand All @@ -1676,7 +1676,7 @@ namespace binding {
}

auto ctx = make_context_one(schema, row_pivots, filter_op, filters, aggregates, sorts,
pivot_depth, column_only, pool, gnode, name);
pivot_depth, pool, gnode, name);

auto view_ptr
= std::make_shared<View<t_ctx1>>(pool, ctx, gnode, name, separator, view_config);
Expand Down Expand Up @@ -1765,9 +1765,9 @@ namespace binding {
std::shared_ptr<t_ctx1>
make_context_one(t_schema schema, std::vector<t_pivot> pivots, t_filter_op combiner,
std::vector<t_fterm> filters, std::vector<t_aggspec> aggregates,
std::vector<t_sortspec> sorts, std::int32_t pivot_depth, bool column_only, t_pool* pool,
std::vector<t_sortspec> sorts, std::int32_t pivot_depth, t_pool* pool,
std::shared_ptr<t_gnode> gnode, std::string name) {
auto cfg = t_config(pivots, aggregates, combiner, filters, column_only);
auto cfg = t_config(pivots, aggregates, combiner, filters);
auto ctx1 = std::make_shared<t_ctx1>(schema, cfg);

ctx1->init();
Expand Down Expand Up @@ -1876,7 +1876,7 @@ namespace binding {
std::uint32_t start_col, std::uint32_t end_col) {
val arr = val::array();
auto data_slice = view->get_data(start_row, end_row, start_col, end_col);
auto slice = data_slice.get_slice();
auto slice = data_slice->get_slice();
for (auto idx = 0; idx < slice->size(); ++idx) {
arr.set(idx, scalar_to_val(slice->at(idx)));
}
Expand All @@ -1901,15 +1901,15 @@ namespace binding {
std::uint32_t start_col, std::uint32_t end_col) {
val arr = val::array();
auto data_slice = view->get_data(start_row, end_row, start_col, end_col);
auto slice = data_slice.get_slice();
auto column_indices = data_slice.get_column_indices();
auto slice = data_slice->get_slice();
auto column_indices = data_slice->get_column_indices();

if (column_indices->size() > 0) {
if (column_indices.size() > 0) {
t_uindex i = 0;
auto iter = slice->begin();
while (iter != slice->end()) {
t_uindex prev = column_indices->front();
for (auto idx = column_indices->begin(); idx != column_indices->end();
t_uindex prev = column_indices.front();
for (auto idx = column_indices.begin(); idx != column_indices.end();
idx++, i++) {
t_uindex col_num = *idx;
iter += col_num - prev;
Expand All @@ -1928,6 +1928,44 @@ namespace binding {
return arr;
}

/**
* @brief Get the t_data_slice object, which contains an underlying slice of data and
* metadata required to interact with it.
*
* @param view
* @param start_row
* @param end_row
* @param start_col
* @param end_col
* @return val
*/
template <typename CTX_T>
std::shared_ptr<t_data_slice<CTX_T>>
get_data_slice(std::shared_ptr<View<CTX_T>> view, std::uint32_t start_row,
std::uint32_t end_row, std::uint32_t start_col, std::uint32_t end_col) {
auto data_slice = view->get_data(start_row, end_row, start_col, end_col);
return data_slice;
}

/**
* @brief Retrieve a single value from the data slice and serialize it to an output
* type that interfaces with the binding language.
*
* @param view
* @param start_row
* @param end_row
* @param start_col
* @param end_col
* @return val
*/
template <typename CTX_T>
val
get_from_data_slice(
std::shared_ptr<t_data_slice<CTX_T>> data_slice, t_uindex ridx, t_uindex cidx) {
auto d = data_slice->get(ridx, cidx);
return scalar_to_val(d);
}

} // end namespace binding
} // end namespace perspective

Expand Down Expand Up @@ -1986,7 +2024,6 @@ EMSCRIPTEN_BINDINGS(perspective) {
.function("get_aggregates", &View<t_ctx0>::get_aggregates)
.function("get_filters", &View<t_ctx0>::get_filters)
.function("get_sorts", &View<t_ctx0>::get_sorts)
.function("get_row_path", &View<t_ctx0>::get_row_path)
.function("get_step_delta", &View<t_ctx0>::get_step_delta)
.function("is_column_only", &View<t_ctx0>::is_column_only);

Expand All @@ -2009,7 +2046,6 @@ EMSCRIPTEN_BINDINGS(perspective) {
.function("get_aggregates", &View<t_ctx1>::get_aggregates)
.function("get_filters", &View<t_ctx1>::get_filters)
.function("get_sorts", &View<t_ctx1>::get_sorts)
.function("get_row_path", &View<t_ctx1>::get_row_path)
.function("get_step_delta", &View<t_ctx1>::get_step_delta)
.function("is_column_only", &View<t_ctx1>::is_column_only);

Expand Down Expand Up @@ -2070,9 +2106,22 @@ EMSCRIPTEN_BINDINGS(perspective) {
*
* t_data_slice
*/
class_<t_data_slice<t_ctx0>>("t_data_slice_ctx0");
class_<t_data_slice<t_ctx1>>("t_data_slice_ctx1");
class_<t_data_slice<t_ctx2>>("t_data_slice_ctx2");
class_<t_data_slice<t_ctx0>>("t_data_slice_ctx0")
.smart_ptr<std::shared_ptr<t_data_slice<t_ctx0>>>("shared_ptr<t_data_slice<t_ctx0>>>")
.function<const std::vector<std::string>&>(
"get_column_names", &t_data_slice<t_ctx0>::get_column_names);

class_<t_data_slice<t_ctx1>>("t_data_slice_ctx1")
.smart_ptr<std::shared_ptr<t_data_slice<t_ctx1>>>("shared_ptr<t_data_slice<t_ctx1>>>")
.function<const std::vector<std::string>&>(
"get_column_names", &t_data_slice<t_ctx1>::get_column_names)
.function<std::vector<t_tscalar>>("get_row_path", &t_data_slice<t_ctx1>::get_row_path);

class_<t_data_slice<t_ctx2>>("t_data_slice_ctx2")
.smart_ptr<std::shared_ptr<t_data_slice<t_ctx2>>>("shared_ptr<t_data_slice<t_ctx2>>>")
.function<const std::vector<std::string>&>(
"get_column_names", &t_data_slice<t_ctx2>::get_column_names);

/******************************************************************************
*
* t_ctx0
Expand Down Expand Up @@ -2197,4 +2246,10 @@ EMSCRIPTEN_BINDINGS(perspective) {
function("make_view_zero", &make_view_zero<val>, allow_raw_pointers());
function("make_view_one", &make_view_one<val>, allow_raw_pointers());
function("make_view_two", &make_view_two<val>, allow_raw_pointers());
}
function("get_data_slice_zero", &get_data_slice<t_ctx0>, allow_raw_pointers());
function("get_from_data_slice_zero", &get_from_data_slice<t_ctx0>, allow_raw_pointers());
function("get_data_slice_one", &get_data_slice<t_ctx1>, allow_raw_pointers());
function("get_from_data_slice_one", &get_from_data_slice<t_ctx1>, allow_raw_pointers());
function("get_data_slice_two", &get_data_slice<t_ctx2>, allow_raw_pointers());
function("get_from_data_slice_two", &get_from_data_slice<t_ctx2>, allow_raw_pointers());
}
Loading