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

Simplify Data Model #17

Merged
merged 3 commits into from
May 25, 2020
Merged

Simplify Data Model #17

merged 3 commits into from
May 25, 2020

Conversation

texodus
Copy link
Member

@texodus texodus commented May 25, 2020

Simplifies the data model to a single function. There is still quite a bit of functionality left out of this new API, which the perspective.html example now activates via extra, special keys prefixed with __. Here's a simple example of what this new API looks like, as implemented on a large two dimensional Array.

const all_column_names = [
    "Column 1 (number)", 
    "Column 2 (string)",
    ...
];

const data = [
    [0, 1, 2, 3, 4, 5, ...], 
    ["A", "B", "C", "D", "E", "F", ...], 
    ...
];
 
function getDataSlice(x0, y0, x1, y1) {
    const slice = data.slice(x0, x1).map(col => col.slice(y0, y1));
    const column_names = all_column_names.slice(x0, x1);
    const num_columns = data.length;
    const num_rows = data[0].length;    
    return {num_rows, num_columns, column_names, slice};
}
 
const regularTable = document.createElement("regular-table");
document.body.appendChild(regularTable);
regularTable.setDataModel(getDataSlice);

Also adds unit tests for get_meta() metadata methods.

@texodus texodus merged commit c6a5d97 into master May 25, 2020
@texodus texodus deleted the simplify branch May 25, 2020 17:30
@texodus texodus changed the title Simplify Simplify Data Model May 25, 2020
@telamonian
Copy link
Contributor

I think this pretty much takes care of the simple case (flat columns, no row names). Quite nice!

const visible_columns = column_paths.slice(viewport.start_col);
const columns_data = await view.to_columns(viewport);
const {view, config, schema} = view_cache;
const {data, row_indices, column_indices, __id_column: id_column} = await view(viewport.start_col, viewport.start_row, viewport.end_col, viewport.end_row);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the motivation behind rearranging the indices to this particular order?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants