Skip to content

Commit

Permalink
Replace row_pivots with group_by, column_pivots with split_by
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Feb 1, 2022
1 parent d78112f commit d40d8f1
Show file tree
Hide file tree
Showing 124 changed files with 2,114 additions and 1,773 deletions.
13 changes: 6 additions & 7 deletions cpp/perspective/src/cpp/emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,10 +1451,9 @@ namespace binding {
make_view_config(const t_gnode& gnode, std::shared_ptr<t_schema> schema,
t_val date_parser, t_val config) {
// extract vectors from JS, where they were created
auto row_pivots
= config.call<std::vector<std::string>>("get_row_pivots");
auto row_pivots = config.call<std::vector<std::string>>("get_group_by");
auto column_pivots
= config.call<std::vector<std::string>>("get_column_pivots");
= config.call<std::vector<std::string>>("get_split_by");
auto columns = config.call<std::vector<std::string>>("get_columns");
auto sort
= config.call<std::vector<std::vector<std::string>>>("get_sort");
Expand Down Expand Up @@ -1578,14 +1577,14 @@ namespace binding {
view_config->init(schema);

// set pivot depths if provided
if (has_value(config["row_pivot_depth"])) {
if (has_value(config["group_by_depth"])) {
view_config->set_row_pivot_depth(
config["row_pivot_depth"].as<std::int32_t>());
config["group_by_depth"].as<std::int32_t>());
}

if (has_value(config["column_pivot_depth"])) {
if (has_value(config["split_by_depth"])) {
view_config->set_column_pivot_depth(
config["column_pivot_depth"].as<std::int32_t>());
config["split_by_depth"].as<std::int32_t>());
}

return view_config;
Expand Down
4 changes: 2 additions & 2 deletions cpp/perspective/src/cpp/view_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ t_view_config::validate(std::shared_ptr<t_schema> schema) {
for (const std::string& col : m_row_pivots) {
if (!schema->has_column(col) && expression_aliases.count(col) == 0) {
std::stringstream ss;
ss << "Invalid column '" << col << "' found in View row_pivots."
ss << "Invalid column '" << col << "' found in View group_by."
<< std::endl;
PSP_COMPLAIN_AND_ABORT(ss.str());
}
Expand All @@ -83,7 +83,7 @@ t_view_config::validate(std::shared_ptr<t_schema> schema) {
for (const std::string& col : m_column_pivots) {
if (!schema->has_column(col) && expression_aliases.count(col) == 0) {
std::stringstream ss;
ss << "Invalid column '" << col << "' found in View column_pivots."
ss << "Invalid column '" << col << "' found in View split_by."
<< std::endl;
PSP_COMPLAIN_AND_ABORT(ss.str());
}
Expand Down
28 changes: 21 additions & 7 deletions docs/js/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {EXAMPLES} = require("./features.js");

const DEFAULT_VIEWPORT = {
width: 400,
height: 300
height: 300,
};

async function run_with_theme(page, is_dark = false) {
Expand All @@ -19,7 +19,9 @@ async function run_with_theme(page, is_dark = false) {
<script src="/node_modules/@finos/perspective-viewer/dist/umd/perspective-viewer.js"></script>
<script src="/node_modules/@finos/perspective-viewer-datagrid/dist/umd/perspective-viewer-datagrid.js"></script>
<script src="/node_modules/@finos/perspective-viewer-d3fc/dist/umd/perspective-viewer-d3fc.js"></script>
<link rel='stylesheet' href="/node_modules/@finos/perspective-viewer/dist/umd/material-dense.${is_dark ? "dark." : ""}css" is="custom-style">
<link rel='stylesheet' href="/node_modules/@finos/perspective-viewer/dist/umd/material-dense.${
is_dark ? "dark." : ""
}css" is="custom-style">
<style>
perspective-viewer {
position: absolute;
Expand Down Expand Up @@ -54,7 +56,7 @@ async function run_with_theme(page, is_dark = false) {
</body>
</html>`);
await page.setViewport(DEFAULT_VIEWPORT);
await page.evaluate(async function() {
await page.evaluate(async function () {
const viewer = document.querySelector("perspective-viewer");
await viewer.flush();
await viewer.toggleConfig();
Expand All @@ -65,9 +67,19 @@ async function run_with_theme(page, is_dark = false) {
for (const idx in EXAMPLES) {
const {config, viewport} = EXAMPLES[idx];
await await page.setViewport(viewport || DEFAULT_VIEWPORT);
const new_config = Object.assign({plugin: "Datagrid", row_pivots: [], expressions: [], column_pivots: [], sort: [], aggregates: {}}, config);
const new_config = Object.assign(
{
plugin: "Datagrid",
group_by: [],
expressions: [],
split_by: [],
sort: [],
aggregates: {},
},
config
);
console.log(JSON.stringify(new_config));
await page.evaluate(async config => {
await page.evaluate(async (config) => {
const viewer = document.querySelector("perspective-viewer");
await viewer.reset();
await viewer.restore(config);
Expand All @@ -76,10 +88,12 @@ async function run_with_theme(page, is_dark = false) {
await page.waitForSelector("perspective-viewer:not([updating])");
const screenshot = await page.screenshot({
captureBeyondViewport: false,
fullPage: true
fullPage: true,
});

const name = `static/features/feature_${idx}${is_dark ? "_dark" : ""}.png`;
const name = `static/features/feature_${idx}${
is_dark ? "_dark" : ""
}.png`;
fs.writeFileSync(name, screenshot);
cp.execSync(`convert ${name} -resize 400x300 ${name}`);
// html.push(`<img src="./test_${idx}.png"></img>`);
Expand Down
Loading

0 comments on commit d40d8f1

Please sign in to comment.