Skip to content

Commit

Permalink
throttle added
Browse files Browse the repository at this point in the history
  • Loading branch information
stevewirts committed Oct 9, 2015
1 parent 20b7f9f commit 83b493e
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 35 deletions.
17 changes: 15 additions & 2 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
fileref.setAttribute("shim-shadowdom", ' ');
fileref.setAttribute("href", 'themes/' + theme + '.css');
document.getElementsByTagName("head")[0].appendChild(fileref);


var updatePermuteRate = function(slider) {
var output = document.querySelector('#permuteInterval');
var inMemoryGrid = document.querySelector('#in-memory-example');
output.innerHTML = slider.value;
inMemoryGrid.getBehavior().permuteInterval = parseInt(slider.value);
};


</script>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>fin-hypergrid Demo</title>
Expand Down Expand Up @@ -151,9 +161,9 @@
<h3>fin-hypergrid-behavior-in-memory


</h3> This element is a custom Polymer web component that is a demonstration of a simple subclass of the fin-hypergrid-behavior-default. It demonstrates live high frequency updating of data, variable width columns, alternate cell renderers, and alternate cell editors(double click in various cells of column 'J'). Press Alt/Option to toggle the column picker. Also, Take note that hypergrid supports <a href="https://polymerthemes.com/">polymer themes</a> and one can be selected from the top left menu.
<br>
</h3> This element is a custom Polymer web component that is a demonstration of a simple subclass of the fin-hypergrid-behavior-default. It demonstrates live high frequency updating of data, variable width columns, alternate cell renderers, and alternate cell editors(double click in various cells of column 'J'). Press Alt/Option to toggle the column picker. Also, Take note that hypergrid supports <a href="https://polymerthemes.com/">polymer themes</a> and one can be selected from the top left menu. The data permute interval is the rate that the data is being randomly changed. Keep in mind the CPU utilization is from this and NOT hypergrid overhead.<br>Data Permute Interval<input style="margin: 15px" oninput="updatePermuteRate(this)" id="slider" type="range" value="50" min="16" max="1000" step="1" /><span style="font-size: large" id="permuteInterval"></span>
<br>

</div>
<core-splitter direction="up"></core-splitter>
<div flex class="rel">
Expand Down Expand Up @@ -347,6 +357,9 @@ <h3>fin-hypergrid-behavior-gol</h3> This element is another custom Polymer web c
//get ahold of our in memory example
var inMemoryGrid = document.querySelector('#in-memory-example');

var output = document.querySelector('#permuteInterval');
output.innerHTML = inMemoryGrid.getBehavior().permuteInterval;

