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

cellContent: function(d) is called twice for every cell #87

Closed
mrjones-plip opened this issue Sep 24, 2018 · 2 comments
Closed

cellContent: function(d) is called twice for every cell #87

mrjones-plip opened this issue Sep 24, 2018 · 2 comments
Labels

Comments

@mrjones-plip
Copy link
Contributor

mrjones-plip commented Sep 24, 2018

when using cellContent(), the function is called twice for every cell. When doing display work (eg make it a certain color) it's safe to do twice, but when doing statics, and for general performance, this is bad.

steps to reproduce:

  1. create a maptable with a cellContent() function.
  2. declare a var before the maptable: var count = 0;
  3. inside your cellContent() function add a line count += 1;

expected: count == number of rows in table
actual: count == 2 x number of rows in table


here's some prototypical code to illustrate the problem:

var rowCount = 0;
var viz = d3.maptable('#vizContainer')
.csv(URL_HERE)
.table()
.columns({
    Key: {
        cellContent: function(d){
            rowCount += 1;
            return d.Key;
        },
    },
})
.render(postProcess);
function postProcess() {
    console.log('row count: ' + rowCount);
}
@melalj
Copy link
Member

melalj commented Oct 22, 2018

Found out that there was a double rendering for table. Fixed on #90

@mrjones-plip
Copy link
Contributor Author

about to release 1.7.0, closing this as one of the fixes in that release.

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

No branches or pull requests

2 participants