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

Column-only pivoting. #15

Merged
merged 2 commits into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
Column-only pivoting.
  • Loading branch information
texodus committed Jan 31, 2018
commit ef955adea5c8d8e12dbb821738be11be19f407c2
3 changes: 2 additions & 1 deletion packages/perspective-viewer-hypergrid/src/js/hypergrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ var light_theme_overrides = {
backgroundColor: '#ffffff',
color: "#666",
lineColor: '#AAA',
font: '12px Arial, Helvetica, sans-serif',
// font: '12px Arial, Helvetica, sans-serif',
font: '12px "Open Sans", Helvetica, sans-serif',
foregroundSelectionFont: '12px amplitude-regular, Helvetica, sans-serif',
foregroundSelectionColor: '#666',
backgroundSelectionColor: 'rgba(162, 183, 206, 0.3)',
Expand Down
9 changes: 9 additions & 0 deletions packages/perspective-viewer-hypergrid/src/less/hypergrid.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/******************************************************************************
*
* 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.
*
*/

perspective-hypergrid {
width: 100%;
position: relative;
Expand Down
11 changes: 6 additions & 5 deletions packages/perspective-viewer/src/js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,12 @@ function new_row(name, type, aggregate) {
if (!type) {
let all = Array.prototype.slice.call(this.querySelectorAll('#inactive_columns perspective-row'));
if (all.length > 0) {
type = all.find(x => x.getAttribute('name') === name).getAttribute('type');
type = all.find(x => x.getAttribute('name') === name)
if (type) {
type = type.getAttribute('type');
} else {
type = "integer";
}
} else {
type = '';
}
Expand Down Expand Up @@ -365,10 +370,6 @@ function update() {
let filters = JSON.parse(this.getAttribute('filters'));
let aggregates = this._get_view_aggregates();
if (aggregates.length === 0) return;
if (row_pivots.length === 0 && column_pivots.length > 0) {
row_pivots = column_pivots;
column_pivots = [];
}
let hidden = [];
let sort = this._view_columns("#sort perspective-row");
for (let s of sort) {
Expand Down
6 changes: 2 additions & 4 deletions packages/perspective-viewer/src/less/row.less
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,11 @@ perspective-viewer[view=scatter], perspective-viewer[view=line] {
}
}

perspective-viewer:not([row-pivots='[]']) #side_panel #active_columns perspective-row #column_aggregate,
perspective-viewer:not([column-pivots='[]']) #side_panel #active_columns perspective-row #column_aggregate {
perspective-viewer:not([row-pivots='[]']) #side_panel #active_columns perspective-row #column_aggregate {
display: inline-block;
}

perspective-viewer:not([row-pivots='[]']) #side_panel,
perspective-viewer:not([column-pivots='[]']) #side_panel {
perspective-viewer:not([row-pivots='[]']) #side_panel {
#active_columns perspective-row .row_draggable {
height: 41px;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/perspective/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ if(DEFINED ENV{WASM_OPTIMIZE})
else()
set(OPT_FLAGS " \
-Os \
-g3 \
-g4 \
-s SAFE_HEAP=1 \
-s DISABLE_EXCEPTION_CATCHING=0 \
-s ALLOW_MEMORY_GROWTH=1 \
-s ASSERTIONS=2 \
-s DEMANGLE_SUPPORT=1 \
Expand Down
50 changes: 34 additions & 16 deletions packages/perspective/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ vecFromTypedArray(const val &typedArray, void* data, t_int32 length) {

template<typename T>
void
_fill_col(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index)
_fill_col(val dcol, t_col_sptr col, t_col_sptr key_col, t_col_sptr okey_col, bool fill_index)
{
t_uindex nrows = col->size();

Expand All @@ -169,14 +169,15 @@ _fill_col(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index)
if (fill_index)
{
key_col->set_nth(i, elem);
okey_col->set_nth(i, elem);
}
}
}
}

template<>
void
_fill_col<t_int64>(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index)
_fill_col<t_int64>(val dcol, t_col_sptr col, t_col_sptr key_col, t_col_sptr okey_col, bool fill_index)
{
t_uindex nrows = col->size();

Expand All @@ -192,7 +193,7 @@ _fill_col<t_int64>(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index

template<>
void
_fill_col<t_time>(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index)
_fill_col<t_time>(val dcol, t_col_sptr col, t_col_sptr key_col, t_col_sptr okey_col, bool fill_index)
{
t_uindex nrows = col->size();

Expand All @@ -209,14 +210,15 @@ _fill_col<t_time>(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index)
if (fill_index)
{
key_col->set_nth(i, elem);
okey_col->set_nth(i, elem);
}
}
}
}

template<>
void
_fill_col<t_bool>(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index)
_fill_col<t_bool>(val dcol, t_col_sptr col, t_col_sptr key_col, t_col_sptr okey_col, bool fill_index)
{
t_uindex nrows = col->size();

Expand All @@ -236,6 +238,7 @@ _fill_col<t_bool>(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index)
if (fill_index)
{
key_col->set_nth(i, elem);
okey_col->set_nth(i, elem);
}
}
}
Expand Down Expand Up @@ -285,7 +288,7 @@ _fill_col_dict(t_uint32 nrows, val dcol, val vkeys, t_col_sptr col)

template<>
void
_fill_col<std::string>(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_index)
_fill_col<std::string>(val dcol, t_col_sptr col, t_col_sptr key_col, t_col_sptr okey_col, bool fill_index)
{

t_uindex nrows = col->size();
Expand Down Expand Up @@ -344,7 +347,8 @@ _fill_col<std::string>(val dcol, t_col_sptr col, t_col_sptr key_col, bool fill_i
col->set_nth(i, elem);
if (fill_index)
{
key_col->set_nth(i, elem);
key_col->set_nth(i, elem);
okey_col->set_nth(i, elem);
}
}
}
Expand Down Expand Up @@ -372,9 +376,14 @@ _fill_data(t_table_sptr tbl,
std::vector<val> data_cols = vecFromJSArray<val>(j_data);
auto op_col = tbl->get_column("psp_op");
auto key_col = tbl->get_column("psp_pkey");
auto okey_col = tbl->get_column("psp_okey");
for (auto cidx = 0; cidx < ocolnames.size(); ++cidx)
{
auto name = ocolnames[cidx];
if (name == "psp_okey")
{
continue;
}
auto col = tbl->get_column(name);
auto col_type = odt[cidx];
auto fill_index = name == index;
Expand All @@ -384,47 +393,47 @@ _fill_data(t_table_sptr tbl,
{
case DTYPE_INT8:
{
_fill_col<t_int8>(dcol, col, key_col, fill_index);
_fill_col<t_int8>(dcol, col, key_col, okey_col, fill_index);
}
break;
case DTYPE_INT16:
{
_fill_col<t_int16>(dcol, col, key_col, fill_index);
_fill_col<t_int16>(dcol, col, key_col, okey_col, fill_index);
}
break;
case DTYPE_INT32:
{
_fill_col<t_int32>(dcol, col, key_col, fill_index);
_fill_col<t_int32>(dcol, col, key_col, okey_col, fill_index);
}
break;
case DTYPE_INT64:
{
_fill_col<t_int64>(dcol, col, key_col, fill_index);
_fill_col<t_int64>(dcol, col, key_col, okey_col, fill_index);
}
break;
case DTYPE_BOOL:
{
_fill_col<t_bool>(dcol, col, key_col, fill_index);
_fill_col<t_bool>(dcol, col, key_col, okey_col, fill_index);
}
break;
case DTYPE_FLOAT32:
{
_fill_col<t_float32>(dcol, col, key_col, fill_index);
_fill_col<t_float32>(dcol, col, key_col, okey_col, fill_index);
}
break;
case DTYPE_FLOAT64:
{
_fill_col<t_float64>(dcol, col, key_col, fill_index);
_fill_col<t_float64>(dcol, col, key_col, okey_col, fill_index);
}
break;
case DTYPE_TIME:
{
_fill_col<t_time>(dcol, col, key_col, fill_index);
_fill_col<t_time>(dcol, col, key_col, okey_col, fill_index);
}
break;
case DTYPE_STR:
{
_fill_col<std::string>(dcol, col, key_col, fill_index);
_fill_col<std::string>(dcol, col, key_col, okey_col, fill_index);
}
break;
default:
Expand All @@ -436,7 +445,8 @@ _fill_data(t_table_sptr tbl,
op_col->set_nth<t_uint8>(ridx, OP_INSERT);
if (index == "")
{
key_col->set_nth<t_uint32>(ridx, ridx + offset);
key_col->set_nth<t_int32>(ridx, ridx + offset);
okey_col->set_nth<t_int32>(ridx, ridx + offset);
}
}
}
Expand Down Expand Up @@ -472,13 +482,17 @@ make_table(
// Create the input and port schemas
t_svec ocolnames = vecFromJSArray<std::string>(j_colnames);
t_svec icolnames = ocolnames;
icolnames.push_back("psp_okey");
icolnames.push_back("psp_op");
icolnames.push_back("psp_pkey");
ocolnames.push_back("psp_okey");

t_dtypevec idt = vecFromJSArray<t_dtype>(j_dtypes);
t_dtypevec odt = idt;
idt.push_back(tindex);
idt.push_back(DTYPE_UINT8);
idt.push_back(tindex);
odt.push_back(tindex);

t_schema iscm(icolnames, idt);
t_schema oscm(ocolnames, odt);
Expand Down Expand Up @@ -531,13 +545,17 @@ make_gnode(val j_colnames, val j_dtypes, t_dtype tindex)
// Create the input and port schemas
t_svec ocolnames = vecFromJSArray<std::string>(j_colnames);
t_svec icolnames = ocolnames;
icolnames.push_back("psp_okey");
icolnames.push_back("psp_op");
icolnames.push_back("psp_pkey");
ocolnames.push_back("psp_okey");

t_dtypevec idt = vecFromJSArray<t_dtype>(j_dtypes);
t_dtypevec odt = idt;
idt.push_back(tindex);
idt.push_back(DTYPE_UINT8);
idt.push_back(tindex);
odt.push_back(tindex);

t_schema iscm(icolnames, idt);
t_schema oscm(ocolnames, odt);
Expand Down
Loading