//lets turn his scrollbars to always on....
var lnfOverrides = {
scrollbarHoverOver: 'visible',
Expand Down
43 changes: 43 additions & 0 deletions examples/cmz.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<html>
<head>
<script src="../../webcomponentsjs/webcomponents.js"></script>
<!-- <link rel="stylesheet" href="../themes/excel.css"> -->
<link rel="import" href="../polymer/html/fin-hypergrid.html">

<!-- <link rel="import" href="../fin-hypergrid.dev.html"> -->
<script src="../js/sampledata.js"></script>
<style>

body {
position: absolute;
top: 0%;
right: 0%;
bottom: 0%;
left: 0%;
padding: 0%;
margin: 15px 0 0 0;
background-color: #ffffff;
}
fin-hypergrid {
width: 100%;
height: 100%;
position: relative;
}
table {

}
</style>
</head>
<body>
<fin-hypergrid id="json-grid" style="position:absolute;width:100%;height:100%">
<fin-hypergrid-behavior-json ></fin-hypergrid-behavior-json>
</fin-hypergrid>
</body>
<script>
window.addEventListener('polymer-ready',function() {
var table = document.querySelector('#json-grid');
var behavior = table.getBehavior();
behavior.setData(window.people);
});
</script>
</html>
28 changes: 18 additions & 10 deletions fin-hypergrid.dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -15484,7 +15484,7 @@
*
* @property {SimpleLRU} textWidthCache - a LRU cache of 10000 of text widths
*/
var textWidthCache = new SimpleLRU(10000);
var textWidthCache = new SimpleLRU(4000);

/**
*
Expand Down Expand Up @@ -24568,14 +24568,18 @@
var myWidths = tableState.columnWidths;
var repaint = false;
var a, b, c, d = 0;
var newVal;
for (c = 0; c < fixedMinWidths.length; c++) {
a = myFixed[c];
b = fixedMinWidths[c];
d = tableState.fixedColumnAutosized[c];
if (a !== b || !d) {
myFixed[c] = !d ? b : Math.max(a, b);
tableState.fixedColumnAutosized[c] = true;
repaint = true;
newVal = !d ? b : Math.max(a, b);
if (myFixed[c] !== newVal) {
myFixed[c] = newVal;
tableState.fixedColumnAutosized[c] = true;
repaint = true;
}
}
}
for (c = 0; c < minWidths.length; c++) {
Expand All @@ -24584,9 +24588,12 @@
b = minWidths[c];
d = tableState.columnAutosized[c];
if (a !== b || !d) {
myWidths[ti] = !d ? b : Math.max(a, b);
tableState.columnAutosized[c] = true;
repaint = true;
newVal = !d ? b : Math.max(a, b);
if (myWidths[ti] !== newVal) {
myWidths[ti] = newVal;
tableState.columnAutosized[c] = true;
repaint = true;
}
}
}
if (repaint) {
Expand Down Expand Up @@ -32297,9 +32304,9 @@
this.fire('load');
this.isScrollButtonClick = false;

setInterval(function() {
self.checkRepaint();
}, 16);
// setInterval(function() {
// self.checkRepaint();
// }, 16);

},

Expand Down Expand Up @@ -32949,6 +32956,7 @@
*/
repaint: function() {
this.repaintFlag = true;
this.checkRepaint();
},

/**
Expand Down
8 changes: 4 additions & 4 deletions fin-hypergrid.min.html

Large diffs are not rendered by default.

54 changes: 45 additions & 9 deletions js/sampledata.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,51 @@
var income = randomFunc() * 100000;
var employed = Math.round(randomFunc());
var person = {
last_name: lastNames[lastName], //jshint ignore:line
first_name: firstNames[firstName], //jshint ignore:line
pets: pets,
birthDate: birthyear + '-' + months[birthmonth] + '-' + days[birthday],
birthState: states[birthstate],
residenceState: states[residencestate],
employed: employed === 1,
income: income,
travel: travel
last_name0: lastNames[lastName], //jshint ignore:line
first_name0: firstNames[firstName], //jshint ignore:line
pets0: pets,
birthDate0: birthyear + '-' + months[birthmonth] + '-' + days[birthday],
birthState0: states[birthstate],
residenceState0: states[residencestate],
employed0: employed === 1,
income0: income,
travel0: travel,
last_name1: lastNames[lastName], //jshint ignore:line
first_name1: firstNames[firstName], //jshint ignore:line
pets1: pets,
birthDate1: birthyear + '-' + months[birthmonth] + '-' + days[birthday],
birthState1: states[birthstate],
residenceState1: states[residencestate],
employed1: employed === 1,
income1: income,
travel1: travel,
last_name2: lastNames[lastName], //jshint ignore:line
first_name2: firstNames[firstName], //jshint ignore:line
pets2: pets,
birthDate2: birthyear + '-' + months[birthmonth] + '-' + days[birthday],
birthState2: states[birthstate],
residenceState2: states[residencestate],
employed2: employed === 1,
income2: income,
travel2: travel,
last_name3: lastNames[lastName], //jshint ignore:line
first_name3: firstNames[firstName], //jshint ignore:line
pets3: pets,
birthDate3: birthyear + '-' + months[birthmonth] + '-' + days[birthday],
birthState3: states[birthstate],
residenceState3: states[residencestate],
employed3: employed === 1,
income3: income,
travel3: travel,
last_name4: lastNames[lastName], //jshint ignore:line
first_name4: firstNames[firstName], //jshint ignore:line
pets4: pets,
birthDate4: birthyear + '-' + months[birthmonth] + '-' + days[birthday],
birthState4: states[birthstate],
residenceState4: states[residencestate],
employed4: employed === 1,
income4: income,
travel4: travel
};
return person;
};
Expand Down
19 changes: 13 additions & 6 deletions polymer/js/behaviors/fin-hypergrid-behavior-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -1651,14 +1651,18 @@ it contains all code/data that's necessary for easily implementing a virtual dat
var myWidths = tableState.columnWidths;
var repaint = false;
var a, b, c, d = 0;
var newVal;
for (c = 0; c < fixedMinWidths.length; c++) {
a = myFixed[c];
b = fixedMinWidths[c];
d = tableState.fixedColumnAutosized[c];
if (a !== b || !d) {
myFixed[c] = !d ? b : Math.max(a, b);
tableState.fixedColumnAutosized[c] = true;
repaint = true;
newVal = !d ? b : Math.max(a, b);
if (myFixed[c] !== newVal) {
myFixed[c] = newVal;
tableState.fixedColumnAutosized[c] = true;
repaint = true;
}
}
}
for (c = 0; c < minWidths.length; c++) {
Expand All @@ -1667,9 +1671,12 @@ it contains all code/data that's necessary for easily implementing a virtual dat
b = minWidths[c];
d = tableState.columnAutosized[c];
if (a !== b || !d) {
myWidths[ti] = !d ? b : Math.max(a, b);
tableState.columnAutosized[c] = true;
repaint = true;
newVal = !d ? b : Math.max(a, b);
if (myWidths[ti] !== newVal) {
myWidths[ti] = newVal;
tableState.columnAutosized[c] = true;
repaint = true;
}
}
}
if (repaint) {
Expand Down
2 changes: 1 addition & 1 deletion polymer/js/fin-hypergrid-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var fontData = {};
*
* @property {SimpleLRU} textWidthCache - a LRU cache of 10000 of text widths
*/
var textWidthCache = new SimpleLRU(10000);
var textWidthCache = new SimpleLRU(4000);

/**
*
Expand Down
7 changes: 4 additions & 3 deletions polymer/js/fin-hypergrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@
this.fire('load');
this.isScrollButtonClick = false;

setInterval(function() {
self.checkRepaint();
}, 16);
// setInterval(function() {
// self.checkRepaint();
// }, 16);

},

Expand Down Expand Up @@ -1086,6 +1086,7 @@
*/
repaint: function() {
this.repaintFlag = true;
this.checkRepaint();
},

/**
Expand Down

0 comments on commit 83b493e

Please sign in to comment.