Skip to content

Commit

Permalink
merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGermaneri committed Aug 15, 2017
2 parents 0b31768 + af2efee commit 28eb4f7
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 17 deletions.
7 changes: 3 additions & 4 deletions README.md
@@ -1,16 +1,15 @@
Canvas Data Grid
================

![coverage](https://coveralls.io/repos/github/TonyGermaneri/canvas-datagrid/badge.svg?branch=master)

[Demo](https://tonygermaneri.github.io/canvas-datagrid/tutorials/demo.html)

![canvas-datagrid](https://tonygermaneri.github.io/canvas-datagrid/images/datagrid1.png)

* High performance hierarchal canvas based data grid.
![coverage](https://coveralls.io/repos/github/TonyGermaneri/canvas-datagrid/badge.svg?branch=master)

* Support for millions of rows and columns.
* Extensible styling, filtering, formatting, resizing, selecting, and ordering.
* Support for touch devices (phones and tablets).
* Extensible styling, filtering, formatting, resizing, selecting, and ordering.
* Built in and custom styles.
* Hierarchal context menu.
* Per-user styles, settings using localStorage.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,7 +1,7 @@
{
"name": "canvas-datagrid",
"main": "lib/main.js",
"version": "0.14.2",
"version": "0.14.3",
"ignore": [
"**/.*",
"node_modules",
Expand Down
2 changes: 1 addition & 1 deletion build.txt
@@ -1 +1 @@
1416
1421
1 change: 1 addition & 0 deletions dist/canvas-datagrid.debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/canvas-datagrid.debug.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/canvas-datagrid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/canvas-datagrid.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/draw.js
Expand Up @@ -196,6 +196,7 @@ define([], function () {
* @method
*/
self.draw = function (internal) {
if (self.dispatchEvent('beforedraw', {})) { return; }
if (!self.isChildGrid && (!self.height || !self.width)) {
return;
}
Expand Down Expand Up @@ -900,6 +901,7 @@ define([], function () {
}
drawBorder();
drawDebug();
if (self.dispatchEvent('afterdraw', {})) { return; }
self.ctx.restore();
};
};
Expand Down
2 changes: 2 additions & 0 deletions lib/publicMethods.js
Expand Up @@ -16,6 +16,8 @@ define([], function () {
* @param {method} [callback] Callback method if any to be called 1 ms after the completion of this otherwise sync task.
*/
self.assertPxColor = function (x, y, expected, callback) {
x = x * window.devicePixelRatio;
y = y * window.devicePixelRatio;
var d = self.ctx.getImageData(x, y, 1, 1).data;
d = 'rgb(' + [d['0'], d['1'], d['2']].join(', ') + ')';
if (expected) {
Expand Down
7 changes: 4 additions & 3 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "canvas-datagrid",
"version": "0.14.2",
"version": "0.14.3",
"description": "Canvas based data grid",
"main": "./lib/main.js",
"scripts": {
Expand All @@ -10,7 +10,7 @@
"build-watch": "./node_modules/.bin/webpack --output-library=canvasDatagrid --output-library-target=umd --watch -d --entry=./lib/main.js --output-path=./dist --output-filename=canvas-datagrid.debug.js --devtool source-map --output-source-map-filename='canvas-datagrid.debug.map'",
"build-dev": "./node_modules/.bin/webpack --output-library=canvasDatagrid --output-library-target=umd -d --entry=./lib/main.js --output-path=./dist --output-filename=canvas-datagrid.debug.js --devtool source-map --output-source-map-filename='canvas-datagrid.debug.map'",
"test": "npm run build-instrument;npm run build-pack-instrument;npm run build-run-test;npm run build-run-report",
"build-instrument": "mkdir build || true;echo \"$((`cat build.txt` + 1))\" > build.txt;./node_modules/.bin/istanbul instrument ./lib -o ./build/lib",
"build-instrument": "rm -rf build;mkdir build;echo \"$((`cat build.txt` + 1))\" > build.txt;./node_modules/.bin/istanbul instrument ./lib -o ./build/lib",
"build-pack-instrument": "./node_modules/.bin/webpack --output-library=canvasDatagrid --output-library-target=umd -d --entry=./build/lib/main.js --output-path=./build --output-filename=canvas-datagrid.instrument.js --devtool source-map --output-source-map-filename='canvas-datagrid.instrument.map'",
"build-run-test": "./node_modules/.bin/phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test/tests.html spec '{\"hooks\": \"mocha-phantomjs-istanbul\", \"coverageFile\": \"./build/coverage.json\"}'",
"build-run-report": "./node_modules/.bin/istanbul report --root ./build --dir ./build/report --reporter text --reporter lcov",
Expand Down Expand Up @@ -53,13 +53,14 @@
},
"homepage": "https://github.com/TonyGermaneri/canvas-datagrid#readme",
"devDependencies": {
"async": "^2.5.0",
"ink-docstrap": "git+ssh://git@github.com:TonyGermaneri/docstrap.git#v1.2.6",
"node-coveralls": "git@github.com:nickmerwin/node-coveralls.git",
"istanbul": "^0.4.5",
"jsdoc": "^3.4.3",
"mocha": "^3.5.0",
"mocha-phantomjs": "^4.1.0",
"mocha-phantomjs-core": "^2.1.2",
"node-coveralls": "git@github.com:nickmerwin/node-coveralls.git",
"phantomjs": "^2.1.7",
"should": "^11.2.1",
"webpack": "^3.0.0"
Expand Down
2 changes: 2 additions & 0 deletions test/tests.html
Expand Up @@ -21,6 +21,8 @@
<script>
mocha.setup('bdd');
</script>
<script src="../node_modules/async/dist/async.min.js"></script>
<!-- <script src="../dist/canvas-datagrid.debug.js"></script> -->
<script src="../build/canvas-datagrid.instrument.js"></script>
<script src="./tests.js"></script>
<script>
Expand Down
41 changes: 36 additions & 5 deletions test/tests.js
@@ -1,8 +1,9 @@
/*jslint browser: true*/
/*globals describe: false, afterEach: false, after: false, it: false, canvasDatagrid: false*/
/*globals describe: false, afterEach: false, after: false, it: false, canvasDatagrid: false, async: false*/
(function () {
'use strict';
var c = {
fu: 'rgb(255, 0, 255)',
white: 'rgb(255, 255, 255)',
black: 'rgb(0, 0, 0)'
},
Expand All @@ -19,7 +20,11 @@
return canvasDatagrid(args);
}
function assertIf(cond, msg) {
if (cond) { throw new Error(msg); }
var x;
for (x = 2; x < arguments.length; x += 1) {
msg = msg.replace(/%s|%n/, arguments[x]);
}
if (cond) { return new Error(msg); }
}
describe('canvas-datagrid: integration tests', function () {
it('Should create an instance of datagrid', function (done) {
Expand All @@ -41,14 +46,40 @@
});
assertIf(grid.data.length !== 3,
'Expected to see data in the interface.');
grid.assertPxColor(100, 37, c.white, done);
grid.assertPxColor(100, 32, c.white, done);
});
it('Should set the cell color to black.', function (done) {
var grid = g({
data: smallData
});
grid.style.activeCellBackgroundColor = c.black;
grid.assertPxColor(100, 37, c.black, done);
grid.style.activeCellBackgroundColor = c.black;
grid.assertPxColor(100, 32, c.black, done);
});
it('Each style setter should call draw 1 time.', function (done) {
var grid = g({
data: smallData
}),
styleKeys = Object.keys(grid.style),
eventCount = -1;
grid.addEventListener('beforedraw', function () {
eventCount += 1;
});
async.eachSeries(styleKeys, function (s, cb) {
grid.style[s] = grid.style[s];
setTimeout(cb, 1);
}, function () {
done(assertIf(eventCount !== styleKeys.length,
'Wrong number of draw invocations on style setters. Expected %n got %n.', styleKeys.length, eventCount));
});
});
it('Should set the cell color to black.', function (done) {
var grid = g({
data: smallData
});
grid.style.activeCellBackgroundColor = c.black;
grid.style.activeCellBackgroundColor = c.black;
grid.assertPxColor(100, 32, c.black, done);
});
});
}());
}());

0 comments on commit 28eb4f7

Please sign in to comment.