Skip to content

Commit

Permalink
Merge pull request #726 from finos/misc-cleanup-and-fixes
Browse files Browse the repository at this point in the history
Misc cleanup and fixes
  • Loading branch information
texodus authored Sep 14, 2019
2 parents a8a50ef + a3febd2 commit d6ac242
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/perspective-viewer-d3fc/src/js/axis/axisType.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const axisType = settings => {

if (settings[settingName].length === 0) {
return AXIS_TYPES.none;
} else if (excludeType != AXIS_TYPES.time && checkTypes(["datetime"])) {
} else if (excludeType != AXIS_TYPES.time && checkTypes(["datetime", "date"])) {
return AXIS_TYPES.time;
} else if (excludeType != AXIS_TYPES.linear && checkTypes(["integer", "float"])) {
return AXIS_TYPES.linear;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

function toValue(type, value) {
switch (type) {
case "date":
case "datetime":
return value instanceof Date ? value : new Date(parseInt(value));
case "integer":
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective-viewer-d3fc/src/less/chart.less
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
&[borderbox-on-hover="true"] {
transition: box-shadow 1s;
&:hover {
box-shadow: 2px 2px 6px #000;
box-shadow: 0px 2px 5px rgba(0,0,0,0.2);
transition: box-shadow 0.2s;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective-viewer-d3fc/test/results/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@
"sunburst.html/highlights invalid filter.": "e48566c24b1655a202d1d227424f71c5",
"sunburst.html/sorts by an alpha column.": "dca6a09d9b0c4b4a3fd6cdb91fa1eb1a",
"sunburst.html/displays visible columns.": "92769650f8ccaf823d070f3bd12aa73b",
"__GIT_COMMIT__": "13d836c9ddaa8374b884e9807f8a433c3fc53a6e"
"__GIT_COMMIT__": "7b829d2c5a9bea3a6bbdd679ef9b4c86ad356ccd"
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"render_warning.html/render warning should not show under size limit.": "8b216a2b86af03bbd65f71261e2f1167",
"render_warning.html/render warning should show above size limit.": "b962cd6103977f5295dd24e773c9c426",
"render_warning.html/dismissing render warning should trigger render.": "f0dbd0bb32ddd7f500aae54d65b6c10a",
"render_warning.html/underlying data updates should not trigger rerender if warning is visible.": "5978b1cefd7590fe27f0e4d088a42a56",
"render_warning.html/underlying data updates should not trigger rerender if warning is visible.": "423ef1bf54472a0a9b8869130d164cc5",
"bar.html/highlights invalid filter.": "d1de0d4a84bde25d5b2e33185923f5b6",
"scatter.html/highlights invalid filter.": "6de6490dddf52cfccb56ca7fd67557e8",
"line.html/highlights invalid filter.": "06752a9e251ff55c1e0afe3bb47216c5",
Expand All @@ -99,5 +99,5 @@
"bar.html/perspective dispatches perspective-click event with one filter.": "32d64db28af46dfe77fad5cc1ca8af9c",
"bar.html/perspective dispatches perspective-click event with filters.": "c18f49270244dfe4a6b32270ec30d99d",
"bar.html/dates on the x-axis display correctly.": "591a1c8e9493451b6885b9651917ffff",
"__GIT_COMMIT__": "13d836c9ddaa8374b884e9807f8a433c3fc53a6e"
"__GIT_COMMIT__": "7b829d2c5a9bea3a6bbdd679ef9b4c86ad356ccd"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"superstore.html/shows a sort indicator": "5f4aae968d2dac96781c954e05d34303",
"superstore.html/shows multiple sort indicators": "b6f6bd22638f550ee07cadc46c1c37c0",
"superstore.html/shows a sort indicator on column split": "5391f996d29f1144d87ddc5f802e8c52",
"__GIT_COMMIT__": "13d836c9ddaa8374b884e9807f8a433c3fc53a6e",
"__GIT_COMMIT__": "7b829d2c5a9bea3a6bbdd679ef9b4c86ad356ccd",
"superstore.html/should reinterpret metadata when only row pivots are changed": "fb9c5cb1b9a4148023f6edf4bffd27db",
"empty.html/perspective-click is fired when an empty dataset is loaded first": "7e5b653226145e1ab9f82e2417d89d7b",
"superstore.html/should not edit an immutable viewer": "8d99c2bc8bf7450a5f2cc4f5b1ca7412",
Expand Down
2 changes: 0 additions & 2 deletions packages/perspective-viewer/src/js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import "@webcomponents/webcomponentsjs";

import _ from "lodash";
import {polyfill} from "mobile-drag-drop";

import {bindTemplate, json_attribute, array_attribute, copy_to_clipboard} from "./utils.js";
Expand Down Expand Up @@ -67,7 +66,6 @@ class PerspectiveViewer extends ActionElement {
this._register_debounce_instance();
this._show_config = true;
this._show_warnings = true;
this._resize_handler = _.debounce(this.notifyResize, 250).bind(this);
window.addEventListener("load", this._resize_handler);
window.addEventListener("resize", this._resize_handler);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/perspective-viewer/src/js/viewer/action_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ export class ActionElement extends DomElement {
const resize = event => {
const new_width = Math.max(0, Math.min(width + (event.clientX - start), this.offsetWidth - 10));
this._side_panel.style.width = `${new_width}px`;
if (this._plugin) {
this._resize_handler();
}
};
const stop = () => {
document.body.style.cursor = initial;
Expand Down
16 changes: 12 additions & 4 deletions packages/perspective-viewer/src/js/viewer/perspective_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ function get_aggregates_with_defaults(aggregate_attribute, schema, cols) {
}

function calculate_throttle_timeout(render_time) {
if (!render_time || render_time.length < 5) {
return 0;
}
const view_count = document.getElementsByTagName("perspective-viewer").length;
const timeout = render_time * view_count * 2;
const avg = render_time.reduce((x, y) => x + y, 0) / render_time.length;
const timeout = avg * view_count * 2;
return Math.min(10000, Math.max(0, timeout));
}

Expand Down Expand Up @@ -271,7 +275,7 @@ export class PerspectiveElement extends StateElement {
} finally {
this.dispatchEvent(new Event("perspective-view-update"));
}
}, calculate_throttle_timeout(this.__render_time));
}, calculate_throttle_timeout(this.__render_times));
}
}

Expand Down Expand Up @@ -385,7 +389,8 @@ export class PerspectiveElement extends StateElement {
} catch (err) {
console.warn(err);
} finally {
if (!this.__render_time) {
if (!this.__render_times) {
this.__render_times = [];
this.dispatchEvent(new Event("perspective-view-update"));
}
timer();
Expand All @@ -399,7 +404,8 @@ export class PerspectiveElement extends StateElement {

_render_time() {
const t = performance.now();
return () => (this.__render_time = `${performance.now() - t}`);
let i = 0;
return () => (this.__render_times[i++ % 5] = performance.now() - t);
}

_restyle_plugin() {
Expand Down Expand Up @@ -452,6 +458,8 @@ export class PerspectiveElement extends StateElement {
resolve();
}
};

this._resize_handler = _.throttle(this.notifyResize, 100).bind(this);
}

_get_worker() {
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective-viewer/test/results/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"superstore.html/saving a duplicate column should fail with error message.": "d9618357228698c5fbe9978b3ed1f668",
"superstore.html/highlights invalid filter.": "b31284a7b2a401d232ed077ec097a653",
"superstore.html/replaces all rows.": "7a7265b18d5c94f8f90abcad4f3f7781",
"__GIT_COMMIT__": "13d836c9ddaa8374b884e9807f8a433c3fc53a6e",
"__GIT_COMMIT__": "7b829d2c5a9bea3a6bbdd679ef9b4c86ad356ccd",
"superstore.html/shows horizontal columns on small vertical viewports.": "05d7c917b5eb9e05387d52e3a6372c67",
"superstore.html/shows horizontal columns on small vertical and horizontal viewports.": "4cde889ccdbecba750e76f287707626f",
"superstore.html/user defined aggregates maintained on computed columns": "4047d2fd3b973a0492f805da9f604dbc"
Expand Down

0 comments on commit d6ac242

Please sign in to comment.